Skip to content

Commit

Permalink
Merge pull request #100 from Setono/up-deps
Browse files Browse the repository at this point in the history
Upgrade to latest event library version
  • Loading branch information
loevgaard authored Sep 12, 2023
2 parents 412b8f0 + 849069a commit 53403e0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"psr/log": "^1.1 || ^2.0 || ^3.0",
"setono/composite-compiler-pass": "^1.1",
"setono/google-analytics-bundle": "^2.0@alpha",
"setono/google-analytics-events": "^1.0@beta",
"setono/google-analytics-events": "^1.0@rc",
"setono/google-analytics-measurement-protocol": "^2.0@beta",
"sylius/channel": "^1.0",
"sylius/channel-bundle": "^1.0",
Expand Down
8 changes: 4 additions & 4 deletions src/EventSubscriber/ViewItemListSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public function track(ItemListViewed $viewItemListEvent): void
{
try {
$event = ViewItemListEvent::create()
->setListId($viewItemListEvent->listId)
->setListName($viewItemListEvent->listName)
->setItemListId($viewItemListEvent->listId)
->setItemListName($viewItemListEvent->listName)
;

foreach ($viewItemListEvent->products as $product) {
Expand Down Expand Up @@ -93,8 +93,8 @@ public function trackNative(ResourceControllerEvent $resourceControllerEvent): v
$taxon = $this->resolveTaxon();
if (null !== $taxon) {
$event
->setListId($taxon->getCode())
->setListName($taxon->getName())
->setItemListId($taxon->getCode())
->setItemListName($taxon->getName())
;
}

Expand Down
16 changes: 8 additions & 8 deletions src/Resolver/Item/ItemResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ public function resolveFromOrderItem(OrderItemInterface $orderItem): Item
Assert::notNull($variant);

$item = Item::create()
->setId($variant->getCode())
->setName($orderItem->getProductName())
->setVariant($this->variantResolver->resolve($variant))
->setBrand($this->brandResolver->resolveFromProductVariant($variant))
->setItemId($variant->getCode())
->setItemName($orderItem->getProductName())
->setItemVariant($this->variantResolver->resolve($variant))
->setItemBrand($this->brandResolver->resolveFromProductVariant($variant))
->setQuantity($orderItem->getQuantity())
->setPrice(self::formatAmount($orderItem->getFullDiscountedUnitPrice()))
;
Expand All @@ -86,9 +86,9 @@ public function resolveFromProduct(ProductInterface $product): Item
Assert::isInstanceOf($variant, ProductVariantInterface::class);

$item = Item::create()
->setId($product->getCode())
->setName($product->getName())
->setBrand($this->brandResolver->resolveFromProduct($product))
->setItemId($product->getCode())
->setItemName($product->getName())
->setItemBrand($this->brandResolver->resolveFromProduct($product))
;

try {
Expand Down Expand Up @@ -119,7 +119,7 @@ private function populateCategories(Item $item, array $categories): void
break;
}

$method = sprintf('setCategory%s', 0 === $idx ? '' : (string) ($idx + 1));
$method = sprintf('setItemCategory%s', 0 === $idx ? '' : (string) ($idx + 1));
$item->{$method}($category);
}
}
Expand Down
12 changes: 6 additions & 6 deletions tests/Resolver/Item/ItemResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ public function it_resolves_from_order_item(): void
$orderItem->getVariant()->willReturn($productVariant->reveal());
$item = $resolver->resolveFromOrderItem($orderItem->reveal());

self::assertSame('T_SHIRT', $item->getId());
self::assertSame('PHP T-shirt', $item->getName());
self::assertSame('T_SHIRT', $item->getItemId());
self::assertSame('PHP T-shirt', $item->getItemName());
self::assertSame(2, $item->getQuantity());
self::assertSame('Large', $item->getVariant());
self::assertSame('PHP', $item->getBrand());
self::assertSame('Apparel', $item->getCategory());
self::assertSame('T-shirts', $item->getCategory2());
self::assertSame('Large', $item->getItemVariant());
self::assertSame('PHP', $item->getItemBrand());
self::assertSame('Apparel', $item->getItemCategory());
self::assertSame('T-shirts', $item->getItemCategory2());
}
}

0 comments on commit 53403e0

Please sign in to comment.