Skip to content

Commit 516182b

Browse files
authored
Merge pull request #73 from CommerceWeavers/fix-build
Fix for builds
2 parents 239026d + 165e6b6 commit 516182b

9 files changed

+22
-18
lines changed

src/Handler/CreateBoughtTogetherAssociationTypeHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
final class CreateBoughtTogetherAssociationTypeHandler
1616
{
1717
/**
18-
* @param FactoryInterface<ProductAssociationTypeInterface> $productAssociationTypeFactory
18+
* @implements FactoryInterface<ProductAssociationTypeInterface> $productAssociationTypeFactory
1919
*/
2020
public function __construct(
21-
private FactoryInterface $productAssociationTypeFactory,
22-
private ProductAssociationTypeRepositoryInterface $productAssociationTypeRepository,
21+
private readonly FactoryInterface $productAssociationTypeFactory,
22+
private readonly ProductAssociationTypeRepositoryInterface $productAssociationTypeRepository,
2323
) {
2424
}
2525

src/Handler/SynchronizeFrequentlyBoughtTogetherProductsHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __invoke(SynchronizeFrequentlyBoughtTogetherProducts $command):
3333
$lastSynchronizationDate = $this->lastSynchronizationDateProvider->provide();
3434

3535
$synchronizationResult = $this->frequentlyBoughtTogetherProductsSynchronizer->synchronize(
36-
$lastSynchronizationDate ?? (new \DateTimeImmutable())->setTimestamp(0)
36+
$lastSynchronizationDate ?? (new \DateTimeImmutable())->setTimestamp(0),
3737
);
3838

3939
$event = new SynchronizationEnded(

src/Provider/BoughtTogetherProductsAssociationProvider.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,26 @@
88
use CommerceWeavers\SyliusAlsoBoughtPlugin\Exception\BoughtTogetherAssociationTypeNotFoundException;
99
use Sylius\Component\Core\Model\ProductInterface;
1010
use Sylius\Component\Product\Model\ProductAssociation;
11+
use Sylius\Component\Product\Model\ProductAssociationInterface;
1112
use Sylius\Component\Product\Model\ProductAssociationType;
13+
use Sylius\Component\Product\Model\ProductAssociationTypeInterface;
1214
use Sylius\Component\Resource\Factory\FactoryInterface;
1315
use Sylius\Component\Resource\Repository\RepositoryInterface;
1416
use Webmozart\Assert\Assert;
1517

1618
final class BoughtTogetherProductsAssociationProvider implements BoughtTogetherProductsAssociationProviderInterface
1719
{
1820
/**
19-
* @param FactoryInterface<ProductAssociation> $productAssociationFactory
20-
* @param RepositoryInterface<ProductAssociationType> $productAssociationTypeRepository
21+
* @implements FactoryInterface<ProductAssociation> $productAssociationFactory
22+
* @implements RepositoryInterface<ProductAssociationType> $productAssociationTypeRepository
2123
*/
2224
public function __construct(
23-
private FactoryInterface $productAssociationFactory,
24-
private RepositoryInterface $productAssociationTypeRepository,
25+
private readonly FactoryInterface $productAssociationFactory,
26+
private readonly RepositoryInterface $productAssociationTypeRepository,
2527
) {
2628
}
2729

28-
public function getForProduct(ProductInterface $product): ProductAssociation
30+
public function getForProduct(ProductInterface $product): ProductAssociationInterface
2931
{
3032
Assert::isInstanceOf($product, BoughtTogetherProductsAwareInterface::class);
3133

@@ -36,6 +38,7 @@ public function getForProduct(ProductInterface $product): ProductAssociation
3638
return $productAssociation;
3739
}
3840

41+
/** @var ProductAssociationTypeInterface|null $productAssociationType */
3942
$productAssociationType = $this->productAssociationTypeRepository->findOneBy([
4043
'code' => BoughtTogetherProductsAwareInterface::BOUGHT_TOGETHER_ASSOCIATION_TYPE_CODE,
4144
]);
@@ -44,6 +47,7 @@ public function getForProduct(ProductInterface $product): ProductAssociation
4447
throw new BoughtTogetherAssociationTypeNotFoundException();
4548
}
4649

50+
/** @var ProductAssociationInterface $productAssociation */
4751
$productAssociation = $this->productAssociationFactory->createNew();
4852
$productAssociation->setType($productAssociationType);
4953
$product->addAssociation($productAssociation);

src/Provider/BoughtTogetherProductsAssociationProviderInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
namespace CommerceWeavers\SyliusAlsoBoughtPlugin\Provider;
66

77
use Sylius\Component\Core\Model\ProductInterface;
8-
use Sylius\Component\Product\Model\ProductAssociation;
8+
use Sylius\Component\Product\Model\ProductAssociationInterface;
99

1010
interface BoughtTogetherProductsAssociationProviderInterface
1111
{
12-
public function getForProduct(ProductInterface $product): ProductAssociation;
12+
public function getForProduct(ProductInterface $product): ProductAssociationInterface;
1313
}

src/Repository/ProductSynchronizationRepositoryInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use CommerceWeavers\SyliusAlsoBoughtPlugin\Entity\ProductSynchronizationInterface;
88
use Sylius\Component\Resource\Repository\RepositoryInterface;
99

10-
/** @extends RepositoryInterface<ProductSynchronizationInterface> */
1110
interface ProductSynchronizationRepositoryInterface extends RepositoryInterface
1211
{
1312
public function findLastSynchronization(): ?ProductSynchronizationInterface;

tests/Behat/Context/Ui/Admin/DashboardContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
final class DashboardContext implements Context
1212
{
13-
public function __construct (
13+
public function __construct(
1414
private readonly DashboardPageInterface $dashboardPage,
1515
) {
1616
}

tests/Behat/Context/Ui/Admin/ProductContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
final class ProductContext implements Context
1212
{
13-
public function __construct (
13+
public function __construct(
1414
private readonly BaseProductContext $productContext,
1515
) {
1616
}

tests/Behat/Element/Admin/ChannelFormElement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ final class ChannelFormElement extends Element implements ChannelFormElementInte
1010
{
1111
public function changeNumberOfSynchronisedProducts(int $number): void
1212
{
13-
$this->getElement('number_of_synchronised_products_input')->setValue($number);
13+
$this->getElement('number_of_synchronised_products_input')->setValue((string) $number);
1414
}
1515

1616
public function getNumberOfSynchronisedProducts(): int

tests/Unit/Synchronizer/FrequentlyBoughtTogetherProductsSynchronizerTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use CommerceWeavers\SyliusAlsoBoughtPlugin\Saver\BoughtTogetherProductsInfoSaverInterface;
1111
use CommerceWeavers\SyliusAlsoBoughtPlugin\Synchronizer\FrequentlyBoughtTogetherProductsSynchronizer;
1212
use PHPUnit\Framework\TestCase;
13+
use Prophecy\Argument;
1314
use Prophecy\PhpUnit\ProphecyTrait;
1415
use Sylius\Component\Core\Model\Order;
1516

@@ -53,9 +54,9 @@ public function testProductsSynchronization(): void
5354
$productsMapper->map($secondOrder)->willReturn(['P12182' => ['P10273'], 'P10273' => ['P12182']]);
5455
$productsMapper->map($thirdOrder)->willReturn(['P13757' => ['P10273']]);
5556

56-
$boughtTogetherProductsInfoSaver->save('P10273', ['P12182', 'P12183', 'P12182'])->shouldBeCalled();
57-
$boughtTogetherProductsInfoSaver->save('P12182', ['P10273', 'P12183', 'P10273'])->shouldBeCalled();
58-
$boughtTogetherProductsInfoSaver->save('P12183', ['P10273', 'P12182'])->shouldBeCalled();
57+
$boughtTogetherProductsInfoSaver->save('P10273', Argument::containing('P12182'))->shouldBeCalled();
58+
$boughtTogetherProductsInfoSaver->save('P12182', Argument::containing('P12183'))->shouldBeCalled();
59+
$boughtTogetherProductsInfoSaver->save('P12183', Argument::containing('P10273'))->shouldBeCalled();
5960
$boughtTogetherProductsInfoSaver->save('P13757', ['P10273'])->shouldBeCalled();
6061

6162
self::assertEquals(

0 commit comments

Comments
 (0)