Skip to content

Commit

Permalink
FRW-8773 Added PHPUnit 11 support. (#11131)
Browse files Browse the repository at this point in the history
FRW-8773 Added PHP Unit 11 support.
  • Loading branch information
olhalivitchuk authored Nov 4, 2024
1 parent 5a84872 commit 2ba3635
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
6 changes: 3 additions & 3 deletions tests/SprykerTest/Zed/Product/Business/ProductFacadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -731,13 +731,13 @@ public function triggerProductExportEventsTriggerFailsDataProvider(): array
{
return [
'store reference is null' => [
'export criteria' => (new ProductExportCriteriaTransfer())->setStoreReference(null),
'productExportCriteriaTransfer' => (new ProductExportCriteriaTransfer())->setStoreReference(null),
],
'store reference is empty' => [
'export criteria' => (new ProductExportCriteriaTransfer())->setStoreReference(''),
'productExportCriteriaTransfer' => (new ProductExportCriteriaTransfer())->setStoreReference(''),
],
'store with given reference doesn\'t exist' => [
'export criteria' => (new ProductExportCriteriaTransfer())
'productExportCriteriaTransfer' => (new ProductExportCriteriaTransfer())
->setStoreReference(static::UNEXISTING_STORE_REFERENCE),
],
];
Expand Down
49 changes: 34 additions & 15 deletions tests/SprykerTest/Zed/Product/Business/ProductUrlGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,25 @@ protected function setUp(): void
$this->productAbstractNameGenerator = $this->getMockBuilder(ProductAbstractNameGeneratorInterface::class)
->disableOriginalConstructor()->getMock();

$invocationIndex = 0;
$expectedCalls = [
[$this->productAbstractTransfer, $this->locales['de_DE']],
[$this->productAbstractTransfer, $this->locales['en_US']],
];
$returnValues = [
static::PRODUCT_NAME['de_DE'],
static::PRODUCT_NAME['en_US'],
];

$this->productAbstractNameGenerator
->expects($this->exactly(2))
->method('getLocalizedProductAbstractName')
->withConsecutive(
[
$this->productAbstractTransfer,
$this->locales['de_DE'],
],
[
$this->productAbstractTransfer,
$this->locales['en_US'],
],
)
->willReturn(static::PRODUCT_NAME['de_DE'], static::PRODUCT_NAME['en_US']);
->willReturnCallback(function ($productAbstractTransfer, $locale) use (&$invocationIndex, $expectedCalls, $returnValues) {
$this->assertSame($expectedCalls[$invocationIndex][0], $productAbstractTransfer);
$this->assertSame($expectedCalls[$invocationIndex][1], $locale);

return $returnValues[$invocationIndex++];
});
}

/**
Expand Down Expand Up @@ -182,11 +187,18 @@ public function testGetProductUrlShouldReturnTransfer(): void
new ArrayObject([$expectedDEUrl, $expectedENUrl]),
);

$invocationIndex = 0;
$expectedValues = [static::PRODUCT_NAME['de_DE'], static::PRODUCT_NAME['en_US']];
$returnValues = ['product-name-dede', 'product-name-enus'];

$this->utilTextService
->expects($this->exactly(2))
->method('generateSlug')
->withConsecutive([static::PRODUCT_NAME['de_DE']], [static::PRODUCT_NAME['en_US']])
->willReturnOnConsecutiveCalls('product-name-dede', 'product-name-enus');
->willReturnCallback(function ($value) use (&$invocationIndex, $expectedValues, $returnValues) {
$this->assertSame($expectedValues[$invocationIndex], $value);

return $returnValues[$invocationIndex++];
});

$configMock = $this->createMock(ProductConfig::class);
$configMock->method('isFullLocaleNamesInUrlEnabled')->willReturn(true);
Expand Down Expand Up @@ -219,11 +231,18 @@ public function testGetProductUrlShouldReturnTransferBCCheck(): void
new ArrayObject([$expectedDEUrl, $expectedENUrl]),
);

$expectedCalls = [static::PRODUCT_NAME['de_DE'], static::PRODUCT_NAME['en_US']];
$returnValues = ['product-name-dede', 'product-name-enus'];
$callIndex = 0;

$this->utilTextService
->expects($this->exactly(2))
->method('generateSlug')
->withConsecutive([static::PRODUCT_NAME['de_DE']], [static::PRODUCT_NAME['en_US']])
->willReturnOnConsecutiveCalls('product-name-dede', 'product-name-enus');
->willReturnCallback(function ($value) use (&$callIndex, $expectedCalls, $returnValues) {
$this->assertSame($expectedCalls[$callIndex], $value);

return $returnValues[$callIndex++];
});

$configMock = $this->createMock(ProductConfig::class);
$configMock->method('isFullLocaleNamesInUrlEnabled')->willReturn(false);
Expand Down

0 comments on commit 2ba3635

Please sign in to comment.