From eff9aba9aa2cda2d6568fb294cf260e47e5ae55b Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 15 May 2026 18:31:52 +0000 Subject: [PATCH 1/6] DMT 2.4.9 Release: Add Magento 2.4.9 compatibility Bump version to 2.4.9 and add changelog entry for Magento Open Source and Adobe Commerce 2.4.9 support. https://claude.ai/code/session_015Y1Wix1FL2gJX27KoQ8N9J --- CHANGELOG.md | 7 +++++++ composer.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53efdbdc..adda998e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +2.4.9 +============= +* Added support for versions: + + * Magento Open Source: 2.4.9 + * Adobe Commerce: 2.4.9 + 2.4.8 ============= * Added support for versions: diff --git a/composer.json b/composer.json index cbad8df9..d7f5ed64 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "magento/data-migration-tool", "description": "Migration Tool", - "version": "2.4.8.1", + "version": "2.4.9", "require": { "symfony/console": "^6.4", "magento/framework": "*", From 84dfa4df3f1a43e11c475b6cf295870d272f59d2 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 15 May 2026 18:43:07 +0000 Subject: [PATCH 2/6] DMT 2.4.9 Release: Add Magento 2.4.9 compatibility - Bump version to 2.4.9 - Add PHP ~8.3.0||~8.4.0||~8.5.0 constraint - Update symfony/console from ^6.4 to ^7.4 - Update phpunit from ~9.5.0 to ^12.0 - Fix PHP 8.4 implicit nullable params: ?Document, ?\Zend_Db_Expr - Add Symfony 7 return types to console command methods - Update PHPUnit XML schemas to v12.0 https://claude.ai/code/session_015Y1Wix1FL2gJX27KoQ8N9J --- composer.json | 5 +++-- .../Console/AbstractMigrateCommand.php | 4 ++-- src/Migration/Console/MigrateDataCommand.php | 4 ++-- src/Migration/Console/MigrateDeltaCommand.php | 4 ++-- .../Console/MigrateSettingsCommand.php | 2 +- src/Migration/ResourceModel/Adapter/Mysql.php | 2 +- .../ResourceModel/AdapterInterface.php | 2 +- src/Migration/ResourceModel/Record.php | 2 +- src/Migration/ResourceModel/Source.php | 2 +- tests/integration/phpunit.xml.dist | 14 ++++++------- tests/unit/phpunit.xml.dist | 20 ++++++------------- 11 files changed, 26 insertions(+), 35 deletions(-) diff --git a/composer.json b/composer.json index d7f5ed64..ff1f6c45 100644 --- a/composer.json +++ b/composer.json @@ -3,12 +3,13 @@ "description": "Migration Tool", "version": "2.4.9", "require": { - "symfony/console": "^6.4", + "php": "~8.3.0||~8.4.0||~8.5.0", + "symfony/console": "^7.4", "magento/framework": "*", "monolog/monolog": "^3.6" }, "require-dev": { - "phpunit/phpunit": "~9.5.0" + "phpunit/phpunit": "^12.0" }, "autoload": { "psr-4": {"Migration\\": "src/Migration"}, diff --git a/src/Migration/Console/AbstractMigrateCommand.php b/src/Migration/Console/AbstractMigrateCommand.php index 2059c6a1..03c562bf 100644 --- a/src/Migration/Console/AbstractMigrateCommand.php +++ b/src/Migration/Console/AbstractMigrateCommand.php @@ -78,7 +78,7 @@ public function __construct( * * @return void */ - protected function configure() + protected function configure(): void { $this->setDefinition([ new InputArgument( @@ -110,7 +110,7 @@ protected function configure() * @throws Exception * @return void */ - protected function initialize(InputInterface $input, OutputInterface $output) + protected function initialize(InputInterface $input, OutputInterface $output): void { $config = $input->getArgument(self::INPUT_KEY_CONFIG); diff --git a/src/Migration/Console/MigrateDataCommand.php b/src/Migration/Console/MigrateDataCommand.php index 03519389..1dd575bb 100644 --- a/src/Migration/Console/MigrateDataCommand.php +++ b/src/Migration/Console/MigrateDataCommand.php @@ -45,7 +45,7 @@ public function __construct( * * @return void */ - protected function configure() + protected function configure(): void { $this->setName($this->name) ->setDescription('Main migration of data'); @@ -55,7 +55,7 @@ protected function configure() /** * @inheritdoc */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $this->dataMode->run(); return Command::SUCCESS; diff --git a/src/Migration/Console/MigrateDeltaCommand.php b/src/Migration/Console/MigrateDeltaCommand.php index 419e3884..ff303e1f 100644 --- a/src/Migration/Console/MigrateDeltaCommand.php +++ b/src/Migration/Console/MigrateDeltaCommand.php @@ -45,7 +45,7 @@ public function __construct( * * @return void */ - protected function configure() + protected function configure(): void { $this->setName($this->name) ->setDescription('Migrate the data is added into Magento after the main migration'); @@ -55,7 +55,7 @@ protected function configure() /** * @inheritdoc */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $this->deltaMode->run(); return Command::SUCCESS; diff --git a/src/Migration/Console/MigrateSettingsCommand.php b/src/Migration/Console/MigrateSettingsCommand.php index 77afff73..b271d253 100644 --- a/src/Migration/Console/MigrateSettingsCommand.php +++ b/src/Migration/Console/MigrateSettingsCommand.php @@ -45,7 +45,7 @@ public function __construct( * * @return void */ - protected function configure() + protected function configure(): void { $this->setName($this->name) ->setDescription('Migrate system configuration'); diff --git a/src/Migration/ResourceModel/Adapter/Mysql.php b/src/Migration/ResourceModel/Adapter/Mysql.php index b7922e88..adba893a 100644 --- a/src/Migration/ResourceModel/Adapter/Mysql.php +++ b/src/Migration/ResourceModel/Adapter/Mysql.php @@ -112,7 +112,7 @@ public function loadPage( $pageSize, $identityField = null, $identityId = null, - \Zend_Db_Expr $condition = null + ?\Zend_Db_Expr $condition = null ) { $select = $this->getSelect(); $select->from($documentName, '*'); diff --git a/src/Migration/ResourceModel/AdapterInterface.php b/src/Migration/ResourceModel/AdapterInterface.php index 0be207b1..f129fdd8 100644 --- a/src/Migration/ResourceModel/AdapterInterface.php +++ b/src/Migration/ResourceModel/AdapterInterface.php @@ -57,7 +57,7 @@ public function loadPage( $pageSize, $identityField = null, $identityId = null, - \Zend_Db_Expr $condition = null + ?\Zend_Db_Expr $condition = null ); /** diff --git a/src/Migration/ResourceModel/Record.php b/src/Migration/ResourceModel/Record.php index 796e7877..7169c139 100644 --- a/src/Migration/ResourceModel/Record.php +++ b/src/Migration/ResourceModel/Record.php @@ -31,7 +31,7 @@ class Record * @param array $data * @param Document $document */ - public function __construct(array $data = [], Document $document = null) + public function __construct(array $data = [], ?Document $document = null) { $this->data = $data; if ($document !== null) { diff --git a/src/Migration/ResourceModel/Source.php b/src/Migration/ResourceModel/Source.php index a50edbfe..f5cfc7ca 100644 --- a/src/Migration/ResourceModel/Source.php +++ b/src/Migration/ResourceModel/Source.php @@ -62,7 +62,7 @@ public function loadPage($documentName, $pageNumber) * @param \Zend_Db_Expr $condition * @return array */ - public function getRecords($documentName, $pageNumber, $pageSize = null, \Zend_Db_Expr $condition = null) + public function getRecords($documentName, $pageNumber, $pageSize = null, ?\Zend_Db_Expr $condition = null) { $pageSize = $pageSize ?: $this->getPageSize($documentName) ; $identityField = $this->getIdentityField($documentName); diff --git a/tests/integration/phpunit.xml.dist b/tests/integration/phpunit.xml.dist index c5569037..06ba1730 100644 --- a/tests/integration/phpunit.xml.dist +++ b/tests/integration/phpunit.xml.dist @@ -6,15 +6,13 @@ */ --> - - testsuite - - - - - + + + testsuite + + diff --git a/tests/unit/phpunit.xml.dist b/tests/unit/phpunit.xml.dist index 44940677..8713203d 100644 --- a/tests/unit/phpunit.xml.dist +++ b/tests/unit/phpunit.xml.dist @@ -6,21 +6,13 @@ */ --> - - testsuite - - + + + testsuite + + From 57e87582b12edef3fe9e716ddbff78f4aab195bf Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 15 May 2026 18:47:09 +0000 Subject: [PATCH 3/6] Fix remaining PHP 8.4 implicit nullable params - ConsoleOutputFactory: ?OutputFormatterInterface $formatter = null - Customer/Data: array $attributesToSkip = [] (was = null); update dead null-check to !empty() https://claude.ai/code/session_015Y1Wix1FL2gJX27KoQ8N9J --- src/Migration/App/ConsoleOutputFactory.php | 2 +- src/Migration/Step/Customer/Data.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Migration/App/ConsoleOutputFactory.php b/src/Migration/App/ConsoleOutputFactory.php index feb6ae78..b68db69a 100644 --- a/src/Migration/App/ConsoleOutputFactory.php +++ b/src/Migration/App/ConsoleOutputFactory.php @@ -24,7 +24,7 @@ class ConsoleOutputFactory public function create( $verbosity = ConsoleOutput::VERBOSITY_NORMAL, $decorated = null, - OutputFormatterInterface $formatter = null + ?OutputFormatterInterface $formatter = null ) { return new ConsoleOutput($verbosity, $decorated, $formatter); } diff --git a/src/Migration/Step/Customer/Data.php b/src/Migration/Step/Customer/Data.php index 7036a58f..92912827 100644 --- a/src/Migration/Step/Customer/Data.php +++ b/src/Migration/Step/Customer/Data.php @@ -174,7 +174,7 @@ public function perform() */ private function transformDocumentRecords( $sourceDocName, - array $attributesToSkip = null + array $attributesToSkip = [] ) { $sourceEntityDocuments = array_keys($this->readerGroups->getGroup('source_entity_documents')); $sourceDocument = $this->source->getDocument($sourceDocName); @@ -244,7 +244,7 @@ private function skipRecordAttribute($recordData, $attributesToSkip) return false; }; - if ($attributesToSkip !== null + if (!empty($attributesToSkip) && isset($recordData['attribute_id']) && isset($attributesToSkip[$recordData['attribute_id']]) && !$passwordHashSha512($recordData, $attributesToSkip) From cd7e24c13897ae4a2a76f3b67950a8f390b84150 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 16 May 2026 10:03:35 +0000 Subject: [PATCH 4/6] Add : void return types to setUp/tearDown in unit tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PHPUnit 10+ requires explicit void return type on setUp() and tearDown() — fixes 24 test files. https://claude.ai/code/session_015Y1Wix1FL2gJX27KoQ8N9J --- tests/unit/testsuite/Migration/ConfigTest.php | 2 +- tests/unit/testsuite/Migration/Handler/ManagerTest.php | 2 +- tests/unit/testsuite/Migration/Handler/Settings/EncryptTest.php | 2 +- tests/unit/testsuite/Migration/Logger/ConsoleHandlerTest.php | 2 +- tests/unit/testsuite/Migration/Logger/FileHandlerTest.php | 2 +- tests/unit/testsuite/Migration/Logger/LoggerTest.php | 2 +- tests/unit/testsuite/Migration/Logger/ManagerTest.php | 2 +- .../Migration/Model/Eav/AttributeGroupNameToCodeMapTest.php | 2 +- tests/unit/testsuite/Migration/RecordTransformerTest.php | 2 +- .../Migration/ResourceModel/AbstractCollectionTest.php | 2 +- .../testsuite/Migration/ResourceModel/AbstractResourceTest.php | 2 +- .../testsuite/Migration/ResourceModel/Adapter/MysqlTest.php | 2 +- .../Migration/ResourceModel/Adapter/Pdo/MysqlBuilderTest.php | 2 +- .../testsuite/Migration/ResourceModel/AdapterFactoryTest.php | 2 +- .../unit/testsuite/Migration/ResourceModel/DestinationTest.php | 2 +- .../Migration/ResourceModel/Document/CollectionTest.php | 2 +- tests/unit/testsuite/Migration/ResourceModel/DocumentTest.php | 2 +- .../testsuite/Migration/ResourceModel/Record/CollectionTest.php | 2 +- tests/unit/testsuite/Migration/ResourceModel/RecordTest.php | 2 +- tests/unit/testsuite/Migration/ResourceModel/SourceTest.php | 2 +- .../Migration/ResourceModel/Structure/CollectionTest.php | 2 +- tests/unit/testsuite/Migration/ResourceModel/StructureTest.php | 2 +- .../Migration/Step/Eav/Integrity/AttributeFrontendInputTest.php | 2 +- .../Migration/Step/Eav/Integrity/AttributeGroupNamesTest.php | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/unit/testsuite/Migration/ConfigTest.php b/tests/unit/testsuite/Migration/ConfigTest.php index 99eb8228..789872bc 100644 --- a/tests/unit/testsuite/Migration/ConfigTest.php +++ b/tests/unit/testsuite/Migration/ConfigTest.php @@ -19,7 +19,7 @@ class ConfigTest extends \PHPUnit\Framework\TestCase * @throws Exception * @return void */ - protected function setUp() + protected function setUp(): void { $validationState = $this->getMockBuilder(\Magento\Framework\App\Arguments\ValidationState::class) ->disableOriginalConstructor() diff --git a/tests/unit/testsuite/Migration/Handler/ManagerTest.php b/tests/unit/testsuite/Migration/Handler/ManagerTest.php index bf3b75c3..dfaebd96 100644 --- a/tests/unit/testsuite/Migration/Handler/ManagerTest.php +++ b/tests/unit/testsuite/Migration/Handler/ManagerTest.php @@ -20,7 +20,7 @@ class ManagerTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $this->objectManager = $this->createPartialMock( \Magento\Framework\ObjectManager\ObjectManager::class, diff --git a/tests/unit/testsuite/Migration/Handler/Settings/EncryptTest.php b/tests/unit/testsuite/Migration/Handler/Settings/EncryptTest.php index 9836e202..e9164c29 100644 --- a/tests/unit/testsuite/Migration/Handler/Settings/EncryptTest.php +++ b/tests/unit/testsuite/Migration/Handler/Settings/EncryptTest.php @@ -33,7 +33,7 @@ class EncryptTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $this->encryptor = $this->createPartialMock( \Magento\Framework\Encryption\Encryptor::class, diff --git a/tests/unit/testsuite/Migration/Logger/ConsoleHandlerTest.php b/tests/unit/testsuite/Migration/Logger/ConsoleHandlerTest.php index f9db721e..e48563e0 100644 --- a/tests/unit/testsuite/Migration/Logger/ConsoleHandlerTest.php +++ b/tests/unit/testsuite/Migration/Logger/ConsoleHandlerTest.php @@ -15,7 +15,7 @@ class ConsoleHandlerTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $this->consoleHandler = new ConsoleHandler(); } diff --git a/tests/unit/testsuite/Migration/Logger/FileHandlerTest.php b/tests/unit/testsuite/Migration/Logger/FileHandlerTest.php index 01830343..3937771d 100644 --- a/tests/unit/testsuite/Migration/Logger/FileHandlerTest.php +++ b/tests/unit/testsuite/Migration/Logger/FileHandlerTest.php @@ -48,7 +48,7 @@ class FileHandlerTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $this->file = $this->getMockBuilder(\Magento\Framework\Filesystem\Driver\File::class) ->disableOriginalConstructor() diff --git a/tests/unit/testsuite/Migration/Logger/LoggerTest.php b/tests/unit/testsuite/Migration/Logger/LoggerTest.php index 795eefda..2a104df5 100644 --- a/tests/unit/testsuite/Migration/Logger/LoggerTest.php +++ b/tests/unit/testsuite/Migration/Logger/LoggerTest.php @@ -13,7 +13,7 @@ class LoggerTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $this->logger = new Logger(); } diff --git a/tests/unit/testsuite/Migration/Logger/ManagerTest.php b/tests/unit/testsuite/Migration/Logger/ManagerTest.php index 8d89f324..1f863fa7 100644 --- a/tests/unit/testsuite/Migration/Logger/ManagerTest.php +++ b/tests/unit/testsuite/Migration/Logger/ManagerTest.php @@ -40,7 +40,7 @@ class ManagerTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $this->logger = $this->createPartialMock( \Migration\Logger\Logger::class, diff --git a/tests/unit/testsuite/Migration/Model/Eav/AttributeGroupNameToCodeMapTest.php b/tests/unit/testsuite/Migration/Model/Eav/AttributeGroupNameToCodeMapTest.php index 246a9072..eb64d1e0 100644 --- a/tests/unit/testsuite/Migration/Model/Eav/AttributeGroupNameToCodeMapTest.php +++ b/tests/unit/testsuite/Migration/Model/Eav/AttributeGroupNameToCodeMapTest.php @@ -25,7 +25,7 @@ class AttributeGroupNameToCodeMapTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $this->translitFilter = $this->getMockBuilder(\Magento\Framework\Filter\Translit::class) ->disableOriginalConstructor() diff --git a/tests/unit/testsuite/Migration/RecordTransformerTest.php b/tests/unit/testsuite/Migration/RecordTransformerTest.php index 581c1afc..94f7dd85 100644 --- a/tests/unit/testsuite/Migration/RecordTransformerTest.php +++ b/tests/unit/testsuite/Migration/RecordTransformerTest.php @@ -40,7 +40,7 @@ class RecordTransformerTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $this->sourceDocument = $this->createPartialMock( \Migration\ResourceModel\Document::class, diff --git a/tests/unit/testsuite/Migration/ResourceModel/AbstractCollectionTest.php b/tests/unit/testsuite/Migration/ResourceModel/AbstractCollectionTest.php index 0c443a0b..ca811181 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/AbstractCollectionTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/AbstractCollectionTest.php @@ -20,7 +20,7 @@ class AbstractCollectionTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $document1 = $this->createMock(\Migration\ResourceModel\Document::class); $document1->expects($this->any())->method('getName')->will($this->returnValue('Doc1')); diff --git a/tests/unit/testsuite/Migration/ResourceModel/AbstractResourceTest.php b/tests/unit/testsuite/Migration/ResourceModel/AbstractResourceTest.php index f05cec26..8dbf2403 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/AbstractResourceTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/AbstractResourceTest.php @@ -60,7 +60,7 @@ class AbstractResourceTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $this->config = $this->createPartialMock( \Migration\Config::class, diff --git a/tests/unit/testsuite/Migration/ResourceModel/Adapter/MysqlTest.php b/tests/unit/testsuite/Migration/ResourceModel/Adapter/MysqlTest.php index d3f5a3a5..ac8f8b0e 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/Adapter/MysqlTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/Adapter/MysqlTest.php @@ -21,7 +21,7 @@ class MysqlTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $this->pdoMysql = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) diff --git a/tests/unit/testsuite/Migration/ResourceModel/Adapter/Pdo/MysqlBuilderTest.php b/tests/unit/testsuite/Migration/ResourceModel/Adapter/Pdo/MysqlBuilderTest.php index a832e06e..a6b84c93 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/Adapter/Pdo/MysqlBuilderTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/Adapter/Pdo/MysqlBuilderTest.php @@ -36,7 +36,7 @@ class MysqlBuilderTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $this->objectManager = $this->getMockBuilder(\Magento\Framework\ObjectManager\ObjectManager::class) ->disableOriginalConstructor() diff --git a/tests/unit/testsuite/Migration/ResourceModel/AdapterFactoryTest.php b/tests/unit/testsuite/Migration/ResourceModel/AdapterFactoryTest.php index 0e764ddc..082da7d6 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/AdapterFactoryTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/AdapterFactoryTest.php @@ -29,7 +29,7 @@ class AdapterFactoryTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $this->config = $this->createPartialMock( \Migration\Config::class, diff --git a/tests/unit/testsuite/Migration/ResourceModel/DestinationTest.php b/tests/unit/testsuite/Migration/ResourceModel/DestinationTest.php index eb28e59e..a3dad2e7 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/DestinationTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/DestinationTest.php @@ -49,7 +49,7 @@ class DestinationTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $adapterConfigs = ['resourceType' => 'destination']; $this->config = $this->createPartialMock( diff --git a/tests/unit/testsuite/Migration/ResourceModel/Document/CollectionTest.php b/tests/unit/testsuite/Migration/ResourceModel/Document/CollectionTest.php index 3ad76240..2b081d95 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/Document/CollectionTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/Document/CollectionTest.php @@ -20,7 +20,7 @@ class CollectionTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $document1 = $this->createMock(\Migration\ResourceModel\Document::class); $document1->expects($this->any())->method('getName')->will($this->returnValue('Doc1')); diff --git a/tests/unit/testsuite/Migration/ResourceModel/DocumentTest.php b/tests/unit/testsuite/Migration/ResourceModel/DocumentTest.php index 775f90f7..ed65c243 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/DocumentTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/DocumentTest.php @@ -25,7 +25,7 @@ class DocumentTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $this->structure = $this->createMock(\Migration\ResourceModel\Structure::class); $this->recordCollectionFactory = $this->getMockBuilder(\Migration\ResourceModel\Record\CollectionFactory::class) diff --git a/tests/unit/testsuite/Migration/ResourceModel/Record/CollectionTest.php b/tests/unit/testsuite/Migration/ResourceModel/Record/CollectionTest.php index 69f0fbff..dfcd9545 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/Record/CollectionTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/Record/CollectionTest.php @@ -25,7 +25,7 @@ class CollectionTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $this->structure = $this->createMock(\Migration\ResourceModel\Structure::class); $record1 = $this->createMock(\Migration\ResourceModel\Record::class); diff --git a/tests/unit/testsuite/Migration/ResourceModel/RecordTest.php b/tests/unit/testsuite/Migration/ResourceModel/RecordTest.php index c0b73365..2936f106 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/RecordTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/RecordTest.php @@ -20,7 +20,7 @@ class RecordTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $this->structure = $this->createMock(\Migration\ResourceModel\Structure::class); $this->structure->expects($this->any())->method('hasField')->willReturnCallback(function ($fieldName) { diff --git a/tests/unit/testsuite/Migration/ResourceModel/SourceTest.php b/tests/unit/testsuite/Migration/ResourceModel/SourceTest.php index 881a31f9..d8952079 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/SourceTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/SourceTest.php @@ -64,7 +64,7 @@ class SourceTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $adapterConfigs = ['resourceType' => 'source']; $this->config = $this->createPartialMock( diff --git a/tests/unit/testsuite/Migration/ResourceModel/Structure/CollectionTest.php b/tests/unit/testsuite/Migration/ResourceModel/Structure/CollectionTest.php index e45aa180..bbbbc09f 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/Structure/CollectionTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/Structure/CollectionTest.php @@ -20,7 +20,7 @@ class CollectionTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $structure1 = $this->createMock(\Migration\ResourceModel\Structure::class); $structure2 = $this->createMock(\Migration\ResourceModel\Structure::class); diff --git a/tests/unit/testsuite/Migration/ResourceModel/StructureTest.php b/tests/unit/testsuite/Migration/ResourceModel/StructureTest.php index 55a3dd21..e38e3180 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/StructureTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/StructureTest.php @@ -15,7 +15,7 @@ class StructureTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $this->structure = new \Migration\ResourceModel\Structure(['id' => 'int', 'name' => 'varchar']); } diff --git a/tests/unit/testsuite/Migration/Step/Eav/Integrity/AttributeFrontendInputTest.php b/tests/unit/testsuite/Migration/Step/Eav/Integrity/AttributeFrontendInputTest.php index 9104eeb8..364e3175 100644 --- a/tests/unit/testsuite/Migration/Step/Eav/Integrity/AttributeFrontendInputTest.php +++ b/tests/unit/testsuite/Migration/Step/Eav/Integrity/AttributeFrontendInputTest.php @@ -32,7 +32,7 @@ class AttributeFrontendInputTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $this->helper = $this->getMockBuilder(Helper::class) ->disableOriginalConstructor() diff --git a/tests/unit/testsuite/Migration/Step/Eav/Integrity/AttributeGroupNamesTest.php b/tests/unit/testsuite/Migration/Step/Eav/Integrity/AttributeGroupNamesTest.php index a6d16958..aa3cd087 100644 --- a/tests/unit/testsuite/Migration/Step/Eav/Integrity/AttributeGroupNamesTest.php +++ b/tests/unit/testsuite/Migration/Step/Eav/Integrity/AttributeGroupNamesTest.php @@ -28,7 +28,7 @@ class AttributeGroupNamesTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $this->helper = $this->getMockBuilder(\Migration\Step\Eav\Helper::class) ->disableOriginalConstructor() From ec402013b88eca4d0e934d3f32e06b30507d99c8 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 16 May 2026 10:09:15 +0000 Subject: [PATCH 5/6] Apply fixes from upstream PRs #929 and issue #934 PR #929: Fix EAV duplicate entry '11-general' constraint violation - Add getEntityAttributeSets() for generic entity type support - Add getDefaultEntityAttributeGroups() replacing product-specific logic - Refactor getCustomAttributeGroups() to use new generic methods Issue #934: Prevent duplicate gallery rows in InsertValueToEntity - Check for existing (value_id, entity_id) pair before inserting - Prevents catalog_product_entity_media_gallery_value_to_entity bloat https://claude.ai/code/session_015Y1Wix1FL2gJX27KoQ8N9J --- .../Handler/Gallery/InsertValueToEntity.php | 20 +++++- src/Migration/Step/Eav/Model/Data.php | 69 ++++++++++++++++--- 2 files changed, 77 insertions(+), 12 deletions(-) diff --git a/src/Migration/Handler/Gallery/InsertValueToEntity.php b/src/Migration/Handler/Gallery/InsertValueToEntity.php index 18be5c71..e40ba7fc 100644 --- a/src/Migration/Handler/Gallery/InsertValueToEntity.php +++ b/src/Migration/Handler/Gallery/InsertValueToEntity.php @@ -66,8 +66,24 @@ public function handle(Record $recordToHandle, Record $oppositeRecord) || $this->moduleList->has('Magento_CatalogStaging') === false ? $this->entityField : 'row_id'; - $record['value_id'] = $recordToHandle->getValue($this->field); - $record[$entityIdName] = $recordToHandle->getValue($this->entityField); + $valueId = (int)$recordToHandle->getValue($this->field); + $entityId = (int)$recordToHandle->getValue($this->entityField); + + $tableName = $this->destination->addDocumentPrefix($this->valueToEntityDocument); + $existing = $this->destination->getAdapter()->loadPage( + $tableName, + 0, + 1, + null, + null, + new \Zend_Db_Expr(sprintf('`value_id` = %d AND `%s` = %d', $valueId, $entityIdName, $entityId)) + ); + if (!empty($existing)) { + return; + } + + $record['value_id'] = $valueId; + $record[$entityIdName] = $entityId; $this->destination->saveRecords($this->valueToEntityDocument, [$record]); } } diff --git a/src/Migration/Step/Eav/Model/Data.php b/src/Migration/Step/Eav/Model/Data.php index d0441fc9..c450ecfd 100644 --- a/src/Migration/Step/Eav/Model/Data.php +++ b/src/Migration/Step/Eav/Model/Data.php @@ -131,6 +131,33 @@ public function getProductAttributeSets( return $attributeSets; } + /** + * Get list of attribute sets for a given entity type + * + * @param string $mode + * @param string $type + * @param string $entityTypeCode + * @return array + */ + public function getEntityAttributeSets( + $mode = self::ATTRIBUTE_SETS_ALL, + $type = self::TYPE_SOURCE, + $entityTypeCode = self::ENTITY_TYPE_PRODUCT_CODE + ) { + $entityTypeId = $this->getEntityTypeIdByCode($entityTypeCode, $type); + $attributeSets = []; + foreach ($this->initialData->getAttributeSets($type) as $attributeSet) { + if ($entityTypeId == $attributeSet['entity_type_id'] + && (($mode == self::ATTRIBUTE_SETS_DEFAULT && $attributeSet['attribute_set_name'] == 'Default') + || ($mode == self::ATTRIBUTE_SETS_NONE_DEFAULT && $attributeSet['attribute_set_name'] != 'Default') + || ($mode == self::ATTRIBUTE_SETS_ALL)) + ) { + $attributeSets[$attributeSet['attribute_set_id']] = $attributeSet; + } + } + return $attributeSets; + } + /** * Return entity type id by its code * @@ -208,6 +235,36 @@ public function getDefaultProductAttributeGroups() return $attributeGroups; } + /** + * Get default attribute groups for any entity type + * + * @param string $entityTypeCode + * @return array + */ + public function getDefaultEntityAttributeGroups($entityTypeCode = self::ENTITY_TYPE_PRODUCT_CODE) + { + $defaultAttributeSet = $this->getEntityAttributeSets( + self::ATTRIBUTE_SETS_DEFAULT, + self::TYPE_DEST, + $entityTypeCode + ); + + if (!$defaultAttributeSet) { + return []; + } + + $defaultAttributeSetId = array_shift($defaultAttributeSet)['attribute_set_id']; + $attributeGroups = []; + foreach ($this->initialData->getAttributeGroups(self::TYPE_DEST) as $attributeGroup) { + if ($attributeGroup['attribute_set_id'] == $defaultAttributeSetId) { + $attributeGroup['attribute_group_id'] = null; + $attributeGroup['attribute_set_id'] = null; + $attributeGroups[] = $attributeGroup; + } + } + return $attributeGroups; + } + /** * Get default product entity attributes * @@ -298,16 +355,8 @@ public function getCustomAttributeGroups($attributeSetId) $sourceAttributeGroupNames = []; $entityTypeCode = $this->getEntityTypeCodeByAttributeSetId($attributeSetId); $excludedAttributeGroups = $this->excludedAttributeGroups[$entityTypeCode] ?? []; - if ($entityTypeCode == self::ENTITY_TYPE_PRODUCT_CODE) { - foreach ($this->getDefaultProductAttributeGroups() as $attributeGroup) { - $defaultAttributeGroupNames[] = $attributeGroup['attribute_group_name']; - } - } else { - foreach ($this->initialData->getAttributeGroups(self::TYPE_DEST) as $attributeGroup) { - if ($attributeGroup['attribute_set_id'] == $attributeSetId) { - $defaultAttributeGroupNames[] = $attributeGroup['attribute_group_name']; - } - } + foreach ($this->getDefaultEntityAttributeGroups($entityTypeCode) as $attributeGroup) { + $defaultAttributeGroupNames[] = $attributeGroup['attribute_group_name']; } foreach ($this->initialData->getAttributeGroups(self::TYPE_SOURCE) as $attributeGroup) { if ($attributeGroup['attribute_set_id'] == $attributeSetId) { From c70ae52356c28fc134f8bbb1a16bd793f29062a2 Mon Sep 17 00:00:00 2001 From: Miye Date: Sun, 14 Jun 2026 00:32:32 +0200 Subject: [PATCH 6/6] Added tests --- .../Migration/App/SetupDeltaLogTest.php | 2 +- .../ResourceModel/SourceDestinationTest.php | 2 +- .../Migration/Step/Customer/DataTest.php | 2 +- .../Step/DataIntegrity/IntegrityTest.php | 2 +- .../testsuite/Migration/Step/EAV/DataTest.php | 2 +- .../Migration/Step/EAV/IntegrityTest.php | 2 +- .../Migration/Step/EAV/VolumeTest.php | 2 +- .../testsuite/Migration/Step/Map/DataTest.php | 2 +- .../Migration/Step/Map/VolumeTest.php | 2 +- .../Migration/Step/Stores/DataTest.php | 2 +- .../Migration/Step/Stores/IntegrityTest.php | 2 +- .../Migration/Step/TierPrice/DataTest.php | 2 +- .../Step/TierPrice/IntegrityTest.php | 2 +- .../UrlRewrite/Version11410to2000Test.php | 2 +- .../Step/UrlRewrite/Version191to2000Test.php | 2 +- tests/unit/framework/autoload.php | 4 +- tests/unit/framework/bootstrap.php | 21 +++++- .../Migration/App/Progress/FileTest.php | 8 +- .../testsuite/Migration/App/ProgressTest.php | 14 ++-- .../Migration/App/SetupDeltaLogTest.php | 17 +++-- .../Migration/App/Step/FactoryTest.php | 4 +- .../Migration/Handler/AddPrefixTest.php | 4 +- .../Migration/Handler/ClassMapTest.php | 2 +- .../Migration/Handler/ConvertTest.php | 4 +- .../Handler/EavAttribute/ConvertModelTest.php | 14 ++-- .../EavAttributeGroup/SetGroupCodeTest.php | 2 +- .../Handler/GetDestinationValueTest.php | 12 +-- .../Migration/Handler/ManagerTest.php | 8 +- .../Migration/Handler/PlaceholderTest.php | 2 +- .../Handler/Rule/ConditionSqlTest.php | 14 ++-- .../Rule/CustomerSegmentConditionSqlTest.php | 14 ++-- .../Handler/Rule/NormalizationIdsTest.php | 2 +- .../Handler/Rule/SerializedDataTest.php | 8 +- .../SetVisibleOnFrontTest.php | 20 ++--- .../ConvertWithConditionsTest.php | 2 +- .../SerializeToJson/ItemOptionTest.php | 2 +- .../Migration/Handler/SetHashTest.php | 4 +- .../Migration/Handler/SetValueTest.php | 4 +- .../Handler/Settings/CategoryRootIdTest.php | 2 +- .../Handler/Settings/EncryptTest.php | 6 +- .../Handler/Settings/TemplateTest.php | 2 +- .../Handler/Settings/UrlSuffixTest.php | 2 +- .../Migration/Handler/TimezonesTest.php | 4 +- .../testsuite/Migration/Logger/LoggerTest.php | 2 +- .../testsuite/Migration/Mode/DataTest.php | 18 ++--- .../testsuite/Migration/Mode/SettingsTest.php | 20 ++--- .../Migration/Reader/ClassMapTest.php | 2 +- .../testsuite/Migration/Reader/GroupsTest.php | 2 +- .../testsuite/Migration/Reader/MapTest.php | 2 +- .../Migration/Reader/SettingsTest.php | 6 +- .../Migration/RecordTransformerTest.php | 14 ++-- .../ResourceModel/AbstractCollectionTest.php | 6 +- .../ResourceModel/AbstractResourceTest.php | 6 +- .../ResourceModel/Adapter/MysqlTest.php | 8 +- .../ResourceModel/AdapterFactoryTest.php | 4 +- .../ResourceModel/DestinationTest.php | 8 +- .../ResourceModel/Document/CollectionTest.php | 8 +- .../Migration/ResourceModel/DocumentTest.php | 2 +- .../Migration/ResourceModel/RecordTest.php | 4 +- .../Migration/ResourceModel/SourceTest.php | 6 +- .../CustomCustomerAttributes/DataTest.php | 28 ++++--- .../IntegrityTest.php | 16 ++-- .../CustomCustomerAttributes/VolumeTest.php | 6 +- .../Migration/Step/Eav/HelperTest.php | 40 +++++----- .../Migration/Step/Eav/InitialDataTest.php | 2 +- .../Migration/Step/Eav/IntegrityTest.php | 22 +++--- .../Step/Eav/Model/IgnoredAttributesTest.php | 2 +- .../Migration/Step/Eav/VolumeTest.php | 2 +- .../testsuite/Migration/Step/Log/DataTest.php | 20 +++-- .../Migration/Step/Log/IntegrityTest.php | 30 ++++---- .../Migration/Step/Log/VolumeTest.php | 2 +- .../testsuite/Migration/Step/Map/DataTest.php | 52 +++++-------- .../Migration/Step/Map/DeltaTest.php | 2 +- .../Migration/Step/Map/HelperTest.php | 2 +- .../Migration/Step/Map/IntegrityTest.php | 74 +++++++++---------- .../Migration/Step/Map/VolumeTest.php | 2 +- .../Data/EavLeftoverDataCleanerTest.php | 2 +- .../Data/ProductsInRootCatalogCleanerTest.php | 2 +- .../Step/PostProcessing/DataTest.php | 2 +- .../Migration/Step/Ratings/DataTest.php | 8 +- .../Migration/Step/Ratings/IntegrityTest.php | 4 +- .../Migration/Step/Ratings/VolumeTest.php | 20 ++--- .../Migration/Step/SalesOrder/DataTest.php | 2 +- .../Migration/Step/SalesOrder/HelperTest.php | 2 +- .../Step/SalesOrder/InitialDataTest.php | 2 +- .../Step/SalesOrder/IntegrityTest.php | 2 +- .../Migration/Step/SalesOrder/VolumeTest.php | 2 +- .../Migration/Step/Settings/DataTest.php | 2 +- .../Migration/Step/Settings/IntegrityTest.php | 2 +- .../UrlRewrite/Version11410to2000Test.php | 2 +- .../Step/UrlRewrite/Version191to2000Test.php | 2 +- 91 files changed, 358 insertions(+), 350 deletions(-) diff --git a/tests/integration/testsuite/Migration/App/SetupDeltaLogTest.php b/tests/integration/testsuite/Migration/App/SetupDeltaLogTest.php index 1fd1fe2e..f55ec199 100644 --- a/tests/integration/testsuite/Migration/App/SetupDeltaLogTest.php +++ b/tests/integration/testsuite/Migration/App/SetupDeltaLogTest.php @@ -30,7 +30,7 @@ class SetupDeltaLogTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $helper = \Migration\TestFramework\Helper::getInstance(); $this->objectManager = $helper->getObjectManager(); diff --git a/tests/integration/testsuite/Migration/ResourceModel/SourceDestinationTest.php b/tests/integration/testsuite/Migration/ResourceModel/SourceDestinationTest.php index a90ff685..1b6d3c4c 100644 --- a/tests/integration/testsuite/Migration/ResourceModel/SourceDestinationTest.php +++ b/tests/integration/testsuite/Migration/ResourceModel/SourceDestinationTest.php @@ -24,7 +24,7 @@ class SourceDestinationTest extends \PHPUnit\Framework\TestCase /** * @return void */ - protected function setUp() + protected function setUp(): void { $helper = \Migration\TestFramework\Helper::getInstance(); $objectManager = $helper->getObjectManager(); diff --git a/tests/integration/testsuite/Migration/Step/Customer/DataTest.php b/tests/integration/testsuite/Migration/Step/Customer/DataTest.php index 6fdf3c06..28cdd92b 100644 --- a/tests/integration/testsuite/Migration/Step/Customer/DataTest.php +++ b/tests/integration/testsuite/Migration/Step/Customer/DataTest.php @@ -79,7 +79,7 @@ class DataTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $helper = \Migration\TestFramework\Helper::getInstance(); $objectManager = $helper->getObjectManager(); diff --git a/tests/integration/testsuite/Migration/Step/DataIntegrity/IntegrityTest.php b/tests/integration/testsuite/Migration/Step/DataIntegrity/IntegrityTest.php index a88330b4..9714e41b 100644 --- a/tests/integration/testsuite/Migration/Step/DataIntegrity/IntegrityTest.php +++ b/tests/integration/testsuite/Migration/Step/DataIntegrity/IntegrityTest.php @@ -44,7 +44,7 @@ class IntegrityTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $helper = \Migration\TestFramework\Helper::getInstance(); $objectManager = $helper->getObjectManager(); diff --git a/tests/integration/testsuite/Migration/Step/EAV/DataTest.php b/tests/integration/testsuite/Migration/Step/EAV/DataTest.php index 11545e8f..0c4efc2a 100644 --- a/tests/integration/testsuite/Migration/Step/EAV/DataTest.php +++ b/tests/integration/testsuite/Migration/Step/EAV/DataTest.php @@ -19,7 +19,7 @@ class DataTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $objectManager = \Migration\TestFramework\Helper::getInstance()->getObjectManager(); $objectManager->get(\Migration\Config::class)->init(dirname(__DIR__) . '/../_files/config.xml'); diff --git a/tests/integration/testsuite/Migration/Step/EAV/IntegrityTest.php b/tests/integration/testsuite/Migration/Step/EAV/IntegrityTest.php index 41e119da..322cd953 100644 --- a/tests/integration/testsuite/Migration/Step/EAV/IntegrityTest.php +++ b/tests/integration/testsuite/Migration/Step/EAV/IntegrityTest.php @@ -19,7 +19,7 @@ class IntegrityTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $objectManager = \Migration\TestFramework\Helper::getInstance()->getObjectManager(); $objectManager->get(\Migration\Config::class)->init(dirname(__DIR__) . '/../_files/config.xml'); diff --git a/tests/integration/testsuite/Migration/Step/EAV/VolumeTest.php b/tests/integration/testsuite/Migration/Step/EAV/VolumeTest.php index 7d2ddb4a..756ed834 100644 --- a/tests/integration/testsuite/Migration/Step/EAV/VolumeTest.php +++ b/tests/integration/testsuite/Migration/Step/EAV/VolumeTest.php @@ -24,7 +24,7 @@ class VolumeTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $objectManager = \Migration\TestFramework\Helper::getInstance()->getObjectManager(); $objectManager->get(\Migration\Config::class)->init(dirname(__DIR__) . '/../_files/config.xml'); diff --git a/tests/integration/testsuite/Migration/Step/Map/DataTest.php b/tests/integration/testsuite/Migration/Step/Map/DataTest.php index 21b342c3..5df4307b 100644 --- a/tests/integration/testsuite/Migration/Step/Map/DataTest.php +++ b/tests/integration/testsuite/Migration/Step/Map/DataTest.php @@ -21,7 +21,7 @@ public function testPerform() \Migration\App\Progress::class, ['getProcessedEntities', 'addProcessedEntity'] ); - $progress->expects($this->once())->method('getProcessedEntities')->will($this->returnValue([])); + $progress->expects($this->once())->method('getProcessedEntities')->willReturn([]); $progress->expects($this->any())->method('addProcessedEntity'); $helper = \Migration\TestFramework\Helper::getInstance(); diff --git a/tests/integration/testsuite/Migration/Step/Map/VolumeTest.php b/tests/integration/testsuite/Migration/Step/Map/VolumeTest.php index c961d94a..cbbb5e9d 100644 --- a/tests/integration/testsuite/Migration/Step/Map/VolumeTest.php +++ b/tests/integration/testsuite/Migration/Step/Map/VolumeTest.php @@ -22,7 +22,7 @@ public function testPerform() \Migration\App\Progress::class, ['getProcessedEntities', 'addProcessedEntity'] ); - $progress->expects($this->once())->method('getProcessedEntities')->will($this->returnValue([])); + $progress->expects($this->once())->method('getProcessedEntities')->willReturn([]); $progress->expects($this->any())->method('addProcessedEntity'); $helper = \Migration\TestFramework\Helper::getInstance(); diff --git a/tests/integration/testsuite/Migration/Step/Stores/DataTest.php b/tests/integration/testsuite/Migration/Step/Stores/DataTest.php index c4f99b8b..ccf44da6 100644 --- a/tests/integration/testsuite/Migration/Step/Stores/DataTest.php +++ b/tests/integration/testsuite/Migration/Step/Stores/DataTest.php @@ -58,7 +58,7 @@ class DataTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $helper = \Migration\TestFramework\Helper::getInstance(); $objectManager = $helper->getObjectManager(); diff --git a/tests/integration/testsuite/Migration/Step/Stores/IntegrityTest.php b/tests/integration/testsuite/Migration/Step/Stores/IntegrityTest.php index 286d8142..f9c7482f 100644 --- a/tests/integration/testsuite/Migration/Step/Stores/IntegrityTest.php +++ b/tests/integration/testsuite/Migration/Step/Stores/IntegrityTest.php @@ -58,7 +58,7 @@ class IntegrityTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $helper = \Migration\TestFramework\Helper::getInstance(); $objectManager = $helper->getObjectManager(); diff --git a/tests/integration/testsuite/Migration/Step/TierPrice/DataTest.php b/tests/integration/testsuite/Migration/Step/TierPrice/DataTest.php index d9e9e95e..a9c3151f 100644 --- a/tests/integration/testsuite/Migration/Step/TierPrice/DataTest.php +++ b/tests/integration/testsuite/Migration/Step/TierPrice/DataTest.php @@ -56,7 +56,7 @@ class DataTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $helper = \Migration\TestFramework\Helper::getInstance(); $objectManager = $helper->getObjectManager(); diff --git a/tests/integration/testsuite/Migration/Step/TierPrice/IntegrityTest.php b/tests/integration/testsuite/Migration/Step/TierPrice/IntegrityTest.php index f6de8b70..6cbc3bc1 100644 --- a/tests/integration/testsuite/Migration/Step/TierPrice/IntegrityTest.php +++ b/tests/integration/testsuite/Migration/Step/TierPrice/IntegrityTest.php @@ -51,7 +51,7 @@ class IntegrityTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $helper = \Migration\TestFramework\Helper::getInstance(); $objectManager = $helper->getObjectManager(); diff --git a/tests/integration/testsuite/Migration/Step/UrlRewrite/Version11410to2000Test.php b/tests/integration/testsuite/Migration/Step/UrlRewrite/Version11410to2000Test.php index ffa9ae83..15c667d9 100644 --- a/tests/integration/testsuite/Migration/Step/UrlRewrite/Version11410to2000Test.php +++ b/tests/integration/testsuite/Migration/Step/UrlRewrite/Version11410to2000Test.php @@ -36,7 +36,7 @@ class Version11410to2000Test extends \PHPUnit\Framework\TestCase * @throws \Migration\Exception * @return void */ - protected function setUp() + protected function setUp(): void { $helper = \Migration\TestFramework\Helper::getInstance(); $this->objectManager = $helper->getObjectManager(); diff --git a/tests/integration/testsuite/Migration/Step/UrlRewrite/Version191to2000Test.php b/tests/integration/testsuite/Migration/Step/UrlRewrite/Version191to2000Test.php index 3ab7f54a..6b8a7e83 100644 --- a/tests/integration/testsuite/Migration/Step/UrlRewrite/Version191to2000Test.php +++ b/tests/integration/testsuite/Migration/Step/UrlRewrite/Version191to2000Test.php @@ -36,7 +36,7 @@ class Version191o2000Test extends \PHPUnit\Framework\TestCase * @throws \Migration\Exception * @return void */ - protected function setUp() + protected function setUp(): void { $helper = \Migration\TestFramework\Helper::getInstance(); $this->objectManager = $helper->getObjectManager(); diff --git a/tests/unit/framework/autoload.php b/tests/unit/framework/autoload.php index 7608b5c8..47229301 100644 --- a/tests/unit/framework/autoload.php +++ b/tests/unit/framework/autoload.php @@ -9,6 +9,8 @@ $vendorDir = require $magentoDir . '/app/etc/vendor_path.php'; $vendorAutoload = require $magentoDir . "/{$vendorDir}/autoload.php"; -$testsBaseDir = "$magentoDir/$vendorDir/magento/data-migration-tool/tests/unit"; +$testsBaseDir = dirname(__DIR__); +$toolBaseDir = dirname($testsBaseDir, 2); $vendorAutoload->add('Migration\\Test\\', "{$testsBaseDir}/testsuite/Migration"); $vendorAutoload->addPsr4('Migration\\TestFramework\\', "{$testsBaseDir}/framework"); +$vendorAutoload->addPsr4('Migration\\', "{$toolBaseDir}/src/Migration", true); diff --git a/tests/unit/framework/bootstrap.php b/tests/unit/framework/bootstrap.php index 28523612..58cf6167 100644 --- a/tests/unit/framework/bootstrap.php +++ b/tests/unit/framework/bootstrap.php @@ -9,7 +9,10 @@ if (!defined('TESTS_TEMP_DIR')) { define('TESTS_TEMP_DIR', dirname(__DIR__) . '/tmp'); } -require BP . '/app/functions.php'; +// Magento 2.4.9+ removed app/functions.php; __() is autoloaded via magento/framework registration.php +if (file_exists(BP . '/app/functions.php')) { + require BP . '/app/functions.php'; +} if (is_dir(TESTS_TEMP_DIR)) { $filesystemAdapter = new \Magento\Framework\Filesystem\Driver\File(); @@ -17,6 +20,22 @@ } mkdir(TESTS_TEMP_DIR); +// PHPUnit 10+ cannot create test doubles for undefined classes; generate factories and proxies on demand +$generatorIo = new \Magento\Framework\Code\Generator\Io( + new \Magento\Framework\Filesystem\Driver\File(), + TESTS_TEMP_DIR . '/generated/code' +); +$generatedCodeAutoloader = new \Magento\Framework\TestFramework\Unit\Autoloader\GeneratedClassesAutoloader( + [ + new \Magento\Framework\TestFramework\Unit\Autoloader\ExtensionAttributesGenerator(), + new \Magento\Framework\TestFramework\Unit\Autoloader\ExtensionAttributesInterfaceGenerator(), + new \Magento\Framework\TestFramework\Unit\Autoloader\FactoryGenerator(), + new \Magento\Framework\TestFramework\Unit\Autoloader\ProxyGenerator(), + ], + $generatorIo +); +spl_autoload_register([$generatedCodeAutoloader, 'load']); + \Magento\Framework\Phrase::setRenderer(new \Magento\Framework\Phrase\Renderer\Placeholder()); set_time_limit(0); diff --git a/tests/unit/testsuite/Migration/App/Progress/FileTest.php b/tests/unit/testsuite/Migration/App/Progress/FileTest.php index 207fcdcd..fec1bdd1 100644 --- a/tests/unit/testsuite/Migration/App/Progress/FileTest.php +++ b/tests/unit/testsuite/Migration/App/Progress/FileTest.php @@ -28,13 +28,13 @@ class FileTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->filesystemDriver = $this->getMockBuilder(\Magento\Framework\Filesystem\Driver\File::class) ->setMethods(['isExists', 'filePutContents', 'fileGetContents']) ->disableOriginalConstructor() ->getMock(); - $this->filesystemDriver->expects($this->any())->method('filePutContents')->will($this->returnValue(true)); + $this->filesystemDriver->expects($this->any())->method('filePutContents')->willReturn(true); $directoryRead = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\ReadInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -54,7 +54,7 @@ public function setUp() public function testSaveData() { $data = ['key' => ['other_key' => 'value']]; - $this->filesystemDriver->expects($this->any())->method('isExists')->will($this->returnValue(true)); + $this->filesystemDriver->expects($this->any())->method('isExists')->willReturn(true); $this->assertTrue($this->file->saveData($data)); } @@ -63,7 +63,7 @@ public function testSaveData() */ public function testGetData() { - $this->filesystemDriver->expects($this->any())->method('isExists')->will($this->returnValue(true)); + $this->filesystemDriver->expects($this->any())->method('isExists')->willReturn(true); $dataSerialized = '{"object":{"integrity":true}}'; $this->filesystemDriver->expects($this->once())->method('fileGetContents')->willReturn($dataSerialized); $data = $this->file->getData(); diff --git a/tests/unit/testsuite/Migration/App/ProgressTest.php b/tests/unit/testsuite/Migration/App/ProgressTest.php index 2c3bbbff..80b8850d 100644 --- a/tests/unit/testsuite/Migration/App/ProgressTest.php +++ b/tests/unit/testsuite/Migration/App/ProgressTest.php @@ -24,7 +24,7 @@ class ProgressTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->file = $this->getMockBuilder(\Migration\App\Progress\File::class) ->setMethods(['getData', 'saveData', 'clearLockFile', 'isExists']) @@ -65,7 +65,7 @@ public function isCompletedDataProvider() */ public function testIsCompleted($data, $step, $stage, $result) { - $this->file->expects($this->once())->method('getData')->will($this->returnValue($data)); + $this->file->expects($this->once())->method('getData')->willReturn($data); $isCompleted = $this->progress->isCompleted($step, $stage); $this->assertEquals($result, $isCompleted); } @@ -90,7 +90,7 @@ public function testAddProcessedEntityAlreadyExist() $stage = 'run'; $documentName = 'document_name1'; $data = [get_class($step) => [$stage => ['process' => [$documentName]]]]; - $this->file->expects($this->once())->method('getData')->will($this->returnValue($data)); + $this->file->expects($this->once())->method('getData')->willReturn($data); $result = $this->progress->addProcessedEntity($step, $stage, $documentName); $this->assertFalse($result); } @@ -118,7 +118,7 @@ public function testGetProcessedEntities() $stage = 'run'; $document = ['some_document']; $progress = [get_class($step) => [$stage => ['process' => $document]]]; - $this->file->expects($this->once())->method('getData')->will($this->returnValue($progress)); + $this->file->expects($this->once())->method('getData')->willReturn($progress); $result = $this->progress->getProcessedEntities($step, $stage); $this->assertEquals($document, $result); } @@ -128,7 +128,7 @@ public function testGetProcessedEntities() */ public function testSaveResult() { - $this->file->expects($this->once())->method('saveData')->will($this->returnValue(1)); + $this->file->expects($this->once())->method('saveData')->willReturn(1); $step = $this->getMockBuilder(\Migration\Step\Map\Migrate::class) ->disableOriginalConstructor() ->getMock(); @@ -153,7 +153,7 @@ public function testResetObject() ->disableOriginalConstructor() ->getMock(); $data = [get_class($step) => ['dummy_array']]; - $this->file->expects($this->once())->method('getData')->will($this->returnValue($data)); + $this->file->expects($this->once())->method('getData')->willReturn($data); $this->file->expects($this->once())->method('saveData')->with([]); $this->progress->reset($step); } @@ -163,7 +163,7 @@ public function testResetObject() */ public function testSaveDataNoFile() { - $this->file->expects($this->any())->method('isExists')->will($this->returnValue(false)); + $this->file->expects($this->any())->method('isExists')->willReturn(false); $this->file->expects($this->once())->method('saveData'); $step = $this->getMockBuilder(\Migration\Step\Map::class) ->disableOriginalConstructor() diff --git a/tests/unit/testsuite/Migration/App/SetupDeltaLogTest.php b/tests/unit/testsuite/Migration/App/SetupDeltaLogTest.php index 75a58803..0dcbf4e7 100644 --- a/tests/unit/testsuite/Migration/App/SetupDeltaLogTest.php +++ b/tests/unit/testsuite/Migration/App/SetupDeltaLogTest.php @@ -24,13 +24,20 @@ public function testPerform() $source->expects($this->any()) ->method('getDocument') ->willReturn($document); + $createDeltaArgs = [ + ['orders', 'order_id'], + ['invoices', 'invoice_id'], + ['reports', 'report_id'], + ['shipments', 'shipment_id'] + ]; + $createDeltaInvocations = 0; $source->expects($this->exactly(4)) ->method('createDelta') - ->withConsecutive( - ['orders', 'order_id'], - ['invoices', 'invoice_id'], - ['reports', 'report_id'], - ['shipments', 'shipment_id'] + ->willReturnCallback( + function ($document, $idKey) use ($createDeltaArgs, &$createDeltaInvocations) { + $this->assertSame($createDeltaArgs[$createDeltaInvocations], [$document, $idKey]); + $createDeltaInvocations++; + } ); /** @var \Migration\Reader\Groups|\PHPUnit_Framework_MockObject_MockObject $readerGroups */ diff --git a/tests/unit/testsuite/Migration/App/Step/FactoryTest.php b/tests/unit/testsuite/Migration/App/Step/FactoryTest.php index 20ed1ecc..0e41ea91 100644 --- a/tests/unit/testsuite/Migration/App/Step/FactoryTest.php +++ b/tests/unit/testsuite/Migration/App/Step/FactoryTest.php @@ -23,7 +23,7 @@ class FactoryTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->objectManager = $this->getMockBuilder(\Magento\Framework\ObjectManager\ObjectManager::class) ->disableOriginalConstructor() @@ -38,7 +38,7 @@ public function setUp() public function testCreate() { $step = $this->createMock(\Migration\App\Step\StageInterface::class); - $this->objectManager->expects($this->once())->method('create')->will($this->returnValue($step)); + $this->objectManager->expects($this->once())->method('create')->willReturn($step); $this->assertSame($step, $this->factory->create(\Migration\Steps\Integrity::class)); } diff --git a/tests/unit/testsuite/Migration/Handler/AddPrefixTest.php b/tests/unit/testsuite/Migration/Handler/AddPrefixTest.php index 3c63068d..17196e84 100644 --- a/tests/unit/testsuite/Migration/Handler/AddPrefixTest.php +++ b/tests/unit/testsuite/Migration/Handler/AddPrefixTest.php @@ -23,8 +23,8 @@ public function testHandle() ->setMethods(['getValue', 'setValue', 'getFields']) ->disableOriginalConstructor() ->getMock(); - $recordToHandle->expects($this->once())->method('getFields')->will($this->returnValue([$fieldName])); - $recordToHandle->expects($this->once())->method('getValue')->with($fieldName)->will($this->returnValue('val')); + $recordToHandle->expects($this->once())->method('getFields')->willReturn([$fieldName]); + $recordToHandle->expects($this->once())->method('getValue')->with($fieldName)->willReturn('val'); $recordToHandle->expects($this->once())->method('setValue')->with($fieldName, $prefix . 'val'); $oppositeRecord = $this->getMockBuilder(\Migration\ResourceModel\Record::class) diff --git a/tests/unit/testsuite/Migration/Handler/ClassMapTest.php b/tests/unit/testsuite/Migration/Handler/ClassMapTest.php index 306ea4e1..422dca39 100644 --- a/tests/unit/testsuite/Migration/Handler/ClassMapTest.php +++ b/tests/unit/testsuite/Migration/Handler/ClassMapTest.php @@ -22,7 +22,7 @@ public function testHandle() ); $record->expects($this->once())->method('getValue')->with($fieldName)->willReturn($classOldFashion); $record->expects($this->once())->method('setValue')->with($fieldName, $classNewStyle); - $record->expects($this->once())->method('getFields')->will($this->returnValue([$fieldName])); + $record->expects($this->once())->method('getFields')->willReturn([$fieldName]); $record2 = $this->getMockBuilder(\Migration\ResourceModel\Record::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/unit/testsuite/Migration/Handler/ConvertTest.php b/tests/unit/testsuite/Migration/Handler/ConvertTest.php index b203f738..c1d8bc6d 100644 --- a/tests/unit/testsuite/Migration/Handler/ConvertTest.php +++ b/tests/unit/testsuite/Migration/Handler/ConvertTest.php @@ -42,9 +42,9 @@ public function testHandle($map, $initialValue, $processedValue) \Migration\ResourceModel\Record::class, ['setValue', 'getValue', 'getFields'] ); - $record->expects($this->once())->method('getValue')->will($this->returnValue($initialValue)); + $record->expects($this->once())->method('getValue')->willReturn($initialValue); $record->expects($this->once())->method('setValue')->with($fieldName, $processedValue); - $record->expects($this->any())->method('getFields')->will($this->returnValue([$fieldName])); + $record->expects($this->any())->method('getFields')->willReturn([$fieldName]); $record2 = $this->getMockBuilder(\Migration\ResourceModel\Record::class) ->disableOriginalConstructor() diff --git a/tests/unit/testsuite/Migration/Handler/EavAttribute/ConvertModelTest.php b/tests/unit/testsuite/Migration/Handler/EavAttribute/ConvertModelTest.php index 0622ac5c..eec73863 100644 --- a/tests/unit/testsuite/Migration/Handler/EavAttribute/ConvertModelTest.php +++ b/tests/unit/testsuite/Migration/Handler/EavAttribute/ConvertModelTest.php @@ -30,7 +30,7 @@ class ConvertModelTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->classMap = $this->getMockBuilder(\Migration\Reader\ClassMap::class)->setMethods(['convertClassName']) ->disableOriginalConstructor() @@ -57,11 +57,11 @@ public function testHandleConvert() $this->classMap->expects($this->once())->method('convertClassName') ->with('some\class_name') - ->will($this->returnValue('Some\Class\Name')); + ->willReturn('Some\Class\Name'); - $recordToHandle->expects($this->once())->method('getFields')->will($this->returnValue([$this->fieldName])); + $recordToHandle->expects($this->once())->method('getFields')->willReturn([$this->fieldName]); $recordToHandle->expects($this->once())->method('getValue')->with($this->fieldName) - ->will($this->returnValue('some\class_name')); + ->willReturn('some\class_name'); $recordToHandle->expects($this->once())->method('setValue')->with($this->fieldName, 'Some\Class\Name'); $this->handler->handle($recordToHandle, $oppositeRecord); @@ -81,13 +81,13 @@ public function testHandleGetDestination() $oppositeRecord = $this->getMockBuilder(\Migration\ResourceModel\Record::class)->disableOriginalConstructor() ->setMethods(['getValue']) ->getMock(); - $oppositeRecord->expects($this->once())->method('getValue')->will($this->returnValue('Some\Class\Name')); + $oppositeRecord->expects($this->once())->method('getValue')->willReturn('Some\Class\Name'); $this->classMap->expects($this->once())->method('convertClassName'); - $recordToHandle->expects($this->once())->method('getFields')->will($this->returnValue([$this->fieldName])); + $recordToHandle->expects($this->once())->method('getFields')->willReturn([$this->fieldName]); $recordToHandle->expects($this->once())->method('getValue')->with($this->fieldName) - ->will($this->returnValue(null)); + ->willReturn(null); $recordToHandle->expects($this->once())->method('setValue')->with($this->fieldName, 'Some\Class\Name'); $this->handler->handle($recordToHandle, $oppositeRecord); diff --git a/tests/unit/testsuite/Migration/Handler/EavAttributeGroup/SetGroupCodeTest.php b/tests/unit/testsuite/Migration/Handler/EavAttributeGroup/SetGroupCodeTest.php index 5cbb3f09..b7ef9565 100644 --- a/tests/unit/testsuite/Migration/Handler/EavAttributeGroup/SetGroupCodeTest.php +++ b/tests/unit/testsuite/Migration/Handler/EavAttributeGroup/SetGroupCodeTest.php @@ -43,7 +43,7 @@ public function testHandle() ->method('getGroupCodeMap') ->with($groupName, $entityType) ->willReturn($groupCode); - $recordToHandle->expects($this->once())->method('getFields')->will($this->returnValue([$fieldName])); + $recordToHandle->expects($this->once())->method('getFields')->willReturn([$fieldName]); $recordToHandle->expects($this->any())->method('getValue')->willReturnMap( [ ['attribute_group_name', $groupName], diff --git a/tests/unit/testsuite/Migration/Handler/GetDestinationValueTest.php b/tests/unit/testsuite/Migration/Handler/GetDestinationValueTest.php index 11ab84fa..c9695f96 100644 --- a/tests/unit/testsuite/Migration/Handler/GetDestinationValueTest.php +++ b/tests/unit/testsuite/Migration/Handler/GetDestinationValueTest.php @@ -24,7 +24,7 @@ public function testHandleSetNull() ['setValue', 'getFields'] ); $recordToHandle->expects($this->once())->method('setValue')->with($fieldName, null); - $recordToHandle->expects($this->once())->method('getFields')->will($this->returnValue([$fieldName])); + $recordToHandle->expects($this->once())->method('getFields')->willReturn([$fieldName]); $oppositeRecord = $this->getMockBuilder(\Migration\ResourceModel\Record::class) ->setMethods(['getValue']) @@ -32,7 +32,7 @@ public function testHandleSetNull() ->getMock(); $oppositeRecord->expects($this->exactly(2))->method('getValue') ->with($fieldName) - ->will($this->returnValue(null)); + ->willReturn(null); $handler = new GetDestinationValue('true'); $handler->setField($fieldName); @@ -52,14 +52,14 @@ public function testHandleSetValue() ['setValue', 'getFields'] ); $recordToHandle->expects($this->once())->method('setValue')->with($fieldName, $value); - $recordToHandle->expects($this->once())->method('getFields')->will($this->returnValue([$fieldName])); + $recordToHandle->expects($this->once())->method('getFields')->willReturn([$fieldName]); $oppositeRecord = $this->getMockBuilder(\Migration\ResourceModel\Record::class) ->setMethods(['getValue']) ->disableOriginalConstructor() ->getMock(); $oppositeRecord->expects($this->exactly(2))->method('getValue')->with($fieldName) - ->will($this->returnValue($value)); + ->willReturn($value); $handler = new GetDestinationValue('true'); $handler->setField($fieldName); @@ -78,13 +78,13 @@ public function testHandleKeepValueFromSource() ['setValue', 'getFields'] ); $recordToHandle->expects($this->never())->method('setValue'); - $recordToHandle->expects($this->once())->method('getFields')->will($this->returnValue([$fieldName])); + $recordToHandle->expects($this->once())->method('getFields')->willReturn([$fieldName]); $oppositeRecord = $this->getMockBuilder(\Migration\ResourceModel\Record::class) ->setMethods(['getValue']) ->disableOriginalConstructor() ->getMock(); - $oppositeRecord->expects($this->once())->method('getValue')->with($fieldName)->will($this->returnValue(null)); + $oppositeRecord->expects($this->once())->method('getValue')->with($fieldName)->willReturn(null); $handler = new GetDestinationValue(); $handler->setField($fieldName); diff --git a/tests/unit/testsuite/Migration/Handler/ManagerTest.php b/tests/unit/testsuite/Migration/Handler/ManagerTest.php index dfaebd96..785697a9 100644 --- a/tests/unit/testsuite/Migration/Handler/ManagerTest.php +++ b/tests/unit/testsuite/Migration/Handler/ManagerTest.php @@ -42,7 +42,7 @@ public function testGetHandlerCorrect() \Migration\Handler\SetValue::class, ['setField'] ); - $this->objectManager->expects($this->any())->method('create')->will($this->returnValue($handler)); + $this->objectManager->expects($this->any())->method('create')->willReturn($handler); $handler->expects($this->once())->method('setField')->with($field); $this->manager->initHandler($field, $handlerConfig); $this->assertEquals($handler, $this->manager->getHandler($field)); @@ -62,7 +62,7 @@ public function testGetHandlerWithHandlerKey() \Migration\Handler\SetValue::class, ['setField'] ); - $this->objectManager->expects($this->any())->method('create')->will($this->returnValue($handler)); + $this->objectManager->expects($this->any())->method('create')->willReturn($handler); $handler->expects($this->once())->method('setField')->with($field); $this->manager->initHandler($field, $handlerConfig, $handlerKey); $this->assertEquals($handler, $this->manager->getHandler($handlerKey)); @@ -82,7 +82,7 @@ public function testGetHandlerEmpty() \Migration\Handler\SetValue::class, ['setField'] ); - $this->objectManager->expects($this->once())->method('create')->will($this->returnValue($handler)); + $this->objectManager->expects($this->once())->method('create')->willReturn($handler); $handler->expects($this->once())->method('setField')->with($field); $this->manager->initHandler($field, $handlerConfig); $this->assertEquals(null, $this->manager->getHandler('non_existent_field')); @@ -120,7 +120,7 @@ public function testInitInvalidHandler() $invalidHandler = $this->getMockBuilder(\Migration\Migration::class) ->disableOriginalConstructor() ->getMock(); - $this->objectManager->expects($this->once())->method('create')->will($this->returnValue($invalidHandler)); + $this->objectManager->expects($this->once())->method('create')->willReturn($invalidHandler); $this->expectException('\Exception'); $this->expectExceptionMessage("'Migration\\Migration' is not correct handler."); $this->manager->initHandler('somefield', $handlerConfig); diff --git a/tests/unit/testsuite/Migration/Handler/PlaceholderTest.php b/tests/unit/testsuite/Migration/Handler/PlaceholderTest.php index 3f8827b1..bd827594 100644 --- a/tests/unit/testsuite/Migration/Handler/PlaceholderTest.php +++ b/tests/unit/testsuite/Migration/Handler/PlaceholderTest.php @@ -28,7 +28,7 @@ public function testHandle() ); $record->expects($this->once())->method('getValue')->with($fieldName)->willReturn($content); $record->expects($this->once())->method('setValue')->with($fieldName, $contentConverted); - $record->expects($this->once())->method('getFields')->will($this->returnValue([$fieldName])); + $record->expects($this->once())->method('getFields')->willReturn([$fieldName]); $classMap = $this->createPartialMock( \Migration\Reader\ClassMap::class, ['getMap'] diff --git a/tests/unit/testsuite/Migration/Handler/Rule/ConditionSqlTest.php b/tests/unit/testsuite/Migration/Handler/Rule/ConditionSqlTest.php index d87bb89d..81f1ec7c 100644 --- a/tests/unit/testsuite/Migration/Handler/Rule/ConditionSqlTest.php +++ b/tests/unit/testsuite/Migration/Handler/Rule/ConditionSqlTest.php @@ -31,7 +31,7 @@ class ConditionSqlTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { /** @var Map|\PHPUnit_Framework_MockObject_MockObject $map */ $this->map = $this->getMockBuilder(\Migration\Reader\Map::class)->disableOriginalConstructor() @@ -50,9 +50,9 @@ public function setUp() $destination = $this->getMockBuilder(\Migration\ResourceModel\Destination::class)->disableOriginalConstructor() ->setMethods(['addDocumentPrefix']) ->getMock(); - $destination->expects($this->any())->method('addDocumentPrefix')->will($this->returnCallback(function ($value) { + $destination->expects($this->any())->method('addDocumentPrefix')->willReturnCallback(function ($value) { return 'pfx_' . $value; - })); + }); $this->handler = new ConditionSql($mapFactory, $this->source, $destination); } @@ -73,9 +73,9 @@ public function testHandle() ->getMock(); $fieldName = 'fieldname'; - $recordToHandle->expects($this->once())->method('getFields')->will($this->returnValue([$fieldName])); + $recordToHandle->expects($this->once())->method('getFields')->willReturn([$fieldName]); $recordToHandle->expects($this->once())->method('getValue')->with($fieldName) - ->will($this->returnValue('SELECT * FROM `source_some_document` LEFT JOIN `source_other_document`')); + ->willReturn('SELECT * FROM `source_some_document` LEFT JOIN `source_other_document`'); $recordToHandle->expects($this->once())->method('setValue') ->with($fieldName, 'SELECT * FROM `pfx_dest_some_document` LEFT JOIN `pfx_dest_other_document`'); @@ -88,8 +88,8 @@ public function testHandle() ); $this->source->expects($this->once())->method('getDocumentList') - ->will($this->returnValue(['source_some_document', 'source_other_document', 'source_ignored_document'])); - $this->source->expects($this->any())->method('addDocumentPrefix')->will($this->returnArgument(0)); + ->willReturn(['source_some_document', 'source_other_document', 'source_ignored_document']); + $this->source->expects($this->any())->method('addDocumentPrefix')->willReturnArgument(0); $this->handler->setField($fieldName); $this->handler->handle($recordToHandle, $oppositeRecord); diff --git a/tests/unit/testsuite/Migration/Handler/Rule/CustomerSegmentConditionSqlTest.php b/tests/unit/testsuite/Migration/Handler/Rule/CustomerSegmentConditionSqlTest.php index 9382399c..04112d8d 100644 --- a/tests/unit/testsuite/Migration/Handler/Rule/CustomerSegmentConditionSqlTest.php +++ b/tests/unit/testsuite/Migration/Handler/Rule/CustomerSegmentConditionSqlTest.php @@ -34,7 +34,7 @@ class CustomerSegmentConditionSqlTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { /** @var Map|\PHPUnit_Framework_MockObject_MockObject $map */ $this->mapMain = $this->getMockBuilder(\Migration\Reader\Map::class)->disableOriginalConstructor() @@ -60,9 +60,9 @@ public function setUp() $destination = $this->getMockBuilder(\Migration\ResourceModel\Destination::class)->disableOriginalConstructor() ->setMethods(['addDocumentPrefix']) ->getMock(); - $destination->expects($this->any())->method('addDocumentPrefix')->will($this->returnCallback(function ($value) { + $destination->expects($this->any())->method('addDocumentPrefix')->willReturnCallback(function ($value) { return 'pfx_' . $value; - })); + }); $this->handler = new CustomerSegmentConditionSql($mapFactory, $this->source, $destination); } @@ -83,9 +83,9 @@ public function testHandle() ->getMock(); $fieldName = 'fieldname'; - $recordToHandle->expects($this->once())->method('getFields')->will($this->returnValue([$fieldName])); + $recordToHandle->expects($this->once())->method('getFields')->willReturn([$fieldName]); $recordToHandle->expects($this->once())->method('getValue')->with($fieldName) - ->will($this->returnValue('SELECT * FROM `sales_flat_order` LEFT JOIN `source_some_document`')); + ->willReturn('SELECT * FROM `sales_flat_order` LEFT JOIN `source_some_document`'); $recordToHandle->expects($this->once())->method('setValue') ->with($fieldName, 'SELECT * FROM `pfx_sales_order` LEFT JOIN `pfx_dest_some_document`'); @@ -102,8 +102,8 @@ public function testHandle() ); $this->source->expects($this->once())->method('getDocumentList') - ->will($this->returnValue(['sales_flat_order', 'source_some_document'])); - $this->source->expects($this->any())->method('addDocumentPrefix')->will($this->returnArgument(0)); + ->willReturn(['sales_flat_order', 'source_some_document']); + $this->source->expects($this->any())->method('addDocumentPrefix')->willReturnArgument(0); $this->handler->setField($fieldName); $this->handler->handle($recordToHandle, $oppositeRecord); diff --git a/tests/unit/testsuite/Migration/Handler/Rule/NormalizationIdsTest.php b/tests/unit/testsuite/Migration/Handler/Rule/NormalizationIdsTest.php index 9ba0f25f..c920e0a7 100644 --- a/tests/unit/testsuite/Migration/Handler/Rule/NormalizationIdsTest.php +++ b/tests/unit/testsuite/Migration/Handler/Rule/NormalizationIdsTest.php @@ -47,7 +47,7 @@ class NormalizationIdsTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->destination = $this->getMockBuilder(\Migration\ResourceModel\Destination::class) ->disableOriginalConstructor() diff --git a/tests/unit/testsuite/Migration/Handler/Rule/SerializedDataTest.php b/tests/unit/testsuite/Migration/Handler/Rule/SerializedDataTest.php index e24df7b0..0341221c 100644 --- a/tests/unit/testsuite/Migration/Handler/Rule/SerializedDataTest.php +++ b/tests/unit/testsuite/Migration/Handler/Rule/SerializedDataTest.php @@ -38,14 +38,14 @@ public function testHandle() $classMap = $this->getMockBuilder(\Migration\Reader\ClassMap::class)->disableOriginalConstructor() ->setMethods(['convertClassName']) ->getMock(); - $classMap->expects($this->exactly(2))->method('convertClassName')->will($this->returnValueMap([ + $classMap->expects($this->exactly(2))->method('convertClassName')->willReturnMap([ ['some\class_name_1', 'Some\Class\Name1'], ['some\class_name_2', 'Some\Class\Name2'] - ])); + ]); $fieldName = 'fieldname'; - $recordToHandle->expects($this->once())->method('getFields')->will($this->returnValue([$fieldName])); - $recordToHandle->expects($this->once())->method('getValue')->with($fieldName)->will($this->returnValue($data)); + $recordToHandle->expects($this->once())->method('getFields')->willReturn([$fieldName]); + $recordToHandle->expects($this->once())->method('getValue')->with($fieldName)->willReturn($data); $recordToHandle->expects($this->once())->method('setValue')->with($fieldName, $convertedData); $handler = new SerializedData($classMap); diff --git a/tests/unit/testsuite/Migration/Handler/SalesOrderStatusState/SetVisibleOnFrontTest.php b/tests/unit/testsuite/Migration/Handler/SalesOrderStatusState/SetVisibleOnFrontTest.php index c0c931d6..008a9377 100644 --- a/tests/unit/testsuite/Migration/Handler/SalesOrderStatusState/SetVisibleOnFrontTest.php +++ b/tests/unit/testsuite/Migration/Handler/SalesOrderStatusState/SetVisibleOnFrontTest.php @@ -25,7 +25,7 @@ class SetVisibleOnFrontTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->recordToHandle = $this->getMockBuilder(\Migration\ResourceModel\Record::class) ->setMethods(['getValue', 'setValue', 'getFields']) @@ -41,8 +41,8 @@ public function setUp() public function testHandleInitiallyInvisible() { $fieldName = 'visible_on_front'; - $this->recordToHandle->expects($this->once())->method('getFields')->will($this->returnValue([$fieldName])); - $this->recordToHandle->expects($this->any())->method('getValue')->will($this->returnCallback(function ($value) { + $this->recordToHandle->expects($this->once())->method('getFields')->willReturn([$fieldName]); + $this->recordToHandle->expects($this->any())->method('getValue')->willReturnCallback(function ($value) { switch ($value) { case 'status': return 'pending_ogone'; @@ -52,7 +52,7 @@ public function testHandleInitiallyInvisible() break; } return ''; - })); + }); $this->recordToHandle->expects($this->once())->method('setValue')->with($fieldName, 0); $handler = new SetVisibleOnFront(); @@ -66,8 +66,8 @@ public function testHandleInitiallyInvisible() public function testHandleNotVisibleStates() { $fieldName = 'visible_on_front'; - $this->recordToHandle->expects($this->once())->method('getFields')->will($this->returnValue([$fieldName])); - $this->recordToHandle->expects($this->any())->method('getValue')->will($this->returnCallback(function ($value) { + $this->recordToHandle->expects($this->once())->method('getFields')->willReturn([$fieldName]); + $this->recordToHandle->expects($this->any())->method('getValue')->willReturnCallback(function ($value) { switch ($value) { case 'status': return 'some_my_status'; @@ -77,7 +77,7 @@ public function testHandleNotVisibleStates() break; } return ''; - })); + }); $this->recordToHandle->expects($this->once())->method('setValue')->with($fieldName, 0); $handler = new SetVisibleOnFront(); @@ -93,8 +93,8 @@ public function testHandleNotVisibleStates() public function testHandleVisibleState($state) { $fieldName = 'visible_on_front'; - $this->recordToHandle->expects($this->once())->method('getFields')->will($this->returnValue([$fieldName])); - $this->recordToHandle->expects($this->any())->method('getValue')->will($this->returnCallback( + $this->recordToHandle->expects($this->once())->method('getFields')->willReturn([$fieldName]); + $this->recordToHandle->expects($this->any())->method('getValue')->willReturnCallback( function ($value) use ($state) { switch ($value) { case 'status': @@ -106,7 +106,7 @@ function ($value) use ($state) { } return ''; } - )); + ); $this->recordToHandle->expects($this->once())->method('setValue')->with($fieldName, 1); $handler = new SetVisibleOnFront(); diff --git a/tests/unit/testsuite/Migration/Handler/SerializeToJson/ConvertWithConditionsTest.php b/tests/unit/testsuite/Migration/Handler/SerializeToJson/ConvertWithConditionsTest.php index 5f4c098f..7cfd680c 100644 --- a/tests/unit/testsuite/Migration/Handler/SerializeToJson/ConvertWithConditionsTest.php +++ b/tests/unit/testsuite/Migration/Handler/SerializeToJson/ConvertWithConditionsTest.php @@ -22,7 +22,7 @@ class ConvertWithConditionsTest extends \PHPUnit\Framework\TestCase */ protected $documentIdField; - public function setUp() + public function setUp(): void { $this->model = $this->getMockBuilder(\Migration\ResourceModel\Record::class) ->setMethods(['setValue', 'getValue', 'getFields', 'getData', 'getDocument']) diff --git a/tests/unit/testsuite/Migration/Handler/SerializeToJson/ItemOptionTest.php b/tests/unit/testsuite/Migration/Handler/SerializeToJson/ItemOptionTest.php index a3c7e951..6534bb06 100644 --- a/tests/unit/testsuite/Migration/Handler/SerializeToJson/ItemOptionTest.php +++ b/tests/unit/testsuite/Migration/Handler/SerializeToJson/ItemOptionTest.php @@ -12,7 +12,7 @@ class ItemOptionTest extends \PHPUnit\Framework\TestCase */ protected $model; - public function setUp() + public function setUp(): void { $this->model = $this->getMockBuilder(\Migration\ResourceModel\Record::class) ->setMethods(['setValue', 'getValue', 'getFields', 'getData']) diff --git a/tests/unit/testsuite/Migration/Handler/SetHashTest.php b/tests/unit/testsuite/Migration/Handler/SetHashTest.php index 7ba27da8..7573d2de 100644 --- a/tests/unit/testsuite/Migration/Handler/SetHashTest.php +++ b/tests/unit/testsuite/Migration/Handler/SetHashTest.php @@ -23,7 +23,7 @@ public function testHandle() ['setValue', 'getFields'] ); $recordToHandle->expects($this->once())->method('setValue')->with($fieldName, $hash($baseFieldValue)); - $recordToHandle->expects($this->once())->method('getFields')->will($this->returnValue([$fieldName])); + $recordToHandle->expects($this->once())->method('getFields')->willReturn([$fieldName]); $oppositeRecord = $this->getMockBuilder(\Migration\ResourceModel\Record::class) ->setMethods(['getValue']) @@ -33,7 +33,7 @@ public function testHandle() $oppositeRecord->expects($this->any()) ->method('getValue') ->with($baseField) - ->will($this->returnValue($baseFieldValue)); + ->willReturn($baseFieldValue); $handler = new SetHash($hash, $baseField); $handler->setField($fieldName); diff --git a/tests/unit/testsuite/Migration/Handler/SetValueTest.php b/tests/unit/testsuite/Migration/Handler/SetValueTest.php index 8d382d3d..6561b84b 100644 --- a/tests/unit/testsuite/Migration/Handler/SetValueTest.php +++ b/tests/unit/testsuite/Migration/Handler/SetValueTest.php @@ -20,7 +20,7 @@ public function testHandle() ['setValue', 'getFields'] ); $record->expects($this->once())->method('setValue')->with($fieldName, $value); - $record->expects($this->once())->method('getFields')->will($this->returnValue([$fieldName])); + $record->expects($this->once())->method('getFields')->willReturn([$fieldName]); $record2 = $this->getMockBuilder(\Migration\ResourceModel\Record::class) ->disableOriginalConstructor() @@ -41,7 +41,7 @@ public function testHandleException() \Migration\ResourceModel\Record::class, ['getFields'] ); - $record->expects($this->once())->method('getFields')->will($this->returnValue([])); + $record->expects($this->once())->method('getFields')->willReturn([]); $handler = new SetValue($value); $record2 = $this->getMockBuilder(\Migration\ResourceModel\Record::class) ->disableOriginalConstructor() diff --git a/tests/unit/testsuite/Migration/Handler/Settings/CategoryRootIdTest.php b/tests/unit/testsuite/Migration/Handler/Settings/CategoryRootIdTest.php index 97f9d0fa..75c77a87 100644 --- a/tests/unit/testsuite/Migration/Handler/Settings/CategoryRootIdTest.php +++ b/tests/unit/testsuite/Migration/Handler/Settings/CategoryRootIdTest.php @@ -22,7 +22,7 @@ public function testHandle() ); $recordToHandle->expects($this->once())->method('getValue')->with($fieldName)->willReturn($categoryRootId); $recordToHandle->expects($this->once())->method('setValue')->with($fieldName, $categoryRootIdHandled); - $recordToHandle->expects($this->once())->method('getFields')->will($this->returnValue([$fieldName])); + $recordToHandle->expects($this->once())->method('getFields')->willReturn([$fieldName]); $oppositeRecord = $this->getMockBuilder(\Migration\ResourceModel\Record::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/unit/testsuite/Migration/Handler/Settings/EncryptTest.php b/tests/unit/testsuite/Migration/Handler/Settings/EncryptTest.php index e9164c29..1b26c8d5 100644 --- a/tests/unit/testsuite/Migration/Handler/Settings/EncryptTest.php +++ b/tests/unit/testsuite/Migration/Handler/Settings/EncryptTest.php @@ -72,7 +72,7 @@ public function testHandle($attributeData, $expected) ); $recordToHandle->expects($this->once())->method('getValue')->with($fieldName)->willReturn($dbValue); $recordToHandle->expects($this->once())->method('setValue')->with($fieldName, $newValue); - $recordToHandle->expects($this->once())->method('getFields')->will($this->returnValue([$fieldName])); + $recordToHandle->expects($this->once())->method('getFields')->willReturn([$fieldName]); $oppositeRecord = $this->getMockBuilder(\Migration\ResourceModel\Record::class) ->disableOriginalConstructor() ->getMock(); @@ -90,7 +90,7 @@ public function testHandle($attributeData, $expected) $this->configReader->expects($this->once()) ->method('getOption') ->with(self::CRYPT_KEY) - ->will($this->returnValue($key)); + ->willReturn($key); $this->cryptFactory->expects($this->once()) ->method('create') @@ -100,7 +100,7 @@ public function testHandle($attributeData, $expected) 'mode' => $mode, 'initVector' => $initVector, ]) - ->will($this->returnValue($crypt)); + ->willReturn($crypt); $this->encryptor->expects($this->once()) ->method('encrypt') diff --git a/tests/unit/testsuite/Migration/Handler/Settings/TemplateTest.php b/tests/unit/testsuite/Migration/Handler/Settings/TemplateTest.php index 18ed48e2..a3cf3a63 100644 --- a/tests/unit/testsuite/Migration/Handler/Settings/TemplateTest.php +++ b/tests/unit/testsuite/Migration/Handler/Settings/TemplateTest.php @@ -22,7 +22,7 @@ public function testHandle() ); $recordToHandle->expects($this->once())->method('getValue')->with($fieldName)->willReturn($templateOldFashion); $recordToHandle->expects($this->once())->method('setValue')->with($fieldName, $templateNewStyle); - $recordToHandle->expects($this->once())->method('getFields')->will($this->returnValue([$fieldName])); + $recordToHandle->expects($this->once())->method('getFields')->willReturn([$fieldName]); $oppositeRecord = $this->getMockBuilder(\Migration\ResourceModel\Record::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/unit/testsuite/Migration/Handler/Settings/UrlSuffixTest.php b/tests/unit/testsuite/Migration/Handler/Settings/UrlSuffixTest.php index ef8b6ad4..e232d2e3 100644 --- a/tests/unit/testsuite/Migration/Handler/Settings/UrlSuffixTest.php +++ b/tests/unit/testsuite/Migration/Handler/Settings/UrlSuffixTest.php @@ -22,7 +22,7 @@ public function testHandle() ); $recordToHandle->expects($this->once())->method('getValue')->with($fieldName)->willReturn($urlSuffix); $recordToHandle->expects($this->once())->method('setValue')->with($fieldName, $urlSuffixHandled); - $recordToHandle->expects($this->once())->method('getFields')->will($this->returnValue([$fieldName])); + $recordToHandle->expects($this->once())->method('getFields')->willReturn([$fieldName]); $oppositeRecord = $this->getMockBuilder(\Migration\ResourceModel\Record::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/unit/testsuite/Migration/Handler/TimezonesTest.php b/tests/unit/testsuite/Migration/Handler/TimezonesTest.php index 2e422fb1..2212435b 100644 --- a/tests/unit/testsuite/Migration/Handler/TimezonesTest.php +++ b/tests/unit/testsuite/Migration/Handler/TimezonesTest.php @@ -37,8 +37,8 @@ public function testHandle($timeAndOffset, $expected) $recordToHandle->expects($this->any())->method('getValue')->willReturn($value); $recordToHandle->expects($this->any())->method('setValue')->with($fieldName, $newValue); - $recordToHandle->expects($this->any())->method('getFields')->will($this->returnValue([$fieldName])); - $recordToHandle->expects($this->any())->method('getStructure')->will($this->returnValue($structure)); + $recordToHandle->expects($this->any())->method('getFields')->willReturn([$fieldName]); + $recordToHandle->expects($this->any())->method('getStructure')->willReturn($structure); $oppositeRecord = $this->getMockBuilder(\Migration\ResourceModel\Record::class) ->disableOriginalConstructor() diff --git a/tests/unit/testsuite/Migration/Logger/LoggerTest.php b/tests/unit/testsuite/Migration/Logger/LoggerTest.php index 2a104df5..2fbf4fd5 100644 --- a/tests/unit/testsuite/Migration/Logger/LoggerTest.php +++ b/tests/unit/testsuite/Migration/Logger/LoggerTest.php @@ -41,7 +41,7 @@ public function testAddRecord() ->disableOriginalConstructor() ->setMethods(['handle']) ->getMock(); - $consoleHandler->expects($this->any())->method('handle')->will($this->returnValue(true)); + $consoleHandler->expects($this->any())->method('handle')->willReturn(true); $this->logger->pushHandler($consoleHandler); $this->logger->addRecord(\Monolog\Logger::INFO, $infoMessage); $this->logger->addRecord(\Monolog\Logger::ERROR, $errorMessage); diff --git a/tests/unit/testsuite/Migration/Mode/DataTest.php b/tests/unit/testsuite/Migration/Mode/DataTest.php index c3867e9f..a6430782 100644 --- a/tests/unit/testsuite/Migration/Mode/DataTest.php +++ b/tests/unit/testsuite/Migration/Mode/DataTest.php @@ -36,7 +36,7 @@ class DataTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->stepList = $this->getMockBuilder(\Migration\App\Mode\StepList::class)->disableOriginalConstructor() ->setMethods(['getSteps']) @@ -75,7 +75,7 @@ public function testRunStepsIntegrityFail() $this->expectException(\Migration\Exception::class); $this->expectExceptionMessage('Integrity Check failed'); $step = $this->getMockBuilder(\Migration\App\Step\StageInterface::class)->getMock(); - $step->expects($this->once())->method('perform')->will($this->returnValue(false)); + $step->expects($this->once())->method('perform')->willReturn(false); $this->progress->expects($this->any())->method('saveResult')->willReturnSelf(); $this->progress->expects($this->any())->method('isCompleted')->willReturn(false); $this->stepList->expects($this->once())->method('getSteps') @@ -91,10 +91,10 @@ public function testRunStepsIntegrityFail() public function testRunStepsVolumeFail() { $stepData = $this->getMockBuilder(\Migration\App\Step\StageInterface::class)->getMock(); - $stepData->expects($this->once())->method('perform')->will($this->returnValue(true)); + $stepData->expects($this->once())->method('perform')->willReturn(true); $stepVolume = $this->getMockBuilder(\Migration\App\Step\StageInterface::class)->getMock(); - $stepVolume->expects($this->once())->method('perform')->will($this->returnValue(false)); + $stepVolume->expects($this->once())->method('perform')->willReturn(false); $this->progress->expects($this->any())->method('saveResult')->willReturnSelf(); $this->progress->expects($this->any())->method('isCompleted')->willReturn(false); @@ -113,9 +113,9 @@ public function testRunStepsDataMigrationFail() $this->expectException(\Migration\Exception::class); $this->expectExceptionMessage('Data Migration failed'); $stageIntegrity = $this->getMockBuilder(\Migration\App\Step\StageInterface::class)->getMock(); - $stageIntegrity->expects($this->once())->method('perform')->will($this->returnValue(true)); + $stageIntegrity->expects($this->once())->method('perform')->willReturn(true); $stageData = $this->getMockBuilder(\Migration\App\Step\StageInterface::class)->getMock(); - $stageData->expects($this->once())->method('perform')->will($this->returnValue(false)); + $stageData->expects($this->once())->method('perform')->willReturn(false); $this->progress->expects($this->any())->method('saveResult')->willReturnSelf(); $this->progress->expects($this->any())->method('isCompleted')->willReturn(false); $this->progress->expects($this->any())->method('reset')->with($stageData); @@ -131,11 +131,11 @@ public function testRunStepsDataMigrationFail() public function testRunStepsSuccess() { $stageIntegrity = $this->getMockBuilder(\Migration\App\Step\StageInterface::class)->getMock(); - $stageIntegrity->expects($this->once())->method('perform')->will($this->returnValue(true)); + $stageIntegrity->expects($this->once())->method('perform')->willReturn(true); $stageData = $this->getMockBuilder(\Migration\App\Step\StageInterface::class)->getMock(); - $stageData->expects($this->once())->method('perform')->will($this->returnValue(true)); + $stageData->expects($this->once())->method('perform')->willReturn(true); $stageVolume = $this->getMockBuilder(\Migration\App\Step\StageInterface::class)->getMock(); - $stageVolume->expects($this->once())->method('perform')->will($this->returnValue(true)); + $stageVolume->expects($this->once())->method('perform')->willReturn(true); $this->progress->expects($this->any())->method('saveResult')->willReturnSelf(); $this->progress->expects($this->any())->method('isCompleted')->willReturn(false); $this->logger->expects($this->at(0))->method('info')->with("started"); diff --git a/tests/unit/testsuite/Migration/Mode/SettingsTest.php b/tests/unit/testsuite/Migration/Mode/SettingsTest.php index e20daa9e..2a57c413 100644 --- a/tests/unit/testsuite/Migration/Mode/SettingsTest.php +++ b/tests/unit/testsuite/Migration/Mode/SettingsTest.php @@ -41,7 +41,7 @@ class SettingsTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->stepList = $this->getMockBuilder(\Migration\App\Mode\StepList::class)->disableOriginalConstructor() ->setMethods(['getSteps']) @@ -73,7 +73,7 @@ public function testRunStepsIntegrityFail() $this->expectException(\Migration\Exception::class); $this->expectExceptionMessage('Integrity Check failed'); $step = $this->getMockBuilder(\Migration\App\Step\StageInterface::class)->getMock(); - $step->expects($this->once())->method('perform')->will($this->returnValue(false)); + $step->expects($this->once())->method('perform')->willReturn(false); $this->progress->expects($this->any())->method('saveResult')->willReturnSelf(); $this->progress->expects($this->any())->method('isCompleted')->willReturn(false); $this->stepList->expects($this->once())->method('getSteps') @@ -88,13 +88,13 @@ public function testRunStepsVolumeFail() { $this->logger->expects($this->once())->method('warning')->with('Volume Check failed'); $stepIntegrity = $this->getMockBuilder(\Migration\App\Step\StageInterface::class)->getMock(); - $stepIntegrity->expects($this->once())->method('perform')->will($this->returnValue(true)); + $stepIntegrity->expects($this->once())->method('perform')->willReturn(true); $stepData = $this->getMockBuilder(\Migration\App\Step\StageInterface::class)->getMock(); - $stepData->expects($this->once())->method('perform')->will($this->returnValue(true)); + $stepData->expects($this->once())->method('perform')->willReturn(true); $stepVolume = $this->getMockBuilder(\Migration\App\Step\StageInterface::class)->getMock(); - $stepVolume->expects($this->once())->method('perform')->will($this->returnValue(false)); + $stepVolume->expects($this->once())->method('perform')->willReturn(false); $this->progress->expects($this->any())->method('saveResult')->willReturnSelf(); $this->progress->expects($this->any())->method('isCompleted')->willReturn(false); @@ -112,10 +112,10 @@ public function testRunStepsDataMigrationFail() $this->expectException(\Migration\Exception::class); $this->expectExceptionMessage('Data Migration failed'); $stepIntegrity = $this->getMockBuilder(\Migration\App\Step\StageInterface::class)->getMock(); - $stepIntegrity->expects($this->once())->method('perform')->will($this->returnValue(true)); + $stepIntegrity->expects($this->once())->method('perform')->willReturn(true); $stepData = $this->getMockBuilder(\Migration\App\Step\StageInterface::class)->getMock(); - $stepData->expects($this->once())->method('perform')->will($this->returnValue(false)); + $stepData->expects($this->once())->method('perform')->willReturn(false); $stepVolume = $this->getMockBuilder(\Migration\App\Step\StageInterface::class)->getMock(); $stepVolume->expects($this->never())->method('perform'); @@ -134,13 +134,13 @@ public function testRunStepsDataMigrationFail() public function testRunStepsSuccess() { $stepIntegrity = $this->getMockBuilder(\Migration\App\Step\StageInterface::class)->getMock(); - $stepIntegrity->expects($this->once())->method('perform')->will($this->returnValue(true)); + $stepIntegrity->expects($this->once())->method('perform')->willReturn(true); $stepData = $this->getMockBuilder(\Migration\App\Step\StageInterface::class)->getMock(); - $stepData->expects($this->once())->method('perform')->will($this->returnValue(true)); + $stepData->expects($this->once())->method('perform')->willReturn(true); $stepVolume = $this->getMockBuilder(\Migration\App\Step\StageInterface::class)->getMock(); - $stepVolume->expects($this->once())->method('perform')->will($this->returnValue(true)); + $stepVolume->expects($this->once())->method('perform')->willReturn(true); $this->progress->expects($this->any())->method('saveResult')->willReturnSelf(); $this->progress->expects($this->any())->method('isCompleted')->willReturn(false); diff --git a/tests/unit/testsuite/Migration/Reader/ClassMapTest.php b/tests/unit/testsuite/Migration/Reader/ClassMapTest.php index 9bb4269b..15da8393 100644 --- a/tests/unit/testsuite/Migration/Reader/ClassMapTest.php +++ b/tests/unit/testsuite/Migration/Reader/ClassMapTest.php @@ -18,7 +18,7 @@ class ClassMapTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $config = $this->getMockBuilder(\Migration\Config::class)->disableOriginalConstructor() ->setMethods(['getOption']) diff --git a/tests/unit/testsuite/Migration/Reader/GroupsTest.php b/tests/unit/testsuite/Migration/Reader/GroupsTest.php index e0ed8927..8991c462 100644 --- a/tests/unit/testsuite/Migration/Reader/GroupsTest.php +++ b/tests/unit/testsuite/Migration/Reader/GroupsTest.php @@ -23,7 +23,7 @@ class GroupsTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->validationState = $this->getMockBuilder(\Magento\Framework\App\Arguments\ValidationState::class) ->disableOriginalConstructor() diff --git a/tests/unit/testsuite/Migration/Reader/MapTest.php b/tests/unit/testsuite/Migration/Reader/MapTest.php index 9b640849..17326746 100644 --- a/tests/unit/testsuite/Migration/Reader/MapTest.php +++ b/tests/unit/testsuite/Migration/Reader/MapTest.php @@ -18,7 +18,7 @@ class MapTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $validationState = $this->getMockBuilder(\Magento\Framework\App\Arguments\ValidationState::class) ->disableOriginalConstructor() diff --git a/tests/unit/testsuite/Migration/Reader/SettingsTest.php b/tests/unit/testsuite/Migration/Reader/SettingsTest.php index f60ad611..b0824172 100644 --- a/tests/unit/testsuite/Migration/Reader/SettingsTest.php +++ b/tests/unit/testsuite/Migration/Reader/SettingsTest.php @@ -18,7 +18,7 @@ class SettingsTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $config = $this->getConfigFile('tests/unit/testsuite/Migration/_files/settings.xml'); @@ -41,9 +41,7 @@ protected function getConfigFile($configPath) /** @var \Migration\Config|\PHPUnit_Framework_MockObject_MockObject $config */ $config = $this->getMockBuilder(\Migration\Config::class)->disableOriginalConstructor() ->setMethods(['getOption'])->getMock(); - $config->expects($this->once())->method('getOption')->with('settings_map_file')->will( - $this->returnValue($configPath) - ); + $config->expects($this->once())->method('getOption')->with('settings_map_file')->willReturn($configPath); return $config; } diff --git a/tests/unit/testsuite/Migration/RecordTransformerTest.php b/tests/unit/testsuite/Migration/RecordTransformerTest.php index 94f7dd85..e30ebcdf 100644 --- a/tests/unit/testsuite/Migration/RecordTransformerTest.php +++ b/tests/unit/testsuite/Migration/RecordTransformerTest.php @@ -83,16 +83,14 @@ protected function initHandler($document, $callNumber = 1) \Migration\Handler\Manager::class, ['initHandler', 'getHandlers'] ); - $this->handlerManagerFactory->expects($this->at($callNumber))->method('create')->will( - $this->returnValue($handlerManager) - ); + $this->handlerManagerFactory->expects($this->at($callNumber))->method('create')->willReturn($handlerManager); $structure = $this->createPartialMock( \Migration\ResourceModel\Structure::class, ['getFields'] ); - $document->expects($this->once())->method('getStructure')->will($this->returnValue($structure)); + $document->expects($this->once())->method('getStructure')->willReturn($structure); $fields = ['field1' => '', 'field2' => '', 'field3' => '',]; - $structure->expects($this->once())->method('getFields')->will($this->returnValue($fields)); + $structure->expects($this->once())->method('getFields')->willReturn($fields); $handlerManager->expects($this->any())->method('initHandler'); return $handlerManager; } @@ -117,16 +115,16 @@ public function testTransform() $this->recordTransformer->init(); $this->sourceDocument->expects($this->any())->method('getName')->willReturn('source_document_name'); $recordFrom = $this->createMock(\Migration\ResourceModel\Record::class); - $recordFrom->expects($this->any())->method('getFields')->will($this->returnValue( + $recordFrom->expects($this->any())->method('getFields')->willReturn( ['field1', 'field2', 'field3'] - )); + ); $recordFrom->expects($this->any())->method('getValue')->willReturnMap([ ['field1', 1], ['field2', 2], ['field3', 3] ]); $recordTo = $this->createMock(\Migration\ResourceModel\Record::class); - $recordTo->expects($this->any())->method('getFields')->will($this->returnValue(['field2'])); + $recordTo->expects($this->any())->method('getFields')->willReturn(['field2']); $recordTo->expects($this->any())->method('setValue')->willReturnMap([ ['field11', 1], ['field2', 2] diff --git a/tests/unit/testsuite/Migration/ResourceModel/AbstractCollectionTest.php b/tests/unit/testsuite/Migration/ResourceModel/AbstractCollectionTest.php index ca811181..678a987f 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/AbstractCollectionTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/AbstractCollectionTest.php @@ -23,11 +23,11 @@ class AbstractCollectionTest extends \PHPUnit\Framework\TestCase protected function setUp(): void { $document1 = $this->createMock(\Migration\ResourceModel\Document::class); - $document1->expects($this->any())->method('getName')->will($this->returnValue('Doc1')); + $document1->expects($this->any())->method('getName')->willReturn('Doc1'); $document2 = $this->createMock(\Migration\ResourceModel\Document::class); - $document2->expects($this->any())->method('getName')->will($this->returnValue('Doc2')); + $document2->expects($this->any())->method('getName')->willReturn('Doc2'); $document3 = $this->createMock(\Migration\ResourceModel\Document::class); - $document3->expects($this->any())->method('getName')->will($this->returnValue('Doc3')); + $document3->expects($this->any())->method('getName')->willReturn('Doc3'); $this->data = [$document1, $document2, $document3]; $this->documentCollection = new \Migration\ResourceModel\Document\Collection($this->data); } diff --git a/tests/unit/testsuite/Migration/ResourceModel/AbstractResourceTest.php b/tests/unit/testsuite/Migration/ResourceModel/AbstractResourceTest.php index 8dbf2403..9c91cf35 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/AbstractResourceTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/AbstractResourceTest.php @@ -77,7 +77,7 @@ protected function setUp(): void $this->adapterFactorySource->expects($this->any()) ->method('create') ->with(['resourceType' => 'source']) - ->will($this->returnValue($this->adapter)); + ->willReturn($this->adapter); $this->adapterFactoryDestination = $this->createPartialMock( \Migration\ResourceModel\AdapterFactory::class, ['create'] @@ -85,7 +85,7 @@ protected function setUp(): void $this->adapterFactoryDestination->expects($this->any()) ->method('create') ->with(['resourceType' => 'destination']) - ->will($this->returnValue($this->adapter)); + ->willReturn($this->adapter); $this->documentFactory = $this->getMockBuilder(\Migration\ResourceModel\DocumentFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) @@ -135,7 +135,7 @@ public function testGetDocument($prefix, $optionName) $this->documentFactory->expects($this->any()) ->method('create') ->with($this->equalTo(['structure' => $structure, 'documentName' => $resourceName])) - ->will($this->returnValue($document)); + ->willReturn($document); $this->adapter->expects($this->any()) ->method('getDocumentStructure') ->with($this->equalTo($prefix . $resourceName)) diff --git a/tests/unit/testsuite/Migration/ResourceModel/Adapter/MysqlTest.php b/tests/unit/testsuite/Migration/ResourceModel/Adapter/MysqlTest.php index ac8f8b0e..6eb486f8 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/Adapter/MysqlTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/Adapter/MysqlTest.php @@ -204,7 +204,7 @@ public function testGetTableDdlCopy() ->getMock(); $this->pdoMysql->expects($this->once())->method('createTableByDdl') ->with('source_table', 'destination_table') - ->will($this->returnValue($table)); + ->willReturn($table); $this->adapterMysql->getTableDdlCopy('source_table', 'destination_table'); } @@ -217,7 +217,7 @@ public function testCreateTableByDdl() ->setMethods(['getName']) ->disableOriginalConstructor() ->getMock(); - $table->expects($this->exactly(2))->method('getName')->will($this->returnValue('some_name')); + $table->expects($this->exactly(2))->method('getName')->willReturn('some_name'); $this->pdoMysql->expects($this->once())->method('dropTable')->with('some_name'); $this->pdoMysql->expects($this->once())->method('createTable')->with($table); $this->pdoMysql->expects($this->once())->method('resetDdlCache')->with('some_name'); @@ -235,14 +235,14 @@ public function testBackupDocument() $table = $this->getMockBuilder(\Magento\Framework\DB\Ddl\Table::class)->disableOriginalConstructor() ->setMethods(['getName']) ->getMock(); - $table->expects($this->any())->method('getName')->will($this->returnValue('migration_backup_document_name')); + $table->expects($this->any())->method('getName')->willReturn('migration_backup_document_name'); $select = $this->getMockBuilder(\Magento\Framework\DB\Select::class)->disableOriginalConstructor() ->setMethods(['from'])->getMock(); $select->expects($this->once())->method('from')->with($documentName)->willReturn($select); $this->pdoMysql->expects($this->once())->method('createTableByDdl') ->with($documentName, $backupDocumentName) - ->will($this->returnValue($table)); + ->willReturn($table); $this->pdoMysql->expects($this->once())->method('isTableExists')->willReturn(false); $this->pdoMysql->expects($this->once())->method('dropTable')->with($backupDocumentName); $this->pdoMysql->expects($this->once())->method('createTable')->with($table); diff --git a/tests/unit/testsuite/Migration/ResourceModel/AdapterFactoryTest.php b/tests/unit/testsuite/Migration/ResourceModel/AdapterFactoryTest.php index 082da7d6..ed347b97 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/AdapterFactoryTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/AdapterFactoryTest.php @@ -55,11 +55,11 @@ public function testCreate() $this->config->expects($this->once()) ->method('getOption') ->with('resource_adapter_class_name') - ->will($this->returnValue(null)); + ->willReturn(null); $this->objectManager->expects($this->once()) ->method('create') ->with(\Migration\ResourceModel\Adapter\Mysql::class, $data) - ->will($this->returnValue($adapter)); + ->willReturn($adapter); $this->assertInstanceOf($adapterClassName, $this->adapterFactory->create($data)); } } diff --git a/tests/unit/testsuite/Migration/ResourceModel/DestinationTest.php b/tests/unit/testsuite/Migration/ResourceModel/DestinationTest.php index a3dad2e7..a48c4450 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/DestinationTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/DestinationTest.php @@ -67,7 +67,7 @@ protected function setUp(): void $this->adapterFactory->expects($this->once()) ->method('create') ->with($adapterConfigs) - ->will($this->returnValue($this->adapter)); + ->willReturn($this->adapter); $this->documentFactory = $this->createMock(\Migration\ResourceModel\DocumentFactory::class); $this->structureFactory = $this->createMock(\Migration\ResourceModel\StructureFactory::class); $this->documentCollection = $this->createMock(\Migration\ResourceModel\Document\Collection::class); @@ -99,11 +99,11 @@ public function testSaveRecords($prefix) $this->adapter->expects($this->at(0)) ->method('insertRecords') ->with($prefix . $resourceName, [['data' => 'value1'], ['data' => 'value2'], ['data' => 'value3']]) - ->will($this->returnSelf()); + ->willReturnSelf(); $this->adapter->expects($this->at(1)) ->method('insertRecords') ->with($prefix . $resourceName, [['data' => 'value4']]) - ->will($this->returnSelf()); + ->willReturnSelf(); $records = $this->createMock(\Migration\ResourceModel\Record\Collection::class); $records->expects($this->any()) @@ -116,7 +116,7 @@ public function testSaveRecords($prefix) \Migration\ResourceModel\Record::class, ['getData'] ); - $record->expects($this->once())->method('getData')->will($this->returnValue($data)); + $record->expects($this->once())->method('getData')->willReturn($data); return $record; }); $records->expects($this->any()) diff --git a/tests/unit/testsuite/Migration/ResourceModel/Document/CollectionTest.php b/tests/unit/testsuite/Migration/ResourceModel/Document/CollectionTest.php index 2b081d95..166d8a72 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/Document/CollectionTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/Document/CollectionTest.php @@ -23,11 +23,11 @@ class CollectionTest extends \PHPUnit\Framework\TestCase protected function setUp(): void { $document1 = $this->createMock(\Migration\ResourceModel\Document::class); - $document1->expects($this->any())->method('getName')->will($this->returnValue('Doc1')); + $document1->expects($this->any())->method('getName')->willReturn('Doc1'); $document2 = $this->createMock(\Migration\ResourceModel\Document::class); - $document2->expects($this->any())->method('getName')->will($this->returnValue('Doc2')); + $document2->expects($this->any())->method('getName')->willReturn('Doc2'); $document3 = $this->createMock(\Migration\ResourceModel\Document::class); - $document3->expects($this->any())->method('getName')->will($this->returnValue('Doc3')); + $document3->expects($this->any())->method('getName')->willReturn('Doc3'); $this->data = [$document1, $document2, $document3]; $this->documentCollection = new \Migration\ResourceModel\Document\Collection($this->data); } @@ -67,7 +67,7 @@ public function testGetDocumentNotExists() public function testAddDocument() { $document = $this->createMock(\Migration\ResourceModel\Document::class); - $document->expects($this->any())->method('getName')->will($this->returnValue('Doc4')); + $document->expects($this->any())->method('getName')->willReturn('Doc4'); $this->documentCollection->addDocument($document); $this->assertSame($document, $this->documentCollection->getDocument('Doc4')); } diff --git a/tests/unit/testsuite/Migration/ResourceModel/DocumentTest.php b/tests/unit/testsuite/Migration/ResourceModel/DocumentTest.php index ed65c243..e9ced898 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/DocumentTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/DocumentTest.php @@ -51,7 +51,7 @@ public function testGetRecords() 'structure' => $this->structure, 'documentName' => 'test_document', ])) - ->will($this->returnValue($recordCollection)); + ->willReturn($recordCollection); $this->assertSame($recordCollection, $this->document->getRecords()); } diff --git a/tests/unit/testsuite/Migration/ResourceModel/RecordTest.php b/tests/unit/testsuite/Migration/ResourceModel/RecordTest.php index 2936f106..2aad022c 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/RecordTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/RecordTest.php @@ -30,7 +30,7 @@ protected function setUp(): void \Migration\ResourceModel\Document::class, ['getStructure'] ); - $document->expects($this->any())->method('getStructure')->will($this->returnValue($this->structure)); + $document->expects($this->any())->method('getStructure')->willReturn($this->structure); $this->record = new \Migration\ResourceModel\Record(['id' => 10, 'name' => 'item1'], $document); } @@ -184,7 +184,7 @@ public function testGetFields($structureData, $fields) \Migration\ResourceModel\Structure::class, ['getFields'] ); - $structure->expects($this->once())->method('getFields')->will($this->returnValue($structureData)); + $structure->expects($this->once())->method('getFields')->willReturn($structureData); $this->record->setStructure($structure); $this->assertEquals($fields, $this->record->getFields()); } diff --git a/tests/unit/testsuite/Migration/ResourceModel/SourceTest.php b/tests/unit/testsuite/Migration/ResourceModel/SourceTest.php index d8952079..46804488 100644 --- a/tests/unit/testsuite/Migration/ResourceModel/SourceTest.php +++ b/tests/unit/testsuite/Migration/ResourceModel/SourceTest.php @@ -92,7 +92,7 @@ protected function setUp(): void $this->adapterFactory->expects($this->once()) ->method('create') ->with($adapterConfigs) - ->will($this->returnValue($this->adapter)); + ->willReturn($this->adapter); $this->documentFactory = $this->getMockBuilder(\Migration\ResourceModel\DocumentFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() @@ -209,8 +209,8 @@ public function testGetRecordsWithOneBulkSize() ->method('create') ->with(['structure' => $this->structure, 'documentName' => $document]) ->willReturn($this->document); - $this->document->expects($this->any())->method('getStructure')->will($this->returnValue($this->structure)); - $this->structure->expects($this->any())->method('getFields')->will($this->returnValue($fields)); + $this->document->expects($this->any())->method('getStructure')->willReturn($this->structure); + $this->structure->expects($this->any())->method('getFields')->willReturn($fields); $this->resourceSource->setLastLoadedRecord($document, $records[0]); $this->assertEquals($records, $this->resourceSource->getRecords($document, 0)); } diff --git a/tests/unit/testsuite/Migration/Step/CustomCustomerAttributes/DataTest.php b/tests/unit/testsuite/Migration/Step/CustomCustomerAttributes/DataTest.php index 75c229c9..e5fba2a3 100644 --- a/tests/unit/testsuite/Migration/Step/CustomCustomerAttributes/DataTest.php +++ b/tests/unit/testsuite/Migration/Step/CustomCustomerAttributes/DataTest.php @@ -62,14 +62,12 @@ class DataTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->config = $this->getMockBuilder(\Migration\Config::class)->disableOriginalConstructor() ->setMethods(['getSource']) ->getMock(); - $this->config->expects($this->any())->method('getSource')->will( - $this->returnValue(['type' => DatabaseStage::SOURCE_TYPE]) - ); + $this->config->expects($this->any())->method('getSource')->willReturn(['type' => DatabaseStage::SOURCE_TYPE]); $this->source = $this->getMockBuilder(\Migration\ResourceModel\Source::class)->disableOriginalConstructor() ->setMethods(['getDocument', 'getRecordsCount', 'getAdapter', 'addDocumentPrefix', 'getRecords']) @@ -154,7 +152,7 @@ public function testPerform() ) ; $sourceTable = $this->getMockBuilder(\Magento\Framework\DB\Ddl\Table::class)->disableOriginalConstructor() ->setMethods(['getColumns'])->getMock(); - $sourceTable->expects($this->any())->method('getColumns')->will($this->returnValue([['asdf']])); + $sourceTable->expects($this->any())->method('getColumns')->willReturn([['asdf']]); $sourceAdapter = $this->getMockBuilder(\Migration\ResourceModel\Adapter\Mysql::class) ->disableOriginalConstructor() @@ -162,7 +160,7 @@ public function testPerform() ->getMock(); $sourceAdapter->expects($this->any())->method('getTableDdlCopy') ->with('source_suffix_source_document_1', 'destination_suffix_destination_document_1') - ->will($this->returnValue($sourceTable)); + ->willReturn($sourceTable); $destinationTable = $this->getMockBuilder(\Magento\Framework\DB\Ddl\Table::class)->disableOriginalConstructor() ->setMethods(['setColumn'])->getMock(); @@ -173,11 +171,11 @@ public function testPerform() ->getMock(); $destAdapter->expects($this->any())->method('getTableDdlCopy') ->with('destination_suffix_destination_document_1', 'destination_suffix_destination_document_1') - ->will($this->returnValue($destinationTable)); + ->willReturn($destinationTable); $destAdapter->expects($this->any())->method('createTableByDdl')->with($destinationTable); - $this->source->expects($this->once())->method('getAdapter')->will($this->returnValue($sourceAdapter)); - $this->destination->expects($this->once())->method('getAdapter')->will($this->returnValue($destAdapter)); + $this->source->expects($this->once())->method('getAdapter')->willReturn($sourceAdapter); + $this->destination->expects($this->once())->method('getAdapter')->willReturn($destAdapter); $recordsCollection = $this->getMockBuilder(\Migration\ResourceModel\Record\Collection::class) ->disableOriginalConstructor() @@ -187,25 +185,25 @@ public function testPerform() $destDocument = $this->getMockBuilder(\Migration\ResourceModel\Document::class)->disableOriginalConstructor() ->setMethods(['getRecords', 'getName']) ->getMock(); - $destDocument->expects($this->any())->method('getName')->will($this->returnValue('some_name')); - $destDocument->expects($this->any())->method('getRecords')->will($this->returnValue($recordsCollection)); + $destDocument->expects($this->any())->method('getName')->willReturn('some_name'); + $destDocument->expects($this->any())->method('getRecords')->willReturn($recordsCollection); $record = $this->getMockBuilder(\Migration\ResourceModel\Record::class)->disableOriginalConstructor() ->setMethods(['setData']) ->getMock(); $record->expects($this->once())->method('setData')->with(['field_1' => 1, 'field_2' => 2]); $this->recordFactory->expects($this->any())->method('create')->with(['document' => $destDocument]) - ->will($this->returnValue($record)); + ->willReturn($record); $recordsCollection->expects($this->any())->method('addRecord')->with($record); - $this->destination->expects($this->any())->method('getDocument')->will($this->returnValue($destDocument)); + $this->destination->expects($this->any())->method('getDocument')->willReturn($destDocument); $this->logger->expects($this->any())->method('debug')->with('migrating', ['table' => 'source_document_1']) ->willReturn(true); - $this->source->expects($this->any())->method('getRecords')->will($this->returnValueMap( + $this->source->expects($this->any())->method('getRecords')->willReturnMap( [ ['source_document_1', 0, null, [['field_1' => 1, 'field_2' => 2]]] ] - )); + ); $this->assertTrue($this->step->perform()); } diff --git a/tests/unit/testsuite/Migration/Step/CustomCustomerAttributes/IntegrityTest.php b/tests/unit/testsuite/Migration/Step/CustomCustomerAttributes/IntegrityTest.php index 7821bcf8..0a9f702f 100644 --- a/tests/unit/testsuite/Migration/Step/CustomCustomerAttributes/IntegrityTest.php +++ b/tests/unit/testsuite/Migration/Step/CustomCustomerAttributes/IntegrityTest.php @@ -51,7 +51,7 @@ class IntegrityTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->logger = $this->createPartialMock( \Migration\Logger\Logger::class, @@ -120,15 +120,15 @@ public function testPerform() $structure = $this->getMockBuilder(\Migration\ResourceModel\Structure::class) ->disableOriginalConstructor()->setMethods([])->getMock(); - $structure->expects($this->any())->method('getFields')->will($this->returnValue($fields)); + $structure->expects($this->any())->method('getFields')->willReturn($fields); $this->source->expects($this->atLeastOnce())->method('getDocumentList') - ->will($this->returnValue(['document1'])); + ->willReturn(['document1']); $this->destination->expects($this->atLeastOnce())->method('getDocumentList') - ->will($this->returnValue(['document2'])); + ->willReturn(['document2']); $document = $this->getMockBuilder(\Migration\ResourceModel\Document::class) ->disableOriginalConstructor() ->getMock(); - $document->expects($this->any())->method('getStructure')->will($this->returnValue($structure)); + $document->expects($this->any())->method('getStructure')->willReturn($structure); $this->map->expects($this->any())->method('getDocumentMap')->willReturnMap( [ @@ -137,9 +137,9 @@ public function testPerform() ] ) ; - $this->source->expects($this->any())->method('getDocument')->will($this->returnValue($document)); - $this->destination->expects($this->any())->method('getDocument')->will($this->returnValue($document)); - $this->map->expects($this->any())->method('getFieldMap')->will($this->returnValue('field1')); + $this->source->expects($this->any())->method('getDocument')->willReturn($document); + $this->destination->expects($this->any())->method('getDocument')->willReturn($document); + $this->map->expects($this->any())->method('getFieldMap')->willReturn('field1'); $this->logger->expects($this->never())->method('error'); $this->assertTrue($this->log->perform()); diff --git a/tests/unit/testsuite/Migration/Step/CustomCustomerAttributes/VolumeTest.php b/tests/unit/testsuite/Migration/Step/CustomCustomerAttributes/VolumeTest.php index bbf574df..5c720b8d 100644 --- a/tests/unit/testsuite/Migration/Step/CustomCustomerAttributes/VolumeTest.php +++ b/tests/unit/testsuite/Migration/Step/CustomCustomerAttributes/VolumeTest.php @@ -52,7 +52,7 @@ class VolumeTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->logger = $this->createPartialMock( \Migration\Logger\Logger::class, @@ -117,12 +117,12 @@ public function testPerform() $structure = $this->getMockBuilder(\Migration\ResourceModel\Structure::class) ->disableOriginalConstructor()->setMethods([])->getMock(); - $structure->expects($this->any())->method('getFields')->will($this->returnValue($fields)); + $structure->expects($this->any())->method('getFields')->willReturn($fields); $document = $this->getMockBuilder(\Migration\ResourceModel\Document::class) ->disableOriginalConstructor() ->getMock(); - $document->expects($this->any())->method('getStructure')->will($this->returnValue($structure)); + $document->expects($this->any())->method('getStructure')->willReturn($structure); $this->map->expects($this->once())->method('getDocumentMap')->with('document1')->willReturn('document2'); $this->source->expects($this->once())->method('getRecordsCount')->willReturn(3); diff --git a/tests/unit/testsuite/Migration/Step/Eav/HelperTest.php b/tests/unit/testsuite/Migration/Step/Eav/HelperTest.php index cc4c68e0..36bde0bd 100644 --- a/tests/unit/testsuite/Migration/Step/Eav/HelperTest.php +++ b/tests/unit/testsuite/Migration/Step/Eav/HelperTest.php @@ -69,7 +69,7 @@ class HelperTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->map = $this->getMockBuilder(\Migration\Reader\Map::class)->disableOriginalConstructor() ->setMethods(['getDocumentMap']) @@ -131,7 +131,7 @@ public function setUp() public function testGetSourceRecordsCount() { $this->source->expects($this->once())->method('getRecordsCount')->with('some_document') - ->will($this->returnValue(5)); + ->willReturn(5); $this->assertEquals(5, $this->helper->getSourceRecordsCount('some_document')); } @@ -142,9 +142,9 @@ public function testGetDestinationRecordsCount() { $this->map->expects($this->once())->method('getDocumentMap') ->with('some_document', MapInterface::TYPE_SOURCE) - ->will($this->returnValue('some_dest_document')); + ->willReturn('some_dest_document'); $this->destination->expects($this->once())->method('getRecordsCount')->with('some_dest_document') - ->will($this->returnValue(5)); + ->willReturn(5); $this->assertEquals(5, $this->helper->getDestinationRecordsCount('some_document')); } @@ -153,9 +153,9 @@ public function testGetDestinationRecordsCount() */ public function testGetSourceRecords() { - $this->source->expects($this->once())->method('getRecordsCount')->will($this->returnValue(1)); + $this->source->expects($this->once())->method('getRecordsCount')->willReturn(1); $this->source->expects($this->once())->method('getRecords')->with('test_source_document', 0, 1) - ->will($this->returnValue([['key' => 'key_value', 'field' => 'field_value']])); + ->willReturn([['key' => 'key_value', 'field' => 'field_value']]); $result = [ 'key_value-field_value' => ['key' => 'key_value', 'field' => 'field_value'] @@ -171,10 +171,10 @@ public function testGetDestinationRecords() { $this->map->expects($this->once())->method('getDocumentMap') ->with('test_source_document', MapInterface::TYPE_SOURCE) - ->will($this->returnValue('test_dest_document')); - $this->destination->expects($this->once())->method('getRecordsCount')->will($this->returnValue(1)); + ->willReturn('test_dest_document'); + $this->destination->expects($this->once())->method('getRecordsCount')->willReturn(1); $this->destination->expects($this->once())->method('getRecords')->with('test_dest_document', 0, 1) - ->will($this->returnValue([['key' => 'key_value', 'field' => 'field_value']])); + ->willReturn([['key' => 'key_value', 'field' => 'field_value']]); $result = [ 'key_value-field_value' => ['key' => 'key_value', 'field' => 'field_value'] @@ -188,9 +188,9 @@ public function testGetDestinationRecords() public function testGetSourceRecordsNoKey() { $row = ['key' => 'key_value', 'field' => 'field_value']; - $this->source->expects($this->once())->method('getRecordsCount')->will($this->returnValue(1)); + $this->source->expects($this->once())->method('getRecordsCount')->willReturn(1); $this->source->expects($this->once())->method('getRecords')->with('test_source_document', 0, 1) - ->will($this->returnValue([$row])); + ->willReturn([$row]); $this->assertEquals([$row], $this->helper->getSourceRecords('test_source_document')); } @@ -203,10 +203,10 @@ public function testGetDestinationRecordsNoKey() $row = ['key' => 'key_value', 'field' => 'field_value']; $this->map->expects($this->once())->method('getDocumentMap') ->with('test_source_document', MapInterface::TYPE_SOURCE) - ->will($this->returnValue('test_dest_document')); - $this->destination->expects($this->once())->method('getRecordsCount')->will($this->returnValue(1)); + ->willReturn('test_dest_document'); + $this->destination->expects($this->once())->method('getRecordsCount')->willReturn(1); $this->destination->expects($this->once())->method('getRecords')->with('test_dest_document', 0, 1) - ->will($this->returnValue([$row])); + ->willReturn([$row]); $this->assertEquals([$row], $this->helper->getDestinationRecords('test_source_document')); } @@ -232,9 +232,9 @@ public function testGetRecordTransformer() 'destDocument' => $destinationDocument, 'mapReader' => $this->map ] - )->will($this->returnValue($recordTransformer)); + )->willReturn($recordTransformer); - $recordTransformer->expects($this->once())->method('init')->will($this->returnSelf()); + $recordTransformer->expects($this->once())->method('init')->willReturnSelf(); $this->assertSame( $recordTransformer, @@ -251,7 +251,7 @@ public function testDeleteBackups() ->willReturn(['some_document' => 0]); $this->map->expects($this->once())->method('getDocumentMap') ->with('some_document', MapInterface::TYPE_SOURCE) - ->will($this->returnValue('some_dest_document')); + ->willReturn('some_dest_document'); $this->destination->expects($this->once())->method('deleteDocumentBackup')->with('some_dest_document'); $this->helper->deleteBackups(); } @@ -304,16 +304,16 @@ public function testClearIgnoredAttributes() ->expects($this->once()) ->method('from') ->with($eavEntityTypeTable, ['entity_type_code', 'entity_type_id']) - ->will($this->returnSelf()); + ->willReturnSelf(); $this->select ->expects($this->once()) ->method('getAdapter') - ->will($this->returnValue($this->pdoMysql)); + ->willReturn($this->pdoMysql); $this->pdoMysql ->expects($this->once()) ->method('fetchPairs') ->with($this->select) - ->will($this->returnValue($entityTypesCodeToId)); + ->willReturn($entityTypesCodeToId); $this->assertEquals($clearedSourceRecords, $this->helper->clearIgnoredAttributes($allSourceRecords)); } } diff --git a/tests/unit/testsuite/Migration/Step/Eav/InitialDataTest.php b/tests/unit/testsuite/Migration/Step/Eav/InitialDataTest.php index feb4b7e9..cc08438c 100644 --- a/tests/unit/testsuite/Migration/Step/Eav/InitialDataTest.php +++ b/tests/unit/testsuite/Migration/Step/Eav/InitialDataTest.php @@ -38,7 +38,7 @@ class InitialDataTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->map = $this->getMockBuilder(\Migration\Reader\Map::class)->disableOriginalConstructor() ->setMethods([]) diff --git a/tests/unit/testsuite/Migration/Step/Eav/IntegrityTest.php b/tests/unit/testsuite/Migration/Step/Eav/IntegrityTest.php index 49de20e0..85112bf6 100644 --- a/tests/unit/testsuite/Migration/Step/Eav/IntegrityTest.php +++ b/tests/unit/testsuite/Migration/Step/Eav/IntegrityTest.php @@ -65,7 +65,7 @@ class IntegrityTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->progress = $this->getMockBuilder(\Migration\App\ProgressBar\LogLevelProcessor::class) ->disableOriginalConstructor() @@ -158,20 +158,20 @@ public function testPerformWithoutError() $structure = $this->getMockBuilder(\Migration\ResourceModel\Structure::class) ->disableOriginalConstructor()->setMethods([])->getMock(); - $structure->expects($this->any())->method('getFields')->will($this->returnValue($fields)); + $structure->expects($this->any())->method('getFields')->willReturn($fields); $document = $this->getMockBuilder(\Migration\ResourceModel\Document::class) ->disableOriginalConstructor() ->getMock(); - $document->expects($this->any())->method('getStructure')->will($this->returnValue($structure)); + $document->expects($this->any())->method('getStructure')->willReturn($structure); - $this->source->expects($this->any())->method('getDocument')->will($this->returnValue($document)); + $this->source->expects($this->any())->method('getDocument')->willReturn($document); $this->source->expects($this->atLeastOnce())->method('getDocumentList') - ->will($this->returnValue(['source_document'])); + ->willReturn(['source_document']); $this->destination->expects($this->atLeastOnce())->method('getDocumentList') - ->will($this->returnValue(['destination_document'])); - $this->destination->expects($this->atLeastOnce())->method('getDocument')->will($this->returnValue($document)); + ->willReturn(['destination_document']); + $this->destination->expects($this->atLeastOnce())->method('getDocument')->willReturn($document); $this->logger->expects($this->never())->method('addRecord'); $this->readerGroups->expects($this->any())->method('getGroup')->with('documents') @@ -196,19 +196,19 @@ public function testPerformWithError() ) ; $structure = $this->getMockBuilder(\Migration\ResourceModel\Structure::class) ->disableOriginalConstructor()->setMethods([])->getMock(); - $structure->expects($this->any())->method('getFields')->will($this->returnValue($fields)); + $structure->expects($this->any())->method('getFields')->willReturn($fields); $document = $this->getMockBuilder(\Migration\ResourceModel\Document::class) ->disableOriginalConstructor() ->getMock(); - $document->expects($this->any())->method('getStructure')->will($this->returnValue($structure)); + $document->expects($this->any())->method('getStructure')->willReturn($structure); $this->source->expects($this->atLeastOnce())->method('getDocumentList') - ->will($this->returnValue(['source_document', 'common_document'])); + ->willReturn(['source_document', 'common_document']); $this->source->expects($this->atLeastOnce())->method('getDocument')->willReturn($document); $this->destination->expects($this->atLeastOnce())->method('getDocumentList') - ->will($this->returnValue(['common_document'])); + ->willReturn(['common_document']); $this->destination->expects($this->atLeastOnce())->method('getDocument')->willReturn($document); $this->logger->expects($this->once())->method('addRecord') diff --git a/tests/unit/testsuite/Migration/Step/Eav/Model/IgnoredAttributesTest.php b/tests/unit/testsuite/Migration/Step/Eav/Model/IgnoredAttributesTest.php index 6dd78860..139dea61 100644 --- a/tests/unit/testsuite/Migration/Step/Eav/Model/IgnoredAttributesTest.php +++ b/tests/unit/testsuite/Migration/Step/Eav/Model/IgnoredAttributesTest.php @@ -31,7 +31,7 @@ class IgnoredAttributesTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->helper = $this->getMockBuilder(\Migration\Step\Eav\Helper::class)->disableOriginalConstructor() ->setMethods(['getAttributesGroupCodes']) diff --git a/tests/unit/testsuite/Migration/Step/Eav/VolumeTest.php b/tests/unit/testsuite/Migration/Step/Eav/VolumeTest.php index 88f2fb92..66d60fd7 100644 --- a/tests/unit/testsuite/Migration/Step/Eav/VolumeTest.php +++ b/tests/unit/testsuite/Migration/Step/Eav/VolumeTest.php @@ -53,7 +53,7 @@ class VolumeTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->initialData = $this->getMockBuilder(\Migration\Step\Eav\InitialData::class)->disableOriginalConstructor() ->setMethods(['getAttributes', 'getAttributeSets', 'getAttributeGroups']) diff --git a/tests/unit/testsuite/Migration/Step/Log/DataTest.php b/tests/unit/testsuite/Migration/Step/Log/DataTest.php index a5a5f793..0a0b9285 100644 --- a/tests/unit/testsuite/Migration/Step/Log/DataTest.php +++ b/tests/unit/testsuite/Migration/Step/Log/DataTest.php @@ -67,7 +67,7 @@ class DataTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->progress = $this->createPartialMock( \Migration\App\ProgressBar\LogLevelProcessor::class, @@ -114,7 +114,7 @@ public function setUp() $this->sourceAdapter->expects($this->any())->method('getSelect')->willReturn($select); $this->source->expects($this->any())->method('getAdapter')->willReturn($this->sourceAdapter); - $this->source->expects($this->any())->method('addDocumentPrefix')->willReturn($this->returnArgument(1)); + $this->source->expects($this->any())->method('addDocumentPrefix')->willReturnArgument(0); $this->source->expects($this->any())->method('getPageSize')->willReturn(100); /** @var \Migration\Reader\MapFactory|\PHPUnit_Framework_MockObject_MockObject $mapFactory */ $mapFactory = $this->createMock(\Migration\Reader\MapFactory::class); @@ -161,19 +161,17 @@ public function setUp() public function testPerform() { $sourceDocName = 'core_config_data'; - $this->source->expects($this->any())->method('getDocumentList')->will($this->returnValue([$sourceDocName])); + $this->source->expects($this->any())->method('getDocumentList')->willReturn([$sourceDocName]); $dstDocName = 'config_data'; - $this->map->expects($this->once())->method('getDocumentMap')->will($this->returnValue($dstDocName)); + $this->map->expects($this->once())->method('getDocumentMap')->willReturn($dstDocName); $sourceDocument = $this->createPartialMock( \Migration\ResourceModel\Document::class, ['getRecords'] ); - $this->source->expects($this->once())->method('getDocument')->will($this->returnValue($sourceDocument)); + $this->source->expects($this->once())->method('getDocument')->willReturn($sourceDocument); $destinationDocument = $this->createMock(\Migration\ResourceModel\Document::class); - $this->destination->expects($this->once())->method('getDocument')->will( - $this->returnValue($destinationDocument) - ); + $this->destination->expects($this->once())->method('getDocument')->willReturn($destinationDocument); $this->sourceAdapter ->expects($this->at(1)) @@ -191,9 +189,9 @@ public function testPerform() $destinationRecords = $this->createMock(\Migration\ResourceModel\Record\Collection::class); $destinationDocument->expects($this->once())->method('getRecords') - ->will($this->returnValue($destinationRecords)); + ->willReturn($destinationRecords); $srcRecord = $this->createMock(\Migration\ResourceModel\Record::class); - $this->recordFactory->expects($this->at(0))->method('create')->will($this->returnValue($srcRecord)); + $this->recordFactory->expects($this->at(0))->method('create')->willReturn($srcRecord); $this->destination->expects($this->once())->method('saveRecords')->with($dstDocName, $destinationRecords); $this->destination->expects($this->exactly(2))->method('clearDocument'); @@ -211,7 +209,7 @@ public function testGetMapEmptyDestinationDocumentName() \Migration\ResourceModel\Document::class, ['getRecords'] ); - $this->source->expects($this->once())->method('getDocument')->will($this->returnValue($sourceDocument)); + $this->source->expects($this->once())->method('getDocument')->willReturn($sourceDocument); $this->data->perform(); } diff --git a/tests/unit/testsuite/Migration/Step/Log/IntegrityTest.php b/tests/unit/testsuite/Migration/Step/Log/IntegrityTest.php index cd6e7be8..653c9a0b 100644 --- a/tests/unit/testsuite/Migration/Step/Log/IntegrityTest.php +++ b/tests/unit/testsuite/Migration/Step/Log/IntegrityTest.php @@ -51,7 +51,7 @@ class IntegrityTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->logger = $this->createPartialMock( \Migration\Logger\Logger::class, @@ -120,15 +120,15 @@ public function testPerformMainFlow() $structure = $this->getMockBuilder(\Migration\ResourceModel\Structure::class) ->disableOriginalConstructor()->setMethods([])->getMock(); - $structure->expects($this->any())->method('getFields')->will($this->returnValue($fields)); + $structure->expects($this->any())->method('getFields')->willReturn($fields); $this->source->expects($this->atLeastOnce())->method('getDocumentList') - ->will($this->returnValue(['document1'])); + ->willReturn(['document1']); $this->destination->expects($this->atLeastOnce())->method('getDocumentList') - ->will($this->returnValue(['document2', 'document_to_clear'])); + ->willReturn(['document2', 'document_to_clear']); $document = $this->getMockBuilder(\Migration\ResourceModel\Document::class) ->disableOriginalConstructor() ->getMock(); - $document->expects($this->any())->method('getStructure')->will($this->returnValue($structure)); + $document->expects($this->any())->method('getStructure')->willReturn($structure); $this->map->expects($this->any())->method('getDocumentMap')->willReturnMap( [ @@ -137,9 +137,9 @@ public function testPerformMainFlow() ] ); - $this->source->expects($this->any())->method('getDocument')->will($this->returnValue($document)); - $this->destination->expects($this->any())->method('getDocument')->will($this->returnValue($document)); - $this->map->expects($this->any())->method('getFieldMap')->will($this->returnValue('field1')); + $this->source->expects($this->any())->method('getDocument')->willReturn($document); + $this->destination->expects($this->any())->method('getDocument')->willReturn($document); + $this->map->expects($this->any())->method('getFieldMap')->willReturn('field1'); $this->logger->expects($this->never())->method('addRecord'); $this->assertTrue($this->log->perform()); @@ -155,15 +155,15 @@ public function testPerformMissingDocument() $structure = $this->getMockBuilder(\Migration\ResourceModel\Structure::class) ->disableOriginalConstructor()->setMethods([])->getMock(); - $structure->expects($this->any())->method('getFields')->will($this->returnValue($fields)); + $structure->expects($this->any())->method('getFields')->willReturn($fields); $this->source->expects($this->atLeastOnce())->method('getDocumentList') - ->will($this->returnValue(['document1'])); + ->willReturn(['document1']); $this->destination->expects($this->atLeastOnce())->method('getDocumentList') - ->will($this->returnValue(['document2'])); + ->willReturn(['document2']); $document = $this->getMockBuilder(\Migration\ResourceModel\Document::class) ->disableOriginalConstructor() ->getMock(); - $document->expects($this->any())->method('getStructure')->will($this->returnValue($structure)); + $document->expects($this->any())->method('getStructure')->willReturn($structure); $this->map->expects($this->any())->method('getDocumentMap')->willReturnMap( [ @@ -172,9 +172,9 @@ public function testPerformMissingDocument() ] ); - $this->source->expects($this->any())->method('getDocument')->will($this->returnValue($document)); - $this->destination->expects($this->any())->method('getDocument')->will($this->returnValue($document)); - $this->map->expects($this->any())->method('getFieldMap')->will($this->returnValue('field1')); + $this->source->expects($this->any())->method('getDocument')->willReturn($document); + $this->destination->expects($this->any())->method('getDocument')->willReturn($document); + $this->map->expects($this->any())->method('getFieldMap')->willReturn('field1'); $this->logger ->expects($this->once()) ->method('addRecord') diff --git a/tests/unit/testsuite/Migration/Step/Log/VolumeTest.php b/tests/unit/testsuite/Migration/Step/Log/VolumeTest.php index fdc684bb..81391c01 100644 --- a/tests/unit/testsuite/Migration/Step/Log/VolumeTest.php +++ b/tests/unit/testsuite/Migration/Step/Log/VolumeTest.php @@ -52,7 +52,7 @@ class VolumeTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->logger = $this->createPartialMock( \Migration\Logger\Logger::class, diff --git a/tests/unit/testsuite/Migration/Step/Map/DataTest.php b/tests/unit/testsuite/Migration/Step/Map/DataTest.php index 421b1f6f..282581c3 100644 --- a/tests/unit/testsuite/Migration/Step/Map/DataTest.php +++ b/tests/unit/testsuite/Migration/Step/Map/DataTest.php @@ -74,7 +74,7 @@ class DataTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->progressBar = $this->createPartialMock( \Migration\App\ProgressBar\LogLevelProcessor::class, @@ -147,8 +147,8 @@ public function setUp() public function testGetMapEmptyDestinationDocumentName() { $sourceDocName = 'core_config_data'; - $this->progress->expects($this->once())->method('getProcessedEntities')->will($this->returnValue([])); - $this->source->expects($this->any())->method('getDocumentList')->will($this->returnValue([$sourceDocName])); + $this->progress->expects($this->once())->method('getProcessedEntities')->willReturn([]); + $this->source->expects($this->any())->method('getDocumentList')->willReturn([$sourceDocName]); $this->data->perform(); } @@ -158,27 +158,23 @@ public function testGetMapEmptyDestinationDocumentName() public function testPerform() { $sourceDocName = 'core_config_data'; - $this->source->expects($this->any())->method('getDocumentList')->will($this->returnValue([$sourceDocName])); - $this->source->expects($this->any())->method('getRecordsCount')->will($this->returnValue(2)); + $this->source->expects($this->any())->method('getDocumentList')->willReturn([$sourceDocName]); + $this->source->expects($this->any())->method('getRecordsCount')->willReturn(2); $dstDocName = 'config_data'; - $this->progress->expects($this->once())->method('getProcessedEntities')->will($this->returnValue([])); - $this->map->expects($this->once())->method('getDocumentMap')->will($this->returnValue($dstDocName)); + $this->progress->expects($this->once())->method('getProcessedEntities')->willReturn([]); + $this->map->expects($this->once())->method('getDocumentMap')->willReturn($dstDocName); $this->map->expects($this->any())->method('getHandlerConfigs')->willReturn(['class' => 'Handler\Class']); $sourceDocument = $this->createPartialMock( \Migration\ResourceModel\Document::class, ['getRecords', 'getStructure'] ); - $this->source->expects($this->once())->method('getDocument')->will( - $this->returnValue($sourceDocument) - ); + $this->source->expects($this->once())->method('getDocument')->willReturn($sourceDocument); $destinationDocument = $this->getMockBuilder(\Migration\ResourceModel\Document::class) ->disableOriginalConstructor() ->setMethods(['getStructure', 'getRecords']) ->getMock(); - $this->destination->expects($this->once())->method('getDocument')->will( - $this->returnValue($destinationDocument) - ); + $this->destination->expects($this->once())->method('getDocument')->willReturn($destinationDocument); $structure = $this->getMockBuilder(\Migration\ResourceModel\Structure::class)->disableOriginalConstructor() ->setMethods(['getFields']) ->getMock(); @@ -191,9 +187,7 @@ public function testPerform() \Migration\RecordTransformer::class, ['init', 'transform'] ); - $this->recordTransformerFactory->expects($this->once())->method('create')->will( - $this->returnValue($recordTransformer) - ); + $this->recordTransformerFactory->expects($this->once())->method('create')->willReturn($recordTransformer); $recordTransformer->expects($this->once())->method('init'); $bulk = [['id' => 4, 'name' => 'john']]; @@ -205,14 +199,12 @@ public function testPerform() $this->source->expects($this->any())->method('getPageSize')->willReturn(100); $destinationRecords = $this->createMock(\Migration\ResourceModel\Record\Collection::class); - $destinationDocument->expects($this->once())->method('getRecords')->will( - $this->returnValue($destinationRecords) - ); + $destinationDocument->expects($this->once())->method('getRecords')->willReturn($destinationRecords); $srcRecord = $this->createMock(\Migration\ResourceModel\Record::class); $dstRecord = $this->createMock(\Migration\ResourceModel\Record::class); - $this->recordFactory->expects($this->at(0))->method('create')->will($this->returnValue($srcRecord)); - $this->recordFactory->expects($this->at(1))->method('create')->will($this->returnValue($dstRecord)); + $this->recordFactory->expects($this->at(0))->method('create')->willReturn($srcRecord); + $this->recordFactory->expects($this->at(1))->method('create')->willReturn($dstRecord); $recordTransformer->expects($this->once())->method('transform')->with($srcRecord, $dstRecord); $this->destination->expects($this->once())->method('saveRecords')->with($dstDocName, $destinationRecords); @@ -230,11 +222,11 @@ public function testPerform() public function testPerformJustCopy() { $sourceDocName = 'core_config_data'; - $this->source->expects($this->any())->method('getDocumentList')->will($this->returnValue([$sourceDocName])); - $this->source->expects($this->any())->method('getRecordsCount')->will($this->returnValue(2)); + $this->source->expects($this->any())->method('getDocumentList')->willReturn([$sourceDocName]); + $this->source->expects($this->any())->method('getRecordsCount')->willReturn(2); $dstDocName = 'config_data'; - $this->progress->expects($this->once())->method('getProcessedEntities')->will($this->returnValue([])); - $this->map->expects($this->once())->method('getDocumentMap')->will($this->returnValue($dstDocName)); + $this->progress->expects($this->once())->method('getProcessedEntities')->willReturn([]); + $this->map->expects($this->once())->method('getDocumentMap')->willReturn($dstDocName); $this->map->expects($this->any())->method('getHandlerConfigs')->willReturn([]); $sourceDocument = $this->createPartialMock( @@ -253,9 +245,7 @@ public function testPerformJustCopy() ->disableOriginalConstructor() ->setMethods(['getStructure', 'getRecords']) ->getMock(); - $this->destination->expects($this->once())->method('getDocument')->will( - $this->returnValue($destinationDocument) - ); + $this->destination->expects($this->once())->method('getDocument')->willReturn($destinationDocument); $structure = $this->getMockBuilder(\Migration\ResourceModel\Structure::class) ->disableOriginalConstructor() ->setMethods(['getFields']) @@ -266,12 +256,10 @@ public function testPerformJustCopy() $destinationDocument->expects($this->any())->method('getStructure')->willReturn($structure); $destinationRecords = $this->createMock(\Migration\ResourceModel\Record\Collection::class); - $destinationDocument->expects($this->once())->method('getRecords')->will( - $this->returnValue($destinationRecords) - ); + $destinationDocument->expects($this->once())->method('getRecords')->willReturn($destinationRecords); $dstRecord = $this->createMock(\Migration\ResourceModel\Record::class); - $this->recordFactory->expects($this->at(0))->method('create')->will($this->returnValue($dstRecord)); + $this->recordFactory->expects($this->at(0))->method('create')->willReturn($dstRecord); $this->destination->expects($this->once())->method('saveRecords')->with($dstDocName, $destinationRecords); $this->destination->expects($this->once())->method('clearDocument')->with($dstDocName); diff --git a/tests/unit/testsuite/Migration/Step/Map/DeltaTest.php b/tests/unit/testsuite/Migration/Step/Map/DeltaTest.php index 4174fe31..dd644cca 100644 --- a/tests/unit/testsuite/Migration/Step/Map/DeltaTest.php +++ b/tests/unit/testsuite/Migration/Step/Map/DeltaTest.php @@ -62,7 +62,7 @@ class DeltaTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->source = $this->createMock(\Migration\ResourceModel\Source::class); $this->logger = $this->createMock(\Migration\Logger\Logger::class); diff --git a/tests/unit/testsuite/Migration/Step/Map/HelperTest.php b/tests/unit/testsuite/Migration/Step/Map/HelperTest.php index 3929abc8..c5e275eb 100644 --- a/tests/unit/testsuite/Migration/Step/Map/HelperTest.php +++ b/tests/unit/testsuite/Migration/Step/Map/HelperTest.php @@ -32,7 +32,7 @@ class HelperTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->groups = $this->getMockBuilder(\Migration\Reader\Groups::class) ->disableOriginalConstructor() diff --git a/tests/unit/testsuite/Migration/Step/Map/IntegrityTest.php b/tests/unit/testsuite/Migration/Step/Map/IntegrityTest.php index cf9bcde7..86372186 100644 --- a/tests/unit/testsuite/Migration/Step/Map/IntegrityTest.php +++ b/tests/unit/testsuite/Migration/Step/Map/IntegrityTest.php @@ -53,7 +53,7 @@ class IntegrityTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->logger = $this->createPartialMock( \Migration\Logger\Logger::class, @@ -98,14 +98,14 @@ public function testPerformMainFlow() { $this->setupFieldsValidation(); - $this->source->expects($this->any())->method('getDocumentList')->will($this->returnValue(['document'])); + $this->source->expects($this->any())->method('getDocumentList')->willReturn(['document']); $this->destination->expects($this->any())->method('getDocumentList') - ->will($this->returnValue(['document'])); + ->willReturn(['document']); - $this->map->expects($this->any())->method('getDocumentMap')->will($this->returnArgument(0)); + $this->map->expects($this->any())->method('getDocumentMap')->willReturnArgument(0); $this->map->expects($this->any())->method('isDocumentIgnored')->willReturn(false); - $this->map->expects($this->any())->method('getFieldMap')->will($this->returnValue('field1')); + $this->map->expects($this->any())->method('getFieldMap')->willReturn('field1'); $this->logger->expects($this->never())->method('addRecord'); @@ -117,10 +117,10 @@ public function testPerformMainFlow() */ public function testPerformDocumentIgnored() { - $this->source->expects($this->atLeastOnce())->method('getDocumentList')->will($this->returnValue(['document'])); + $this->source->expects($this->atLeastOnce())->method('getDocumentList')->willReturn(['document']); $this->destination->expects($this->atLeastOnce())->method('getDocumentList') - ->will($this->returnValue(['document2'])); - $this->map->expects($this->any())->method('getDocumentMap')->will($this->returnValue(false)); + ->willReturn(['document2']); + $this->map->expects($this->any())->method('getDocumentMap')->willReturn(false); $this->map->expects($this->any())->method('isDocumentIgnored')->willReturn(true); $this->logger->expects($this->never())->method('addRecord'); $this->integrity->perform(); @@ -133,10 +133,10 @@ public function testPerformWithDestinationDocMissed() { $this->setupFieldsValidation(); $this->source->expects($this->atLeastOnce())->method('getDocumentList') - ->will($this->returnValue(['document1', 'document2'])); + ->willReturn(['document1', 'document2']); $this->destination->expects($this->atLeastOnce())->method('getDocumentList') - ->will($this->returnValue(['document2'])); - $this->map->expects($this->any())->method('getDocumentMap')->will($this->returnArgument(0)); + ->willReturn(['document2']); + $this->map->expects($this->any())->method('getDocumentMap')->willReturnArgument(0); $this->map->expects($this->any())->method('isDocumentIgnored')->willReturn(false); $this->logger->expects($this->exactly(1))->method('addRecord') ->with(400, 'Source documents are not mapped: document1'); @@ -153,8 +153,8 @@ public function testPerformWithSourceDocMissed() $this->source->expects($this->atLeastOnce())->method('getDocumentList') ->willReturn(['document2']); $this->destination->expects($this->atLeastOnce())->method('getDocumentList') - ->will($this->returnValue(['document1', 'document2'])); - $this->map->expects($this->any())->method('getDocumentMap')->will($this->returnArgument(0)); + ->willReturn(['document1', 'document2']); + $this->map->expects($this->any())->method('getDocumentMap')->willReturnArgument(0); $this->logger->expects($this->once())->method('addRecord') ->with(400, 'Destination documents are not mapped: document1'); @@ -170,10 +170,10 @@ public function testPerformWithSourceFieldErrors() ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $structure->expects($this->at(0))->method('getFields')->will($this->returnValue(['field1' => []])); - $structure->expects($this->at(1))->method('getFields')->will($this->returnValue(['field2' => []])); - $structure->expects($this->at(2))->method('getFields')->will($this->returnValue(['field2' => []])); - $structure->expects($this->at(3))->method('getFields')->will($this->returnValue(['field1' => []])); + $structure->expects($this->at(0))->method('getFields')->willReturn(['field1' => []]); + $structure->expects($this->at(1))->method('getFields')->willReturn(['field2' => []]); + $structure->expects($this->at(2))->method('getFields')->willReturn(['field2' => []]); + $structure->expects($this->at(3))->method('getFields')->willReturn(['field1' => []]); $document = $this->getMockBuilder(\Migration\ResourceModel\Document::class) ->disableOriginalConstructor() @@ -181,21 +181,21 @@ public function testPerformWithSourceFieldErrors() $document->expects($this->any())->method('getStructure')->willReturn($structure); $document->expects($this->any())->method('getName')->willReturn('document'); - $this->source->expects($this->atLeastOnce())->method('getDocumentList')->will($this->returnValue(['document'])); + $this->source->expects($this->atLeastOnce())->method('getDocumentList')->willReturn(['document']); $this->destination->expects($this->atLeastOnce())->method('getDocumentList') - ->will($this->returnValue(['document'])); + ->willReturn(['document']); - $this->source->expects($this->any())->method('getDocument')->will($this->returnValue($document)); + $this->source->expects($this->any())->method('getDocument')->willReturn($document); $this->destination->expects($this->any())->method('getDocument')->with('document') - ->will($this->returnValue($document)); + ->willReturn($document); $this->map->expects($this->any())->method('isDocumentIgnored')->willReturn(false); $this->map->expects($this->exactly(2))->method('getDocumentMap')->with('document') - ->will($this->returnArgument(0)); + ->willReturnArgument(0); $this->map->expects($this->at(2))->method('getFieldMap')->with('document', 'field1') - ->will($this->returnValue('field1')); + ->willReturn('field1'); $this->map->expects($this->at(5))->method('getFieldMap')->with('document', 'field2') - ->will($this->returnValue('field2')); + ->willReturn('field2'); $this->logger->expects($this->at(0))->method('addRecord')->with( 400, @@ -215,16 +215,16 @@ public function testPerformWithSourceFieldErrors() public function testPerformWithMismatchDocumentFieldDataTypes() { $this->setupFieldsValidation(true); - $this->documentSource->expects($this->any())->method('getName')->will($this->returnValue('document1')); - $this->documentDestination->expects($this->any())->method('getName')->will($this->returnValue('document1')); + $this->documentSource->expects($this->any())->method('getName')->willReturn('document1'); + $this->documentDestination->expects($this->any())->method('getName')->willReturn('document1'); $this->source->expects($this->atLeastOnce())->method('getDocumentList') - ->will($this->returnValue(['document1'])); + ->willReturn(['document1']); $this->destination->expects($this->atLeastOnce())->method('getDocumentList') - ->will($this->returnValue(['document1'])); - $this->map->expects($this->any())->method('getDocumentMap')->will($this->returnArgument(0)); + ->willReturn(['document1']); + $this->map->expects($this->any())->method('getDocumentMap')->willReturnArgument(0); $this->map->expects($this->any())->method('isDocumentIgnored')->willReturn(false); - $this->map->expects($this->any())->method('getFieldMap')->will($this->returnValue('field1')); - $this->map->expects($this->any())->method('isFieldDataTypeIgnored')->will($this->returnValue(false)); + $this->map->expects($this->any())->method('getFieldMap')->willReturn('field1'); + $this->map->expects($this->any())->method('isFieldDataTypeIgnored')->willReturn(false); $this->logger->expects($this->at(0))->method('warning') ->with('Mismatch of data types. Source document: document1. Fields: field1'); $this->logger->expects($this->at(1))->method('warning') @@ -243,24 +243,24 @@ protected function setupFieldsValidation($dataTypeMismatch = false) $fieldsSource = ['field1' => ['DATA_TYPE' => $dataTypeSource]]; $structureSource = $this->getMockBuilder(\Migration\ResourceModel\Structure::class) ->disableOriginalConstructor()->setMethods([])->getMock(); - $structureSource->expects($this->any())->method('getFields')->will($this->returnValue($fieldsSource)); + $structureSource->expects($this->any())->method('getFields')->willReturn($fieldsSource); $this->documentSource = $this->getMockBuilder(\Migration\ResourceModel\Document::class) ->disableOriginalConstructor()->getMock(); $this->documentSource->expects($this->any())->method('getStructure') - ->will($this->returnValue($structureSource)); + ->willReturn($structureSource); $dataTypeDestination = 'int'; $fieldsDestination = ['field1' => ['DATA_TYPE' => $dataTypeDestination]]; $structureDestination = $this->getMockBuilder(\Migration\ResourceModel\Structure::class) ->disableOriginalConstructor()->setMethods([])->getMock(); - $structureDestination->expects($this->any())->method('getFields')->will($this->returnValue($fieldsDestination)); + $structureDestination->expects($this->any())->method('getFields')->willReturn($fieldsDestination); $this->documentDestination = $this->getMockBuilder(\Migration\ResourceModel\Document::class) ->disableOriginalConstructor()->getMock(); $this->documentDestination->expects($this->any())->method('getStructure') - ->will($this->returnValue($structureDestination)); + ->willReturn($structureDestination); - $this->source->expects($this->any())->method('getDocument')->will($this->returnValue($this->documentSource)); + $this->source->expects($this->any())->method('getDocument')->willReturn($this->documentSource); $this->destination->expects($this->any())->method('getDocument') - ->will($this->returnValue($this->documentDestination)); + ->willReturn($this->documentDestination); } } diff --git a/tests/unit/testsuite/Migration/Step/Map/VolumeTest.php b/tests/unit/testsuite/Migration/Step/Map/VolumeTest.php index fd3c9a9e..91ced2a4 100644 --- a/tests/unit/testsuite/Migration/Step/Map/VolumeTest.php +++ b/tests/unit/testsuite/Migration/Step/Map/VolumeTest.php @@ -54,7 +54,7 @@ class VolumeTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->logger = $this->createPartialMock( \Migration\Logger\Logger::class, diff --git a/tests/unit/testsuite/Migration/Step/PostProcessing/Data/EavLeftoverDataCleanerTest.php b/tests/unit/testsuite/Migration/Step/PostProcessing/Data/EavLeftoverDataCleanerTest.php index 3d1e142d..29a9e073 100644 --- a/tests/unit/testsuite/Migration/Step/PostProcessing/Data/EavLeftoverDataCleanerTest.php +++ b/tests/unit/testsuite/Migration/Step/PostProcessing/Data/EavLeftoverDataCleanerTest.php @@ -35,7 +35,7 @@ class EavLeftoverDataCleanerTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->destination = $this->createPartialMock( \Migration\ResourceModel\Destination::class, diff --git a/tests/unit/testsuite/Migration/Step/PostProcessing/Data/ProductsInRootCatalogCleanerTest.php b/tests/unit/testsuite/Migration/Step/PostProcessing/Data/ProductsInRootCatalogCleanerTest.php index 95bdc9da..0f00cc3e 100644 --- a/tests/unit/testsuite/Migration/Step/PostProcessing/Data/ProductsInRootCatalogCleanerTest.php +++ b/tests/unit/testsuite/Migration/Step/PostProcessing/Data/ProductsInRootCatalogCleanerTest.php @@ -25,7 +25,7 @@ class ProductsInRootCatalogCleanerTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->destination = $this->createPartialMock( \Migration\ResourceModel\Destination::class, diff --git a/tests/unit/testsuite/Migration/Step/PostProcessing/DataTest.php b/tests/unit/testsuite/Migration/Step/PostProcessing/DataTest.php index fd5baeda..582490db 100644 --- a/tests/unit/testsuite/Migration/Step/PostProcessing/DataTest.php +++ b/tests/unit/testsuite/Migration/Step/PostProcessing/DataTest.php @@ -40,7 +40,7 @@ class DataTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->eavLeftoverDataCleaner = $this->createPartialMock( \Migration\Step\PostProcessing\Data\EavLeftoverDataCleaner::class, diff --git a/tests/unit/testsuite/Migration/Step/Ratings/DataTest.php b/tests/unit/testsuite/Migration/Step/Ratings/DataTest.php index 795b359e..cbcf2948 100644 --- a/tests/unit/testsuite/Migration/Step/Ratings/DataTest.php +++ b/tests/unit/testsuite/Migration/Step/Ratings/DataTest.php @@ -35,7 +35,7 @@ class DataTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->destination = $this->createPartialMock( \Migration\ResourceModel\Destination::class, @@ -44,7 +44,7 @@ public function setUp() $this->destination ->expects($this->any()) ->method('addDocumentPrefix') - ->will($this->returnValueMap([['rating_store', 'rating_store'], ['rating', 'rating']])); + ->willReturnMap([['rating_store', 'rating_store'], ['rating', 'rating']]); $this->select = $this->createPartialMock( \Magento\Framework\DB\Select::class, ['from', 'where'] @@ -74,12 +74,12 @@ public function testPerform() ->expects($this->once()) ->method('from') ->with('rating_store', ['rating_id']) - ->will($this->returnSelf()); + ->willReturnSelf(); $this->select ->expects($this->once()) ->method('where') ->with('store_id > 0') - ->will($this->returnSelf()); + ->willReturnSelf(); $this->adapter ->expects($this->once()) ->method('loadDataFromSelect') diff --git a/tests/unit/testsuite/Migration/Step/Ratings/IntegrityTest.php b/tests/unit/testsuite/Migration/Step/Ratings/IntegrityTest.php index d747f3f3..1072e6bb 100644 --- a/tests/unit/testsuite/Migration/Step/Ratings/IntegrityTest.php +++ b/tests/unit/testsuite/Migration/Step/Ratings/IntegrityTest.php @@ -43,7 +43,7 @@ class IntegrityTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->destination = $this->createPartialMock( \Migration\ResourceModel\Destination::class, @@ -52,7 +52,7 @@ public function setUp() $this->destination ->expects($this->any()) ->method('addDocumentPrefix') - ->will($this->returnValueMap([['rating_store', 'rating_store'], ['rating', 'rating']])); + ->willReturnMap([['rating_store', 'rating_store'], ['rating', 'rating']]); $this->structure = $this->createPartialMock( \Migration\ResourceModel\Structure::class, diff --git a/tests/unit/testsuite/Migration/Step/Ratings/VolumeTest.php b/tests/unit/testsuite/Migration/Step/Ratings/VolumeTest.php index 2f565a0a..f8bce12a 100644 --- a/tests/unit/testsuite/Migration/Step/Ratings/VolumeTest.php +++ b/tests/unit/testsuite/Migration/Step/Ratings/VolumeTest.php @@ -45,7 +45,7 @@ class VolumeTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->destination = $this->createPartialMock( \Migration\ResourceModel\Destination::class, @@ -54,7 +54,7 @@ public function setUp() $this->destination ->expects($this->any()) ->method('addDocumentPrefix') - ->will($this->returnValueMap([['rating_store', 'rating_store'], ['rating', 'rating']])); + ->willReturnMap([['rating_store', 'rating_store'], ['rating', 'rating']]); $this->select = $this->createPartialMock( \Magento\Framework\DB\Select::class, ['from', 'where'] @@ -88,18 +88,18 @@ public function testPerform() ->expects($this->at(0)) ->method('from') ->with('rating_store', ['rating_id']) - ->will($this->returnSelf()); + ->willReturnSelf(); $this->select ->expects($this->at(1)) ->method('where') ->with('store_id > 0') - ->will($this->returnSelf()); + ->willReturnSelf(); $this->adapter ->expects($this->exactly(2)) ->method('loadDataFromSelect') ->with($this->select)->willReturn([['rating_id' => 1]]); - $this->select->expects($this->at(2))->method('from')->with('rating', ['rating_id'])->will($this->returnSelf()); - $this->select->expects($this->at(3))->method('where')->with('is_active = ?', 1)->will($this->returnSelf()); + $this->select->expects($this->at(2))->method('from')->with('rating', ['rating_id'])->willReturnSelf(); + $this->select->expects($this->at(3))->method('where')->with('is_active = ?', 1)->willReturnSelf(); $this->logger->expects($this->never())->method('addRecord'); $this->assertTrue($this->volume->perform()); } @@ -119,12 +119,12 @@ public function testPerformFailed() ->expects($this->at(0)) ->method('from') ->with('rating_store', ['rating_id']) - ->will($this->returnSelf()); + ->willReturnSelf(); $this->select ->expects($this->at(1)) ->method('where') ->with('store_id > 0') - ->will($this->returnSelf()); + ->willReturnSelf(); $this->adapter ->expects($this->at(1)) ->method('loadDataFromSelect') @@ -139,12 +139,12 @@ public function testPerformFailed() ->expects($this->at(2)) ->method('from') ->with('rating', ['rating_id']) - ->will($this->returnSelf()); + ->willReturnSelf(); $this->select ->expects($this->at(3)) ->method('where') ->with('is_active = ?', 1) - ->will($this->returnSelf()); + ->willReturnSelf(); $this->logger ->expects($this->once()) ->method('addRecord') diff --git a/tests/unit/testsuite/Migration/Step/SalesOrder/DataTest.php b/tests/unit/testsuite/Migration/Step/SalesOrder/DataTest.php index eeee47c4..3d103f04 100644 --- a/tests/unit/testsuite/Migration/Step/SalesOrder/DataTest.php +++ b/tests/unit/testsuite/Migration/Step/SalesOrder/DataTest.php @@ -63,7 +63,7 @@ class DataTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->progress = $this->createPartialMock( \Migration\App\ProgressBar\LogLevelProcessor::class, diff --git a/tests/unit/testsuite/Migration/Step/SalesOrder/HelperTest.php b/tests/unit/testsuite/Migration/Step/SalesOrder/HelperTest.php index 401eacd0..075b4992 100644 --- a/tests/unit/testsuite/Migration/Step/SalesOrder/HelperTest.php +++ b/tests/unit/testsuite/Migration/Step/SalesOrder/HelperTest.php @@ -26,7 +26,7 @@ class HelperTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->source = $this->getMockBuilder(\Migration\ResourceModel\Source::class) ->setMethods(['getAdapter', 'addDocumentPrefix']) diff --git a/tests/unit/testsuite/Migration/Step/SalesOrder/InitialDataTest.php b/tests/unit/testsuite/Migration/Step/SalesOrder/InitialDataTest.php index 4ecfc1dd..b3c6d2c8 100644 --- a/tests/unit/testsuite/Migration/Step/SalesOrder/InitialDataTest.php +++ b/tests/unit/testsuite/Migration/Step/SalesOrder/InitialDataTest.php @@ -37,7 +37,7 @@ class InitialDataTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->source = $this->createMock(\Migration\ResourceModel\Source::class); $this->destination = $this->createPartialMock( diff --git a/tests/unit/testsuite/Migration/Step/SalesOrder/IntegrityTest.php b/tests/unit/testsuite/Migration/Step/SalesOrder/IntegrityTest.php index 04c71107..435d8b28 100644 --- a/tests/unit/testsuite/Migration/Step/SalesOrder/IntegrityTest.php +++ b/tests/unit/testsuite/Migration/Step/SalesOrder/IntegrityTest.php @@ -55,7 +55,7 @@ class IntegrityTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->logger = $this->createPartialMock( \Migration\Logger\Logger::class, diff --git a/tests/unit/testsuite/Migration/Step/SalesOrder/VolumeTest.php b/tests/unit/testsuite/Migration/Step/SalesOrder/VolumeTest.php index 9c7b1b5a..8319f1ea 100644 --- a/tests/unit/testsuite/Migration/Step/SalesOrder/VolumeTest.php +++ b/tests/unit/testsuite/Migration/Step/SalesOrder/VolumeTest.php @@ -56,7 +56,7 @@ class VolumeTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->logger = $this->createPartialMock( \Migration\Logger\Logger::class, diff --git a/tests/unit/testsuite/Migration/Step/Settings/DataTest.php b/tests/unit/testsuite/Migration/Step/Settings/DataTest.php index c2a66934..b592d74e 100644 --- a/tests/unit/testsuite/Migration/Step/Settings/DataTest.php +++ b/tests/unit/testsuite/Migration/Step/Settings/DataTest.php @@ -53,7 +53,7 @@ class DataTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->destination = $this->createPartialMock( \Migration\ResourceModel\Destination::class, diff --git a/tests/unit/testsuite/Migration/Step/Settings/IntegrityTest.php b/tests/unit/testsuite/Migration/Step/Settings/IntegrityTest.php index c99e5c08..57b143ff 100644 --- a/tests/unit/testsuite/Migration/Step/Settings/IntegrityTest.php +++ b/tests/unit/testsuite/Migration/Step/Settings/IntegrityTest.php @@ -53,7 +53,7 @@ class IntegrityTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->destination = $this->createPartialMock( \Migration\ResourceModel\Destination::class, diff --git a/tests/unit/testsuite/Migration/Step/UrlRewrite/Version11410to2000Test.php b/tests/unit/testsuite/Migration/Step/UrlRewrite/Version11410to2000Test.php index 7649b1bd..81922b54 100644 --- a/tests/unit/testsuite/Migration/Step/UrlRewrite/Version11410to2000Test.php +++ b/tests/unit/testsuite/Migration/Step/UrlRewrite/Version11410to2000Test.php @@ -82,7 +82,7 @@ class Version11410to2000Test extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->progress = $this->createPartialMock( \Migration\App\ProgressBar\LogLevelProcessor::class, diff --git a/tests/unit/testsuite/Migration/Step/UrlRewrite/Version191to2000Test.php b/tests/unit/testsuite/Migration/Step/UrlRewrite/Version191to2000Test.php index 8c975499..8a510071 100644 --- a/tests/unit/testsuite/Migration/Step/UrlRewrite/Version191to2000Test.php +++ b/tests/unit/testsuite/Migration/Step/UrlRewrite/Version191to2000Test.php @@ -60,7 +60,7 @@ class Version191to2000Test extends \PHPUnit\Framework\TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->logger = $this->createPartialMock( \Migration\Logger\Logger::class,