Skip to content

Commit 540be8c

Browse files
committed
MC-38546: Warnings in Unit tests build log
1 parent 00a70ec commit 540be8c

File tree

1 file changed

+20
-3
lines changed
  • app/code/Magento/Catalog/Test/Unit/Model/Product/Type

1 file changed

+20
-3
lines changed

app/code/Magento/Catalog/Test/Unit/Model/Product/Type/PriceTest.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Magento\Store\Model\StoreManagerInterface;
2222
use Magento\Store\Model\Website;
2323
use PHPUnit\Framework\MockObject\MockObject;
24+
use PHPUnit\Framework\MockObject\RuntimeException;
2425
use PHPUnit\Framework\TestCase;
2526

2627
/**
@@ -289,14 +290,30 @@ function () {
289290
return $this->objectManagerHelper->getObject(TierPrice::class);
290291
}
291292
);
292-
$tierPriceExtensionMock = $this->getMockBuilder(ProductTierPriceExtensionInterface::class)
293-
->onlyMethods(['getPercentageValue', 'setPercentageValue'])
294-
->getMockForAbstractClass();
293+
$tierPriceExtensionMock = $this->getProductTierPriceExtensionInterfaceMock();
295294
$tierPriceExtensionMock->method('getPercentageValue')
296295
->willReturn(50);
297296
$this->tierPriceExtensionFactoryMock->method('create')
298297
->willReturn($tierPriceExtensionMock);
299298

300299
$this->assertInstanceOf(TierPrice::class, $this->model->getTierPrices($this->product)[0]);
301300
}
301+
302+
/**
303+
* Build ProductTierPriceExtensionInterface mock.
304+
*
305+
* @return MockObject
306+
*/
307+
private function getProductTierPriceExtensionInterfaceMock(): MockObject
308+
{
309+
$mockBuilder = $this->getMockBuilder(ProductTierPriceExtensionInterface::class)
310+
->disableOriginalConstructor();
311+
try {
312+
$mockBuilder->addMethods(['getPercentageValue', 'setPercentageValue', 'setWebsiteId']);
313+
} catch (RuntimeException $e) {
314+
// ProductTierPriceExtensionInterface already generated and has all necessary methods.
315+
}
316+
317+
return $mockBuilder->getMock();
318+
}
302319
}

0 commit comments

Comments
 (0)