Skip to content

Commit

Permalink
Merge pull request #8896 from magento-gl/phpunit10
Browse files Browse the repository at this point in the history
[Arrows] Delivery of PHPUnit 10 Upgrade
  • Loading branch information
sidolov authored Jun 7, 2024
2 parents 001e518 + e555b13 commit e81f28e
Show file tree
Hide file tree
Showing 1,899 changed files with 14,014 additions and 9,250 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,17 @@ protected function setUp(): void

$this->backendAuthSessionMock = $this->getMockBuilder(Session::class)
->disableOriginalConstructor()
->setMethods(['isLoggedIn'])
->onlyMethods(['isLoggedIn'])
->getMock();

$this->feedMock = $this->getMockBuilder(Feed::class)
->disableOriginalConstructor()
->setMethods(['checkUpdate'])
->onlyMethods(['checkUpdate'])
->getMock();

$this->feedFactoryMock = $this->getMockBuilder(FeedFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->onlyMethods(['create'])
->getMock();

$this->observer = $this->objectManager->getObject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function setUp(): void
{
$this->groupRepository = $this->getMockBuilder(GroupRepositoryInterface::class)
->disableOriginalConstructor()
->setMethods(['getList'])
->onlyMethods(['getList'])
->getMockForAbstractClass();

$this->searchCriteriaBuilder = $this->createMock(SearchCriteriaBuilder::class);
Expand All @@ -65,7 +65,7 @@ protected function setUp(): void
$this->tierPrice = $this->getMockBuilder(
TierPrice::class
)
->setMethods(['isValidValueAndLength', 'hasEmptyColumns', '_addMessages'])
->onlyMethods(['isValidValueAndLength', 'hasEmptyColumns', '_addMessages'])
->setConstructorArgs([$this->groupRepository, $this->searchCriteriaBuilder, $this->storeResolver])
->getMock();
}
Expand All @@ -87,7 +87,7 @@ public function testInitInternalCalls()

$groupTest = $this->getMockBuilder(GroupInterface::class)
->disableOriginalConstructor()
->setMethods(['getCode', 'getId'])
->onlyMethods(['getCode', 'getId'])
->getMockForAbstractClass();
$groupTest->expects($this->once())->method('getCode');
$groupTest->method('getId');
Expand All @@ -114,7 +114,7 @@ public function testInitAddToCustomerGroups()

$groupTest = $this->getMockBuilder(GroupInterface::class)
->disableOriginalConstructor()
->setMethods(['getCode', 'getId'])
->onlyMethods(['getCode', 'getId'])
->getMockForAbstractClass();

$expectedCode = 'code';
Expand Down Expand Up @@ -184,7 +184,7 @@ public function testIsValidAddMessagesCall($value, $hasEmptyColumns, $customerGr

$groupTest = $this->getMockBuilder(GroupInterface::class)
->disableOriginalConstructor()
->setMethods(['getCode', 'getId'])
->onlyMethods(['getCode', 'getId'])
->getMockForAbstractClass();
$groupTest->expects($this->once())->method('getCode');
$groupTest->method('getId');
Expand All @@ -198,7 +198,7 @@ public function testIsValidAddMessagesCall($value, $hasEmptyColumns, $customerGr
/**
* @return array
*/
public function isValidResultFalseDataProvider()
public static function isValidResultFalseDataProvider()
{
return [
// First if condition cases.
Expand Down Expand Up @@ -306,7 +306,7 @@ public function isValidResultFalseDataProvider()
/**
* @return array
*/
public function isValidAddMessagesCallDataProvider()
public static function isValidAddMessagesCallDataProvider()
{
return [
// First if condition cases.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testIsValid(array $value, $expectedResult)
*
* @return array
*/
public function isValidDataProvider()
public static function isValidDataProvider()
{
return [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class WebsiteTest extends TestCase
protected function setUp(): void
{
$this->webSiteModel = $this->getMockBuilder(Website::class)
->setMethods(['getBaseCurrency'])
->onlyMethods(['getBaseCurrency'])
->disableOriginalConstructor()
->getMock();
$this->storeResolver = $this->createPartialMock(
Expand All @@ -56,7 +56,7 @@ protected function setUp(): void
$this->website = $this->getMockBuilder(
WebsiteValidator::class
)
->setMethods(['getAllWebsitesValue', '_clearMessages', '_addMessages'])
->onlyMethods(['getAllWebsitesValue', '_clearMessages', '_addMessages'])
->setConstructorArgs([$this->storeResolver, $this->webSiteModel, $this->currencyResolver])
->getMock();
}
Expand Down Expand Up @@ -121,7 +121,7 @@ public function testGetAllWebsitesValue()
$websiteString = $this->getMockBuilder(
WebsiteValidator::class
)
->setMethods(['_clearMessages', '_addMessages'])
->onlyMethods(['_clearMessages', '_addMessages'])
->setConstructorArgs([$this->storeResolver, $this->webSiteModel, $this->currencyResolver])
->getMock();
$result = $websiteString->getAllWebsitesValue();
Expand All @@ -132,7 +132,7 @@ public function testGetAllWebsitesValue()
/**
* @return array
*/
public function isValidReturnDataProvider()
public static function isValidReturnDataProvider()
{
return [
// False cases.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function setUp(): void
$this->validator = $this->getMockBuilder(
\Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator::class
)
->setMethods(['_clearMessages', '_addMessages'])
->onlyMethods(['_clearMessages', '_addMessages'])
->setConstructorArgs([$this->validators])
->getMock();
}
Expand Down Expand Up @@ -84,7 +84,7 @@ public function testInit()
/**
* @return array
*/
public function isValidDataProvider()
public static function isValidDataProvider()
{
return [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Magento\AdvancedPricingImportExport\Test\Unit\Model\Import;

use Magento\AdvancedPricingImportExport\Model\CurrencyResolver;
use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing as AdvancedPricing;
use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator;
use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\TierPrice;
Expand Down Expand Up @@ -137,6 +138,11 @@ class AdvancedPricingTest extends AbstractImportTestCase
*/
protected $errorAggregator;

/**
* @var MockObject|CurrencyResolver
*/
private $currencyResolver;

/**
* @inheritDoc
*/
Expand Down Expand Up @@ -537,23 +543,23 @@ public function testSaveAndReplaceAdvancedPricesReplaceBehaviourInternalCalls():

$this->advancedPricing
->method('deleteProductTierPrices')
->withConsecutive(
[
$listSku,
AdvancedPricing::TABLE_TIER_PRICE
]
)
->willReturn(true);
->willReturnCallback(
function ($arg1, $arg2) use ($listSku) {
if ($arg1 == $listSku && $arg2 == AdvancedPricing::TABLE_TIER_PRICE) {
return true;
}
}
);

$this->advancedPricing
->method('saveProductPrices')
->withConsecutive(
[
$expectedTierPrices,
AdvancedPricing::TABLE_TIER_PRICE
]
)
->willReturnSelf();
->willReturnCallback(
function ($arg1, $arg2) use ($expectedTierPrices) {
if ($arg1 == $expectedTierPrices && $arg2 == AdvancedPricing::TABLE_TIER_PRICE) {
return $this->advancedPricing;
}
}
);

$this->invokeMethod($this->advancedPricing, 'saveAndReplaceAdvancedPrices');
}
Expand Down Expand Up @@ -584,9 +590,13 @@ public function testDeleteAdvancedPricingFormListSkuToDelete(): void
$this->advancedPricing
->expects($this->once())
->method('deleteProductTierPrices')
->withConsecutive(
[$expectedSkuList, AdvancedPricing::TABLE_TIER_PRICE]
)->willReturnSelf();
->willReturnCallback(
function ($arg1, $arg2) use ($expectedSkuList) {
if ($arg1 == $expectedSkuList && $arg2 == AdvancedPricing::TABLE_TIER_PRICE) {
return $this->advancedPricing;
}
}
);

$this->advancedPricing->deleteAdvancedPricing();
}
Expand Down Expand Up @@ -630,7 +640,7 @@ public function testReplaceAdvancedPricing(): void
*
* @return array
*/
public function saveAndReplaceAdvancedPricesAppendBehaviourDataProvider(): array
public static function saveAndReplaceAdvancedPricesAppendBehaviourDataProvider(): array
{
// @codingStandardsIgnoreStart
return [
Expand Down Expand Up @@ -759,7 +769,7 @@ public function saveAndReplaceAdvancedPricesAppendBehaviourDataProvider(): array
*
* @return array
*/
public function validateRowResultDataProvider(): array
public static function validateRowResultDataProvider(): array
{
return [
[
Expand Down Expand Up @@ -791,7 +801,7 @@ public function validateRowResultDataProvider(): array
*
* @return array
*/
public function validateRowAddRowErrorCallDataProvider(): array
public static function validateRowAddRowErrorCallDataProvider(): array
{
return [
[
Expand Down Expand Up @@ -836,7 +846,7 @@ public function testSaveProductPrices(array $priceData, array $oldSkus, array $p
/**
* @return array
*/
public function saveProductPricesDataProvider(): array
public static function saveProductPricesDataProvider(): array
{
return [
[[], ['oSku1' => 'product1', 'oSku2' => 'product2'], [], 0],
Expand Down Expand Up @@ -912,7 +922,7 @@ public function testDeleteProductTierPrices(
/**
* @return array
*/
public function deleteProductTierPricesDataProvider(): array
public static function deleteProductTierPricesDataProvider(): array
{
return [
[
Expand Down Expand Up @@ -991,15 +1001,19 @@ public function testProcessCountExistingPrices(
->willReturn($oldSkus);
$this->advancedPricing->expects($this->exactly($numCall))
->method('incrementCounterUpdated')
->withConsecutive($args);
->willReturnCallback(function ($args) {
if (!empty($args)) {
return null;
}
});

$this->invokeMethod($this->advancedPricing, 'processCountExistingPrices', [$prices, 'table']);
}

/**
* @return array
*/
public function processCountExistingPricesDataProvider(): array
public static function processCountExistingPricesDataProvider(): array
{
return [
[
Expand Down Expand Up @@ -1095,10 +1109,11 @@ private function getAdvancedPricingMock(array $methods = []): MockObject
->method('getMetaData')
->with(ProductInterface::class)
->willReturn($metadataMock);
$this->currencyResolver = $this->createMock(CurrencyResolver::class);
$advancedPricingMock = $this->getMockBuilder(
\Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing::class
)
->setMethods($methods)
->onlyMethods($methods)
->setConstructorArgs(
[
$this->jsonHelper,
Expand All @@ -1115,7 +1130,8 @@ private function getAdvancedPricingMock(array $methods = []): MockObject
$this->importProduct,
$this->validator,
$this->websiteValidator,
$this->tierPriceValidator
$this->tierPriceValidator,
$this->currencyResolver
]
)
->getMock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ protected function setUp(): void
{
$this->dataProvider = $this->getMockBuilder(SuggestedQueriesInterface::class)
->disableOriginalConstructor()
->setMethods(['getItems', 'isResultsCountEnabled'])
->onlyMethods(['getItems', 'isResultsCountEnabled'])
->getMockForAbstractClass();

$this->searchQueryMock = $this->getMockBuilder(QueryInterface::class)
->disableOriginalConstructor()
->setMethods(['getQueryText'])
->onlyMethods(['getQueryText'])
->getMockForAbstractClass();
$this->queryFactoryMock = $this->getMockBuilder(QueryFactoryInterface::class)
->disableOriginalConstructor()
->setMethods(['get'])
->onlyMethods(['get'])
->getMockForAbstractClass();
$this->queryFactoryMock->expects($this->once())
->method('get')
Expand All @@ -78,7 +78,7 @@ protected function setUp(): void
[],
]
)
->setMethods(['getUrl'])
->onlyMethods(['getUrl'])
->getMockForAbstractClass();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function setUp(): void
$responseMock = $this->createMock(HttpResponse::class);

$context = $this->getMockBuilder(Context::class)
->setMethods(['getRequest', 'getResponse', 'getMessageManager', 'getSession'])
->onlyMethods(['getRequest', 'getResponse', 'getMessageManager', 'getSession'])
->setConstructorArgs(
$helper->getConstructArguments(
Context::class,
Expand All @@ -90,7 +90,7 @@ protected function setUp(): void

$this->clientResolverMock = $this->getMockBuilder(ClientResolver::class)
->disableOriginalConstructor()
->setMethods(['create'])
->onlyMethods(['create'])
->getMock();

$this->clientMock = $this->getMockForAbstractClass(ClientInterface::class);
Expand All @@ -101,12 +101,12 @@ protected function setUp(): void

$this->resultJsonFactoryMock = $this->getMockBuilder(JsonFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->onlyMethods(['create'])
->getMock();

$this->tagFilterMock = $this->getMockBuilder(StripTags::class)
->disableOriginalConstructor()
->setMethods(['filter'])
->onlyMethods(['filter'])
->getMock();

$this->controller = new TestConnection(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected function setUp(): void
$this->scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
$this->layerResolverMock = $this->getMockBuilder(Resolver::class)
->disableOriginalConstructor()
->setMethods(['get'])
->onlyMethods(['get'])
->getMock();

$this->searchLayerMock = $this->createMock(SearchLayer::class);
Expand All @@ -91,14 +91,14 @@ protected function setUp(): void

$this->recommendationsFactoryMock = $this->getMockBuilder(RecommendationsFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->onlyMethods(['create'])
->getMock();

$this->recommendationsMock = $this->createMock(Recommendations::class);

$this->queryResultFactoryMock = $this->getMockBuilder(QueryResultFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->onlyMethods(['create'])
->getMock();

$this->objectManagerHelper = new ObjectManagerHelper($this);
Expand Down
Loading

0 comments on commit e81f28e

Please sign in to comment.