From 72ffbff53ed738df2b33a963dae9a2af19e264c9 Mon Sep 17 00:00:00 2001 From: Michael Woodward Date: Sat, 24 Mar 2018 14:10:39 +0000 Subject: [PATCH 01/12] 6: Upgrade PHPUnit dependencies - PHPUnit -> ~7.0.0 - PHPCPD -> ~4.0.0 --- composer.json | 4 +- composer.lock | 246 ++++++++++++++++++++++++-------------------------- 2 files changed, 120 insertions(+), 130 deletions(-) diff --git a/composer.json b/composer.json index 653210f51ca..901f3274422 100644 --- a/composer.json +++ b/composer.json @@ -84,8 +84,8 @@ "lusitanian/oauth": "~0.8.10", "pdepend/pdepend": "2.5.2", "phpmd/phpmd": "@stable", - "phpunit/phpunit": "~6.2.0", - "sebastian/phpcpd": "~3.0.0", + "phpunit/phpunit": "~7.0.0", + "sebastian/phpcpd": "~4.0.0", "squizlabs/php_codesniffer": "3.2.2" }, "replace": { diff --git a/composer.lock b/composer.lock index d35e9193255..271d45425f7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "6206f691f045589bbf11b8417f01ef69", + "content-hash": "c055928732e771373d317ded0337bc4a", "packages": [ { "name": "braintree/braintree_php", @@ -257,16 +257,16 @@ }, { "name": "composer/composer", - "version": "1.6.3", + "version": "1.6.4", "source": { "type": "git", "url": "https://github.com/composer/composer.git", - "reference": "88a69fda0f2187ad8714cedffd7a8872dceaa4c2" + "reference": "86ad51e8a3c64c9782446aae740a61fc6faa2522" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/composer/zipball/88a69fda0f2187ad8714cedffd7a8872dceaa4c2", - "reference": "88a69fda0f2187ad8714cedffd7a8872dceaa4c2", + "url": "https://api.github.com/repos/composer/composer/zipball/86ad51e8a3c64c9782446aae740a61fc6faa2522", + "reference": "86ad51e8a3c64c9782446aae740a61fc6faa2522", "shasum": "" }, "require": { @@ -330,7 +330,7 @@ "dependency", "package" ], - "time": "2018-01-31T15:28:18+00:00" + "time": "2018-04-13T10:04:24+00:00" }, { "name": "composer/semver", @@ -837,13 +837,6 @@ "reference": "68522e5768edc8e829d1f64b620a3de3753f1141", "shasum": "" }, - "archive": { - "exclude": [ - "/demos", - "/documentation", - "/tests" - ] - }, "require": { "php": ">=5.2.11" }, @@ -862,6 +855,7 @@ "Zend_": "library/" } }, + "notification-url": "https://packagist.org/downloads/", "include-path": [ "library/" ], @@ -871,14 +865,10 @@ "description": "Magento Zend Framework 1", "homepage": "http://framework.zend.com/", "keywords": [ - "framework", - "zf1" + "ZF1", + "framework" ], - "support": { - "source": "https://github.com/magento-engcom/zf1-php-7.2-support/tree/master", - "issues": "https://github.com/magento-engcom/zf1-php-7.2-support/issues" - }, - "time": "2018-04-06T17:12:22+00:00" + "time": "2018-04-06T18:49:03+00:00" }, { "name": "monolog/monolog", @@ -2723,29 +2713,32 @@ }, { "name": "zendframework/zend-filter", - "version": "2.7.2", + "version": "2.8.0", "source": { "type": "git", "url": "https://github.com/zendframework/zend-filter.git", - "reference": "b8d0ff872f126631bf63a932e33aa2d22d467175" + "reference": "7b997dbe79459f1652deccc8786d7407fb66caa9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-filter/zipball/b8d0ff872f126631bf63a932e33aa2d22d467175", - "reference": "b8d0ff872f126631bf63a932e33aa2d22d467175", + "url": "https://api.github.com/repos/zendframework/zend-filter/zipball/7b997dbe79459f1652deccc8786d7407fb66caa9", + "reference": "7b997dbe79459f1652deccc8786d7407fb66caa9", "shasum": "" }, "require": { - "php": "^5.5 || ^7.0", - "zendframework/zend-stdlib": "^2.7 || ^3.0" + "php": "^5.6 || ^7.0", + "zendframework/zend-stdlib": "^2.7.7 || ^3.1" + }, + "conflict": { + "zendframework/zend-validator": "<2.10.1" }, "require-dev": { - "pear/archive_tar": "^1.4", - "phpunit/phpunit": "^6.0.10 || ^5.7.17", + "pear/archive_tar": "^1.4.3", + "phpunit/phpunit": "^5.7.23 || ^6.4.3", "zendframework/zend-coding-standard": "~1.0.0", - "zendframework/zend-crypt": "^2.6 || ^3.0", - "zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3", - "zendframework/zend-uri": "^2.5" + "zendframework/zend-crypt": "^3.2.1", + "zendframework/zend-servicemanager": "^2.7.8 || ^3.3", + "zendframework/zend-uri": "^2.6" }, "suggest": { "zendframework/zend-crypt": "Zend\\Crypt component, for encryption filters", @@ -2756,8 +2749,8 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.7-dev", - "dev-develop": "2.8-dev" + "dev-master": "2.8.x-dev", + "dev-develop": "2.9.x-dev" }, "zf": { "component": "Zend\\Filter", @@ -2774,12 +2767,12 @@ "BSD-3-Clause" ], "description": "provides a set of commonly needed data filters", - "homepage": "https://github.com/zendframework/zend-filter", "keywords": [ + "ZendFramework", "filter", - "zf2" + "zf" ], - "time": "2017-05-17T20:56:17+00:00" + "time": "2018-04-11T16:20:04+00:00" }, { "name": "zendframework/zend-form", @@ -5010,40 +5003,40 @@ }, { "name": "phpunit/php-code-coverage", - "version": "5.3.2", + "version": "6.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "c89677919c5dd6d3b3852f230a663118762218ac" + "reference": "774a82c0c5da4c1c7701790c262035d235ab7856" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c89677919c5dd6d3b3852f230a663118762218ac", - "reference": "c89677919c5dd6d3b3852f230a663118762218ac", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/774a82c0c5da4c1c7701790c262035d235ab7856", + "reference": "774a82c0c5da4c1c7701790c262035d235ab7856", "shasum": "" }, "require": { "ext-dom": "*", "ext-xmlwriter": "*", - "php": "^7.0", + "php": "^7.1", "phpunit/php-file-iterator": "^1.4.2", "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^2.0.1", + "phpunit/php-token-stream": "^3.0", "sebastian/code-unit-reverse-lookup": "^1.0.1", - "sebastian/environment": "^3.0", + "sebastian/environment": "^3.1", "sebastian/version": "^2.0.1", "theseer/tokenizer": "^1.1" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^7.0" }, "suggest": { - "ext-xdebug": "^2.5.5" + "ext-xdebug": "^2.6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.3.x-dev" + "dev-master": "6.0-dev" } }, "autoload": { @@ -5069,7 +5062,7 @@ "testing", "xunit" ], - "time": "2018-04-06T15:36:58+00:00" + "time": "2018-04-06T15:39:20+00:00" }, { "name": "phpunit/php-file-iterator", @@ -5161,28 +5154,28 @@ }, { "name": "phpunit/php-timer", - "version": "1.0.9", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" + "reference": "8b8454ea6958c3dee38453d3bd571e023108c91f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/8b8454ea6958c3dee38453d3bd571e023108c91f", + "reference": "8b8454ea6958c3dee38453d3bd571e023108c91f", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -5197,7 +5190,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -5206,33 +5199,33 @@ "keywords": [ "timer" ], - "time": "2017-02-26T11:10:40+00:00" + "time": "2018-02-01T13:07:23+00:00" }, { "name": "phpunit/php-token-stream", - "version": "2.0.2", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "791198a2c6254db10131eecfe8c06670700904db" + "reference": "21ad88bbba7c3d93530d93994e0a33cd45f02ace" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db", - "reference": "791198a2c6254db10131eecfe8c06670700904db", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/21ad88bbba7c3d93530d93994e0a33cd45f02ace", + "reference": "21ad88bbba7c3d93530d93994e0a33cd45f02ace", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": "^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^6.2.4" + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -5255,20 +5248,20 @@ "keywords": [ "tokenizer" ], - "time": "2017-11-27T05:48:46+00:00" + "time": "2018-02-01T13:16:43+00:00" }, { "name": "phpunit/phpunit", - "version": "6.2.4", + "version": "7.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "ff3a76a58ac293657808aefd58c8aaf05945f4d9" + "reference": "536f4d853c12d8189963435088e8ff7c0daeab2e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ff3a76a58ac293657808aefd58c8aaf05945f4d9", - "reference": "ff3a76a58ac293657808aefd58c8aaf05945f4d9", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/536f4d853c12d8189963435088e8ff7c0daeab2e", + "reference": "536f4d853c12d8189963435088e8ff7c0daeab2e", "shasum": "" }, "require": { @@ -5277,35 +5270,31 @@ "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", - "myclabs/deep-copy": "^1.3", + "myclabs/deep-copy": "^1.6.1", "phar-io/manifest": "^1.0.1", "phar-io/version": "^1.0", - "php": "^7.0", + "php": "^7.1", "phpspec/prophecy": "^1.7", - "phpunit/php-code-coverage": "^5.2", - "phpunit/php-file-iterator": "^1.4", - "phpunit/php-text-template": "^1.2", - "phpunit/php-timer": "^1.0.6", - "phpunit/phpunit-mock-objects": "^4.0", - "sebastian/comparator": "^2.0", - "sebastian/diff": "^1.4.3", - "sebastian/environment": "^3.0.2", + "phpunit/php-code-coverage": "^6.0.1", + "phpunit/php-file-iterator": "^1.4.3", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-timer": "^2.0", + "phpunit/phpunit-mock-objects": "^6.0", + "sebastian/comparator": "^2.1", + "sebastian/diff": "^3.0", + "sebastian/environment": "^3.1", "sebastian/exporter": "^3.1", - "sebastian/global-state": "^1.1 || ^2.0", - "sebastian/object-enumerator": "^3.0.2", + "sebastian/global-state": "^2.0", + "sebastian/object-enumerator": "^3.0.3", "sebastian/resource-operations": "^1.0", - "sebastian/version": "^2.0" - }, - "conflict": { - "phpdocumentor/reflection-docblock": "3.0.2", - "phpunit/dbunit": "<3.0" + "sebastian/version": "^2.0.1" }, "require-dev": { "ext-pdo": "*" }, "suggest": { "ext-xdebug": "*", - "phpunit/php-invoker": "^1.1" + "phpunit/php-invoker": "^2.0" }, "bin": [ "phpunit" @@ -5313,7 +5302,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "6.2.x-dev" + "dev-master": "7.0-dev" } }, "autoload": { @@ -5339,33 +5328,30 @@ "testing", "xunit" ], - "time": "2017-08-03T13:59:28+00:00" + "time": "2018-03-26T07:36:48+00:00" }, { "name": "phpunit/phpunit-mock-objects", - "version": "4.0.4", + "version": "6.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "2f789b59ab89669015ad984afa350c4ec577ade0" + "reference": "70c740bde8fd9ea9ea295be1cd875dd7b267e157" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/2f789b59ab89669015ad984afa350c4ec577ade0", - "reference": "2f789b59ab89669015ad984afa350c4ec577ade0", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/70c740bde8fd9ea9ea295be1cd875dd7b267e157", + "reference": "70c740bde8fd9ea9ea295be1cd875dd7b267e157", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.5", - "php": "^7.0", + "php": "^7.1", "phpunit/php-text-template": "^1.2.1", - "sebastian/exporter": "^3.0" - }, - "conflict": { - "phpunit/phpunit": "<6.0" + "sebastian/exporter": "^3.1" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^7.0" }, "suggest": { "ext-soap": "*" @@ -5373,7 +5359,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0.x-dev" + "dev-master": "6.1-dev" } }, "autoload": { @@ -5388,7 +5374,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -5398,7 +5384,7 @@ "mock", "xunit" ], - "time": "2017-08-03T14:08:16+00:00" + "time": "2018-04-11T04:50:36+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -5447,30 +5433,30 @@ }, { "name": "sebastian/comparator", - "version": "2.0.0", + "version": "2.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "20f84f468cb67efee293246e6a09619b891f55f0" + "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/20f84f468cb67efee293246e6a09619b891f55f0", - "reference": "20f84f468cb67efee293246e6a09619b891f55f0", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/34369daee48eafb2651bea869b4b15d75ccc35f9", + "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9", "shasum": "" }, "require": { "php": "^7.0", - "sebastian/diff": "^1.2", - "sebastian/exporter": "^3.0" + "sebastian/diff": "^2.0 || ^3.0", + "sebastian/exporter": "^3.1" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^6.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "2.1.x-dev" } }, "autoload": { @@ -5501,38 +5487,39 @@ } ], "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", + "homepage": "https://github.com/sebastianbergmann/comparator", "keywords": [ "comparator", "compare", "equality" ], - "time": "2017-03-03T06:26:08+00:00" + "time": "2018-02-01T13:46:46+00:00" }, { "name": "sebastian/diff", - "version": "1.4.3", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" + "reference": "e09160918c66281713f1c324c1f4c4c3037ba1e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/e09160918c66281713f1c324c1f4c4c3037ba1e8", + "reference": "e09160918c66281713f1c324c1f4c4c3037ba1e8", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + "phpunit/phpunit": "^7.0", + "symfony/process": "^2 || ^3.3 || ^4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -5557,9 +5544,12 @@ "description": "Diff implementation", "homepage": "https://github.com/sebastianbergmann/diff", "keywords": [ - "diff" + "diff", + "udiff", + "unidiff", + "unified diff" ], - "time": "2017-05-22T07:24:03+00:00" + "time": "2018-02-01T13:45:15+00:00" }, { "name": "sebastian/environment", @@ -5862,21 +5852,21 @@ }, { "name": "sebastian/phpcpd", - "version": "3.0.1", + "version": "4.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpcpd.git", - "reference": "dfed51c1288790fc957c9433e2f49ab152e8a564" + "reference": "bb7953b81fb28e55964d76d5fe2dbe725d43fab3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpcpd/zipball/dfed51c1288790fc957c9433e2f49ab152e8a564", - "reference": "dfed51c1288790fc957c9433e2f49ab152e8a564", + "url": "https://api.github.com/repos/sebastianbergmann/phpcpd/zipball/bb7953b81fb28e55964d76d5fe2dbe725d43fab3", + "reference": "bb7953b81fb28e55964d76d5fe2dbe725d43fab3", "shasum": "" }, "require": { - "php": "^5.6|^7.0", - "phpunit/php-timer": "^1.0.6", + "php": "^7.1", + "phpunit/php-timer": "^2.0", "sebastian/finder-facade": "^1.1", "sebastian/version": "^1.0|^2.0", "symfony/console": "^2.7|^3.0|^4.0" @@ -5887,7 +5877,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -5908,7 +5898,7 @@ ], "description": "Copy/Paste Detector (CPD) for PHP code.", "homepage": "https://github.com/sebastianbergmann/phpcpd", - "time": "2017-11-16T08:49:28+00:00" + "time": "2018-02-02T09:59:58+00:00" }, { "name": "sebastian/recursion-context", From 5c20742949c071d84ff0b3f0233e87509dd85c15 Mon Sep 17 00:00:00 2001 From: Michael Woodward Date: Sat, 7 Apr 2018 21:09:20 +0100 Subject: [PATCH 02/12] Fix test listeners for PHPUnit 7 --- .../TestFramework/ErrorLog/Listener.php | 37 ++++++--- .../TestFramework/Listener/ExtededTestdox.php | 83 ++++++++++--------- .../Unit/Listener/ReplaceObjectManager.php | 7 +- 3 files changed, 75 insertions(+), 52 deletions(-) diff --git a/dev/tests/integration/framework/Magento/TestFramework/ErrorLog/Listener.php b/dev/tests/integration/framework/Magento/TestFramework/ErrorLog/Listener.php index 5b9e4386b70..879f1709814 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/ErrorLog/Listener.php +++ b/dev/tests/integration/framework/Magento/TestFramework/ErrorLog/Listener.php @@ -6,15 +6,26 @@ namespace Magento\TestFramework\ErrorLog; use Magento\TestFramework\Helper; +use PHPUnit\Framework\AssertionFailedError; +use PHPUnit\Framework\Test; +use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\TestListener; +use PHPUnit\Framework\TestSuite; +use PHPUnit\Framework\Warning; -class Listener implements \PHPUnit\Framework\TestListener +class Listener implements TestListener { + /** + * @var Logger|null + */ + private $logger; + /** * {@inheritdoc} * @SuppressWarnings(PHPMD.ShortVariable) * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function addError(\PHPUnit\Framework\Test $test, \Exception $e, $time) + public function addError(Test $test, \Throwable $e, float $time): void { } @@ -23,7 +34,7 @@ public function addError(\PHPUnit\Framework\Test $test, \Exception $e, $time) * @SuppressWarnings(PHPMD.ShortVariable) * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function addFailure(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\AssertionFailedError $e, $time) + public function addFailure(Test $test, AssertionFailedError $e, float $time): void { } @@ -32,7 +43,7 @@ public function addFailure(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\Ass * @SuppressWarnings(PHPMD.ShortVariable) * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function addIncompleteTest(\PHPUnit\Framework\Test $test, \Exception $e, $time) + public function addIncompleteTest(Test $test, \Throwable $e, float $time): void { } @@ -41,7 +52,7 @@ public function addIncompleteTest(\PHPUnit\Framework\Test $test, \Exception $e, * @SuppressWarnings(PHPMD.ShortVariable) * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function addRiskyTest(\PHPUnit\Framework\Test $test, \Exception $e, $time) + public function addRiskyTest(Test $test, \Throwable $e, float $time): void { } @@ -50,30 +61,30 @@ public function addRiskyTest(\PHPUnit\Framework\Test $test, \Exception $e, $time * @SuppressWarnings(PHPMD.ShortVariable) * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function addSkippedTest(\PHPUnit\Framework\Test $test, \Exception $e, $time) + public function addSkippedTest(Test $test, \Throwable $e, float $time): void { } /** * {@inheritdoc} */ - public function startTestSuite(\PHPUnit\Framework\TestSuite $suite) + public function startTestSuite(TestSuite $suite): void { } /** * {@inheritdoc} */ - public function endTestSuite(\PHPUnit\Framework\TestSuite $suite) + public function endTestSuite(TestSuite $suite): void { } /** * {@inheritdoc} */ - public function startTest(\PHPUnit\Framework\Test $test) + public function startTest(Test $test): void { - $this->logger = Helper\Bootstrap::getObjectManager()->get(\Magento\TestFramework\ErrorLog\Logger::class); + $this->logger = Helper\Bootstrap::getObjectManager()->get(Logger::class); $this->logger->clearMessages(); } @@ -81,9 +92,9 @@ public function startTest(\PHPUnit\Framework\Test $test) * {@inheritdoc} * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function endTest(\PHPUnit\Framework\Test $test, $time) + public function endTest(Test $test, float $time): void { - if ($test instanceof \PHPUnit\Framework\TestCase) { + if ($test instanceof TestCase) { $messages = $this->logger->getMessages(); try { if ($messages) { @@ -102,7 +113,7 @@ public function endTest(\PHPUnit\Framework\Test $test, $time) /** * {@inheritdoc} */ - public function addWarning(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\Warning $e, $time) + public function addWarning(Test $test, Warning $e, float $time): void { } } diff --git a/dev/tests/integration/framework/Magento/TestFramework/Listener/ExtededTestdox.php b/dev/tests/integration/framework/Magento/TestFramework/Listener/ExtededTestdox.php index 6936f15cdec..883d20059ac 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Listener/ExtededTestdox.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Listener/ExtededTestdox.php @@ -5,10 +5,19 @@ */ namespace Magento\TestFramework\Listener; -class ExtededTestdox extends \PHPUnit_Util_Printer implements \PHPUnit\Framework\TestListener +use PHPUnit\Framework\AssertionFailedError; +use PHPUnit\Framework\Test; +use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\TestListener; +use PHPUnit\Framework\TestSuite; +use PHPUnit\Runner\BaseTestRunner; +use PHPUnit\Util\Printer; +use PHPUnit\Util\TestDox\NamePrettifier; + +class ExtededTestdox extends Printer implements TestListener { /** - * @var \PHPUnit_Util_TestDox_NamePrettifier + * @var NamePrettifier */ protected $prettifier; @@ -55,7 +64,7 @@ class ExtededTestdox extends \PHPUnit_Util_Printer implements \PHPUnit\Framework /** * @var \stdClass */ - protected $testTypeOfInterest = \PHPUnit\Framework\TestCase::class; + protected $testTypeOfInterest = TestCase::class; /** * @var string @@ -76,7 +85,7 @@ public function __construct($out = null) { parent::__construct($out); - $this->prettifier = new \PHPUnit_Util_TestDox_NamePrettifier(); + $this->prettifier = new NamePrettifier(); $this->startRun(); } @@ -95,15 +104,15 @@ public function flush() /** * An error occurred. * - * @param \PHPUnit\Framework\Test $test + * @param Test $test * @param \Exception $e * @param float $time * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function addError(\PHPUnit\Framework\Test $test, \Exception $e, $time) + public function addError(Test $test, \Throwable $e, float $time): void { if ($test instanceof $this->testTypeOfInterest) { - $this->testStatus = \PHPUnit_Runner_BaseTestRunner::STATUS_ERROR; + $this->testStatus = BaseTestRunner::STATUS_ERROR; $this->failed++; } } @@ -111,15 +120,15 @@ public function addError(\PHPUnit\Framework\Test $test, \Exception $e, $time) /** * A failure occurred. * - * @param \PHPUnit\Framework\Test $test - * @param \PHPUnit\Framework\AssertionFailedError $e + * @param Test $test + * @param AssertionFailedError $e * @param float $time * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function addFailure(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\AssertionFailedError $e, $time) + public function addFailure(Test $test, AssertionFailedError $e, float $time): void { if ($test instanceof $this->testTypeOfInterest) { - $this->testStatus = \PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE; + $this->testStatus = BaseTestRunner::STATUS_FAILURE; $this->failed++; } } @@ -127,15 +136,15 @@ public function addFailure(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\Ass /** * Incomplete test. * - * @param \PHPUnit\Framework\Test $test + * @param Test $test * @param \Exception $e * @param float $time * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function addIncompleteTest(\PHPUnit\Framework\Test $test, \Exception $e, $time) + public function addIncompleteTest(Test $test, \Throwable $e, float $time): void { if ($test instanceof $this->testTypeOfInterest) { - $this->testStatus = \PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE; + $this->testStatus = BaseTestRunner::STATUS_INCOMPLETE; $this->incomplete++; } } @@ -143,16 +152,16 @@ public function addIncompleteTest(\PHPUnit\Framework\Test $test, \Exception $e, /** * Skipped test. * - * @param \PHPUnit\Framework\Test $test + * @param Test $test * @param \Exception $e * @param float $time * @since Method available since Release 3.0.0 * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function addSkippedTest(\PHPUnit\Framework\Test $test, \Exception $e, $time) + public function addSkippedTest(Test $test, \Throwable $e, float $time): void { if ($test instanceof $this->testTypeOfInterest) { - $this->testStatus = \PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED; + $this->testStatus = BaseTestRunner::STATUS_SKIPPED; $this->skipped++; } } @@ -160,16 +169,16 @@ public function addSkippedTest(\PHPUnit\Framework\Test $test, \Exception $e, $ti /** * Risky test. * - * @param \PHPUnit\Framework\Test $test + * @param Test $test * @param \Exception $e * @param float $time * @since Method available since Release 4.0.0 * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function addRiskyTest(\PHPUnit\Framework\Test $test, \Exception $e, $time) + public function addRiskyTest(Test $test, \Throwable $e, float $time): void { if ($test instanceof $this->testTypeOfInterest) { - $this->testStatus = \PHPUnit_Runner_BaseTestRunner::STATUS_RISKY; + $this->testStatus = BaseTestRunner::STATUS_RISKY; $this->risky++; } } @@ -177,31 +186,31 @@ public function addRiskyTest(\PHPUnit\Framework\Test $test, \Exception $e, $time /** * A testsuite started. * - * @param \PHPUnit\Framework\TestSuite $suite + * @param TestSuite $suite * @since Method available since Release 2.2.0 * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function startTestSuite(\PHPUnit\Framework\TestSuite $suite) + public function startTestSuite(TestSuite $suite): void { } /** * A testsuite ended. * - * @param \PHPUnit\Framework\TestSuite $suite + * @param TestSuite $suite * @since Method available since Release 2.2.0 * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function endTestSuite(\PHPUnit\Framework\TestSuite $suite) + public function endTestSuite(TestSuite $suite): void { } /** * A test started. * - * @param \PHPUnit\Framework\Test $test + * @param Test $test */ - public function startTest(\PHPUnit\Framework\Test $test) + public function startTest(Test $test): void { if ($test instanceof $this->testTypeOfInterest) { $class = get_class($test); @@ -220,30 +229,30 @@ public function startTest(\PHPUnit\Framework\Test $test) $this->write('.'); $this->currentTestMethodPrettified = $this->prettifier->prettifyTestMethod($test->getName(false)); - $this->testStatus = \PHPUnit_Runner_BaseTestRunner::STATUS_PASSED; + $this->testStatus = BaseTestRunner::STATUS_PASSED; } } /** * A test ended. * - * @param \PHPUnit\Framework\Test $test + * @param Test $test * @param float $time */ - public function endTest(\PHPUnit\Framework\Test $test, $time) + public function endTest(Test $test, float $time): void { if ($test instanceof $this->testTypeOfInterest) { if (!isset($this->tests[$this->currentTestMethodPrettified])) { $this->tests[$this->currentTestMethodPrettified] = ['success' => 0, 'failure' => 0, 'time' => 0]; } - if ($this->testStatus == \PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) { + if ($this->testStatus == BaseTestRunner::STATUS_PASSED) { $this->tests[$this->currentTestMethodPrettified]['success']++; } - if ($this->testStatus == \PHPUnit_Runner_BaseTestRunner::STATUS_ERROR) { + if ($this->testStatus == BaseTestRunner::STATUS_ERROR) { $this->tests[$this->currentTestMethodPrettified]['failure']++; } - if ($this->testStatus == \PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE) { + if ($this->testStatus == BaseTestRunner::STATUS_FAILURE) { $this->tests[$this->currentTestMethodPrettified]['failure']++; } $this->tests[$this->currentTestMethodPrettified]['time'] += $time; @@ -256,7 +265,7 @@ public function endTest(\PHPUnit\Framework\Test $test, $time) * Handler for 'start run' event. * */ - protected function startRun() + protected function startRun(): void { } @@ -264,7 +273,7 @@ protected function startRun() * Handler for 'end run' event. * */ - protected function endRun() + protected function endRun(): void { } @@ -274,7 +283,7 @@ protected function endRun() * @param string $name * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - protected function startClass($name) + protected function startClass($name): void { $this->write($this->currentTestClassPrettified . ' '); } @@ -285,7 +294,7 @@ protected function startClass($name) * @param string $name * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - protected function endClass($name) + protected function endClass($name): void { $this->write("\n"); } @@ -293,7 +302,7 @@ protected function endClass($name) /** * @since Method available since Release 2.3.0 */ - protected function doEndClass() + protected function doEndClass(): void { foreach ($this->tests as $name => $data) { $check = $data['failure'] == 0 ? ' - [x] ' : ' - [ ] '; diff --git a/lib/internal/Magento/Framework/TestFramework/Unit/Listener/ReplaceObjectManager.php b/lib/internal/Magento/Framework/TestFramework/Unit/Listener/ReplaceObjectManager.php index 79745599e83..a185041350b 100644 --- a/lib/internal/Magento/Framework/TestFramework/Unit/Listener/ReplaceObjectManager.php +++ b/lib/internal/Magento/Framework/TestFramework/Unit/Listener/ReplaceObjectManager.php @@ -7,12 +7,15 @@ use Magento\Framework\App\ObjectManager; use Magento\Framework\ObjectManagerInterface; +use PHPUnit\Framework\TestListener; +use PHPUnit\Framework\TestListenerDefaultImplementation; /** * The event listener which instantiates ObjectManager before test run */ -class ReplaceObjectManager extends \PHPUnit\Framework\BaseTestListener +class ReplaceObjectManager implements TestListener { + use TestListenerDefaultImplementation; /** * Replaces ObjectManager before run for each test * @@ -25,7 +28,7 @@ class ReplaceObjectManager extends \PHPUnit\Framework\BaseTestListener * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function startTest(\PHPUnit\Framework\Test $test) + public function startTest(\PHPUnit\Framework\Test $test): void { if ($test instanceof \PHPUnit\Framework\TestCase) { $objectManagerMock = $test->getMockBuilder(ObjectManagerInterface::class) From 68e3fcfeccaf7a8e39aa8a9826082ffeb707d7a2 Mon Sep 17 00:00:00 2001 From: Michael Woodward Date: Sat, 7 Apr 2018 21:13:09 +0100 Subject: [PATCH 03/12] Fix usages of invocation matcher for PHPUnit 7 --- .../Magento/Test/Event/TransactionTest.php | 16 +++-- .../Unit/Matcher/MethodInvokedAtIndex.php | 69 +++++++++++++++++-- 2 files changed, 71 insertions(+), 14 deletions(-) diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Event/TransactionTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Event/TransactionTest.php index 5bb273b4e27..04c837b66a6 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Event/TransactionTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Event/TransactionTest.php @@ -9,20 +9,22 @@ */ namespace Magento\Test\Event; +use PHPUnit\Framework\MockObject\Matcher\Invocation; + class TransactionTest extends \PHPUnit\Framework\TestCase { /** - * @var \Magento\TestFramework\Event\Transaction|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\TestFramework\Event\Transaction|\PHPUnit\Framework\MockObject\MockObject */ protected $_object; /** - * @var \Magento\TestFramework\EventManager|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\TestFramework\EventManager|\PHPUnit\Framework\MockObject\MockObject */ protected $_eventManager; /** - * @var \Magento\TestFramework\Db\Adapter\TransactionInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\TestFramework\Db\Adapter\TransactionInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $_adapter; @@ -69,9 +71,9 @@ protected function _imitateTransactionStartRequest($eventName) /** * Setup expectations for "transaction start" use case * - * @param \PHPUnit_Framework_MockObject_Matcher_Invocation $invocationMatcher + * @param Invocation $invocationMatcher */ - protected function _expectTransactionStart(\PHPUnit_Framework_MockObject_Matcher_Invocation $invocationMatcher) + protected function _expectTransactionStart(Invocation $invocationMatcher) { $this->_eventManager->expects($invocationMatcher)->method('fireEvent')->with('startTransaction'); $this->_adapter->expects($this->once())->method('beginTransaction'); @@ -103,9 +105,9 @@ protected function _imitateTransactionRollbackRequest($eventName) /** * Setup expectations for "transaction rollback" use case * - * @param \PHPUnit_Framework_MockObject_Matcher_Invocation $invocationMatcher + * @param Invocation $invocationMatcher */ - protected function _expectTransactionRollback(\PHPUnit_Framework_MockObject_Matcher_Invocation $invocationMatcher) + protected function _expectTransactionRollback(Invocation $invocationMatcher) { $this->_eventManager->expects($invocationMatcher)->method('fireEvent')->with('rollbackTransaction'); $this->_adapter->expects($this->once())->method('rollback'); diff --git a/lib/internal/Magento/Framework/TestFramework/Unit/Matcher/MethodInvokedAtIndex.php b/lib/internal/Magento/Framework/TestFramework/Unit/Matcher/MethodInvokedAtIndex.php index cd116521dbe..8a6ab07d154 100644 --- a/lib/internal/Magento/Framework/TestFramework/Unit/Matcher/MethodInvokedAtIndex.php +++ b/lib/internal/Magento/Framework/TestFramework/Unit/Matcher/MethodInvokedAtIndex.php @@ -6,6 +6,9 @@ namespace Magento\Framework\TestFramework\Unit\Matcher; +use PHPUnit\Framework\ExpectationFailedException; +use PHPUnit\Framework\MockObject\Invocation; + /** * Class MethodInvokedAtIndex * Matches invocations per 'method' at 'position' @@ -18,7 +21,7 @@ * * @package Magento\TestFramework\Matcher */ -class MethodInvokedAtIndex extends \PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex +class MethodInvokedAtIndex implements \PHPUnit\Framework\MockObject\Matcher\Invocation { /** * @var array @@ -26,22 +29,74 @@ class MethodInvokedAtIndex extends \PHPUnit_Framework_MockObject_Matcher_Invoked protected $indexes = []; /** - * @param \PHPUnit_Framework_MockObject_Invocation $invocation + * @var int + */ + private $currentIndex = -1; + + /** + * @var int + */ + private $sequenceIndex; + + /** + * @param int $sequenceIndex + */ + public function __construct($sequenceIndex) + { + $this->sequenceIndex = $sequenceIndex; + } + + /** + * @return string + */ + public function toString(): string + { + return 'invoked at sequence index ' . $this->sequenceIndex; + } + + /** + * @param \PHPUnit\Framework\MockObject\Invocation $invocation * @return boolean */ - public function matches(\PHPUnit_Framework_MockObject_Invocation $invocation) + public function matches(Invocation $invocation): bool { /** @noinspection PhpUndefinedFieldInspection */ - if (!isset($this->indexes[$invocation->methodName])) { + if (!isset($this->indexes[$invocation->getMethodName()])) { /** @noinspection PhpUndefinedFieldInspection */ - $this->indexes[$invocation->methodName] = 0; + $this->indexes[$invocation->getMethodName()] = 0; } else { /** @noinspection PhpUndefinedFieldInspection */ - $this->indexes[$invocation->methodName]++; + $this->indexes[$invocation->getMethodName()]++; } $this->currentIndex++; /** @noinspection PhpUndefinedFieldInspection */ - return $this->indexes[$invocation->methodName] == $this->sequenceIndex; + return $this->indexes[$invocation->getMethodName()] === $this->sequenceIndex; + } + + /** + * Verifies that the current expectation is valid. If everything is OK the + * code should just return, if not it must throw an exception. + * + * @throws ExpectationFailedException + */ + public function verify(): void + { + if ($this->currentIndex < $this->sequenceIndex) { + throw new ExpectationFailedException( + \sprintf( + 'The expected invocation at index %s was never reached.', + $this->sequenceIndex + ) + ); + } + } + + /** + * @param Invocation $invocation Object containing information on a mocked or stubbed method which was invoked + * @return mixed + */ + public function invoked(Invocation $invocation) + { } } From 884f4295e410c8b5e36179e1708401640aa10b0f Mon Sep 17 00:00:00 2001 From: Michael Woodward Date: Sat, 7 Apr 2018 21:17:40 +0100 Subject: [PATCH 04/12] Use namespaced PHPUnits object invocation mock --- .../Test/Unit/Unit/Matcher/MethodInvokedAtIndexTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/TestFramework/Test/Unit/Unit/Matcher/MethodInvokedAtIndexTest.php b/lib/internal/Magento/Framework/TestFramework/Test/Unit/Unit/Matcher/MethodInvokedAtIndexTest.php index 9721cdb8f93..61b218bfac6 100644 --- a/lib/internal/Magento/Framework/TestFramework/Test/Unit/Unit/Matcher/MethodInvokedAtIndexTest.php +++ b/lib/internal/Magento/Framework/TestFramework/Test/Unit/Unit/Matcher/MethodInvokedAtIndexTest.php @@ -6,12 +6,13 @@ namespace Magento\Framework\TestFramework\Test\Unit\Unit\Matcher; use Magento\Framework\TestFramework\Unit\Matcher\MethodInvokedAtIndex; +use PHPUnit\Framework\MockObject\Invocation\ObjectInvocation; class MethodInvokedAtIndexTest extends \PHPUnit\Framework\TestCase { public function testMatches() { - $invocationObject = new \PHPUnit_Framework_MockObject_Invocation_Object( + $invocationObject = new ObjectInvocation( 'ClassName', 'ValidMethodName', [], From c9ecf1bf296541da05204efdcbc33cdb50ec8777 Mon Sep 17 00:00:00 2001 From: Michael Woodward Date: Sat, 7 Apr 2018 21:28:51 +0100 Subject: [PATCH 05/12] Fix html link test not having href attrib --- .../Framework/View/Test/Unit/Element/Html/LinkTest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php index 692dcb54d14..142c029cc91 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php @@ -11,6 +11,7 @@ class LinkTest extends \PHPUnit\Framework\TestCase * @var array */ protected $allowedAttributes = [ + 'href', 'shape', 'tabindex', 'onfocus', @@ -51,7 +52,7 @@ public function getLinkAttributesDataProvider() $urlBuilderMock->expects($this->any()) ->method('getUrl') - ->will($this->returnArgument('http://site.com/link.html')); + ->will($this->returnValue('http://site.com/link.html')); $validtorMock = $this->getMockBuilder(\Magento\Framework\View\Element\Template\File\Validator::class) ->setMethods(['isValid'])->disableOriginalConstructor()->getMock(); @@ -105,11 +106,11 @@ public function getLinkAttributesDataProvider() return [ 'full' => [ 'link' => $linkWithAttributes, - 'expected' => 'shape="shape" tabindex="tabindex" onfocus="onfocus" onblur="onblur" id="id"', + 'expected' => 'href="http://site.com/link.html" shape="shape" tabindex="tabindex" onfocus="onfocus" onblur="onblur" id="id"', ], 'empty' => [ 'link' => $linkWithoutAttributes, - 'expected' => '', + 'expected' => 'href="http://site.com/link.html"', ], ]; } From 0065c1f700ca6018b22ee14d3e177a5ab4b6a02f Mon Sep 17 00:00:00 2001 From: Michael Woodward Date: Sat, 7 Apr 2018 21:32:15 +0100 Subject: [PATCH 06/12] Fix method signitures for PHPUnit test listener --- .../Magento/TestFramework/Event/PhpUnit.php | 53 +++++++++++-------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/dev/tests/integration/framework/Magento/TestFramework/Event/PhpUnit.php b/dev/tests/integration/framework/Magento/TestFramework/Event/PhpUnit.php index 6e56cecd1c4..b0a34051cef 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Event/PhpUnit.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Event/PhpUnit.php @@ -9,26 +9,35 @@ */ namespace Magento\TestFramework\Event; +use Magento\Framework\Exception\LocalizedException; +use Magento\TestFramework\EventManager; +use PHPUnit\Framework\AssertionFailedError; +use PHPUnit\Framework\DataProviderTestSuite; +use PHPUnit\Framework\Test; +use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\TestSuite; +use PHPUnit\Framework\Warning; + class PhpUnit implements \PHPUnit\Framework\TestListener { /** * Used when PHPUnit framework instantiates the class on its own and passes nothing to the constructor * - * @var \Magento\TestFramework\EventManager + * @var EventManager */ protected static $_defaultEventManager; /** - * @var \Magento\TestFramework\EventManager + * @var EventManager */ protected $_eventManager; /** * Assign default event manager instance * - * @param \Magento\TestFramework\EventManager $eventManager + * @param EventManager $eventManager */ - public static function setDefaultEventManager(\Magento\TestFramework\EventManager $eventManager = null) + public static function setDefaultEventManager(EventManager $eventManager = null): void { self::$_defaultEventManager = $eventManager; } @@ -36,14 +45,14 @@ public static function setDefaultEventManager(\Magento\TestFramework\EventManage /** * Constructor * - * @param \Magento\TestFramework\EventManager $eventManager - * @throws \Magento\Framework\Exception\LocalizedException + * @param EventManager $eventManager + * @throws LocalizedException */ - public function __construct(\Magento\TestFramework\EventManager $eventManager = null) + public function __construct(EventManager $eventManager = null) { $this->_eventManager = $eventManager ?: self::$_defaultEventManager; if (!$this->_eventManager) { - throw new \Magento\Framework\Exception\LocalizedException(__('Instance of the event manager is required.')); + throw new LocalizedException(__('Instance of the event manager is required.')); } } @@ -52,7 +61,7 @@ public function __construct(\Magento\TestFramework\EventManager $eventManager = * @SuppressWarnings(PHPMD.ShortVariable) * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function addError(\PHPUnit\Framework\Test $test, \Exception $e, $time) + public function addError(Test $test, \Throwable $e, float $time): void { } @@ -61,7 +70,7 @@ public function addError(\PHPUnit\Framework\Test $test, \Exception $e, $time) * @SuppressWarnings(PHPMD.ShortVariable) * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function addFailure(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\AssertionFailedError $e, $time) + public function addFailure(Test $test, AssertionFailedError $e, float $time): void { } @@ -70,7 +79,7 @@ public function addFailure(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\Ass * @SuppressWarnings(PHPMD.ShortVariable) * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function addIncompleteTest(\PHPUnit\Framework\Test $test, \Exception $e, $time) + public function addIncompleteTest(Test $test, \Throwable $e, float $time): void { } @@ -79,7 +88,7 @@ public function addIncompleteTest(\PHPUnit\Framework\Test $test, \Exception $e, * @SuppressWarnings(PHPMD.ShortVariable) * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function addRiskyTest(\PHPUnit\Framework\Test $test, \Exception $e, $time) + public function addRiskyTest(Test $test, \Throwable $e, float $time): void { } @@ -88,17 +97,17 @@ public function addRiskyTest(\PHPUnit\Framework\Test $test, \Exception $e, $time * @SuppressWarnings(PHPMD.ShortVariable) * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function addSkippedTest(\PHPUnit\Framework\Test $test, \Exception $e, $time) + public function addSkippedTest(Test $test, \Throwable $e, float $time): void { } /** * {@inheritdoc} */ - public function startTestSuite(\PHPUnit\Framework\TestSuite $suite) + public function startTestSuite(TestSuite $suite): void { /* PHPUnit runs tests with data provider in own test suite for each test, so just skip such test suites */ - if ($suite instanceof \PHPUnit\Framework\DataProviderTestSuite) { + if ($suite instanceof DataProviderTestSuite) { return; } $this->_eventManager->fireEvent('startTestSuite'); @@ -107,9 +116,9 @@ public function startTestSuite(\PHPUnit\Framework\TestSuite $suite) /** * {@inheritdoc} */ - public function endTestSuite(\PHPUnit\Framework\TestSuite $suite) + public function endTestSuite(TestSuite $suite): void { - if ($suite instanceof \PHPUnit\Framework\DataProviderTestSuite) { + if ($suite instanceof DataProviderTestSuite) { return; } $this->_eventManager->fireEvent('endTestSuite', [$suite], true); @@ -118,9 +127,9 @@ public function endTestSuite(\PHPUnit\Framework\TestSuite $suite) /** * {@inheritdoc} */ - public function startTest(\PHPUnit\Framework\Test $test) + public function startTest(Test $test): void { - if (!$test instanceof \PHPUnit\Framework\TestCase || $test instanceof \PHPUnit\Framework\Warning) { + if (!$test instanceof TestCase || $test instanceof Warning) { return; } $this->_eventManager->fireEvent('startTest', [$test]); @@ -130,9 +139,9 @@ public function startTest(\PHPUnit\Framework\Test $test) * {@inheritdoc} * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function endTest(\PHPUnit\Framework\Test $test, $time) + public function endTest(Test $test, float $time): void { - if (!$test instanceof \PHPUnit\Framework\TestCase || $test instanceof \PHPUnit\Framework\Warning) { + if (!$test instanceof TestCase || $test instanceof Warning) { return; } $this->_eventManager->fireEvent('endTest', [$test], true); @@ -141,7 +150,7 @@ public function endTest(\PHPUnit\Framework\Test $test, $time) /** * {@inheritdoc} */ - public function addWarning(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\Warning $e, $time) + public function addWarning(Test $test, Warning $e, float $time): void { } } From 27066e8d0873309af30763939adaad39d3d6cee8 Mon Sep 17 00:00:00 2001 From: Michael Woodward Date: Sun, 8 Apr 2018 23:08:26 +0100 Subject: [PATCH 07/12] Upgrade PHPUnit to 7.1.1 --- composer.json | 2 +- composer.lock | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 901f3274422..39b075a9ec6 100644 --- a/composer.json +++ b/composer.json @@ -84,7 +84,7 @@ "lusitanian/oauth": "~0.8.10", "pdepend/pdepend": "2.5.2", "phpmd/phpmd": "@stable", - "phpunit/phpunit": "~7.0.0", + "phpunit/phpunit": "~7.1.0", "sebastian/phpcpd": "~4.0.0", "squizlabs/php_codesniffer": "3.2.2" }, diff --git a/composer.lock b/composer.lock index 271d45425f7..1519744ca5c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "c055928732e771373d317ded0337bc4a", + "content-hash": "9c9b884be5ca41942afe70e153aa8752", "packages": [ { "name": "braintree/braintree_php", @@ -5252,16 +5252,16 @@ }, { "name": "phpunit/phpunit", - "version": "7.0.3", + "version": "7.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "536f4d853c12d8189963435088e8ff7c0daeab2e" + "reference": "a7834993ddbf4b0ed2c3b2dc1f3b1d093ef910a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/536f4d853c12d8189963435088e8ff7c0daeab2e", - "reference": "536f4d853c12d8189963435088e8ff7c0daeab2e", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a7834993ddbf4b0ed2c3b2dc1f3b1d093ef910a9", + "reference": "a7834993ddbf4b0ed2c3b2dc1f3b1d093ef910a9", "shasum": "" }, "require": { @@ -5279,7 +5279,7 @@ "phpunit/php-file-iterator": "^1.4.3", "phpunit/php-text-template": "^1.2.1", "phpunit/php-timer": "^2.0", - "phpunit/phpunit-mock-objects": "^6.0", + "phpunit/phpunit-mock-objects": "^6.1.1", "sebastian/comparator": "^2.1", "sebastian/diff": "^3.0", "sebastian/environment": "^3.1", @@ -5302,7 +5302,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "7.0-dev" + "dev-master": "7.1-dev" } }, "autoload": { @@ -5328,7 +5328,7 @@ "testing", "xunit" ], - "time": "2018-03-26T07:36:48+00:00" + "time": "2018-04-13T02:28:50+00:00" }, { "name": "phpunit/phpunit-mock-objects", From 6187ec70c842de9b58fa881cdded0c9a1e5d27e0 Mon Sep 17 00:00:00 2001 From: Michael Woodward Date: Fri, 13 Apr 2018 23:25:35 +0100 Subject: [PATCH 08/12] Fix PHPUnit 7 class removals for InvokedCount and ReturnStub - Replace \PHPUnit_Framework_MockObject_Matcher_InvokedCount - Replace \PHPUnit_Framework_MockObject_Stub_Return --- .../Unit/ReportXml/DB/ReportValidatorTest.php | 4 ++-- .../Command/ConfigShow/ValueProcessorTest.php | 18 +++++++++--------- .../ElementVisibilityCompositeTest.php | 8 ++++---- .../Product/Form/Modifier/Data/LinksTest.php | 4 ++-- .../ResourceModel/Order/CollectionTest.php | 4 ++-- .../Report/Product/ViewedTest.php | 4 ++-- .../Order/Email/Sender/AbstractSenderTest.php | 4 ++-- .../TestFramework/Unit/Block/Adminhtml.php | 2 +- .../TestFramework/Unit/Helper/ProxyTesting.php | 4 ++-- .../Test/Unit/Element/AbstractBlockTest.php | 6 +++--- .../Test/Unit/Layout/Data/StructureTest.php | 2 +- .../Test/Unit/Layout/Generator/BlockTest.php | 8 ++++---- .../View/Test/Unit/Layout/Reader/BlockTest.php | 12 ++++++------ .../Test/Unit/Layout/Reader/ContainerTest.php | 6 +++--- .../Layout/ScheduledStructure/HelperTest.php | 2 +- .../View/Test/Unit/Result/LayoutTest.php | 4 ++-- 16 files changed, 46 insertions(+), 46 deletions(-) diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ReportValidatorTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ReportValidatorTest.php index d7dcf506205..ac141fae4be 100644 --- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ReportValidatorTest.php +++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ReportValidatorTest.php @@ -79,9 +79,9 @@ protected function setUp() * @dataProvider errorDataProvider * @param string $reportName * @param array $result - * @param \PHPUnit_Framework_MockObject_Stub $queryReturnStub + * @param \PHPUnit\Framework\MockObject\Stub $queryReturnStub */ - public function testValidate($reportName, $result, \PHPUnit_Framework_MockObject_Stub $queryReturnStub) + public function testValidate($reportName, $result, \PHPUnit\Framework\MockObject\Stub $queryReturnStub) { $connectionName = 'testConnection'; $this->queryFactoryMock->expects($this->once()) diff --git a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigShow/ValueProcessorTest.php b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigShow/ValueProcessorTest.php index cf758553e87..07dcc65493a 100644 --- a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigShow/ValueProcessorTest.php +++ b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigShow/ValueProcessorTest.php @@ -73,15 +73,15 @@ protected function setUp() /** * @param bool $hasBackendModel - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsGetBackendModel - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsCreate - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsGetValue - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsSetPath - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsSetScope - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsSetScopeId - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsSetValue - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsAfterLoad - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsSerialize + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $expectsGetBackendModel + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $expectsCreate + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $expectsGetValue + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $expectsSetPath + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $expectsSetScope + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $expectsSetScopeId + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $expectsSetValue + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $expectsAfterLoad + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $expectsSerialize * @param string $expectsValue * @param string $className * @param string $value diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ElementVisibilityCompositeTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ElementVisibilityCompositeTest.php index b779c29c931..d2a89a8abc7 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ElementVisibilityCompositeTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ElementVisibilityCompositeTest.php @@ -51,9 +51,9 @@ public function testException() } /** - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $firstExpects + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $firstExpects * @param bool $firstResult - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $secondExpects + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $secondExpects * @param bool $secondResult * @param bool $expectedResult * @dataProvider visibilityDataProvider @@ -74,9 +74,9 @@ public function testDisabled($firstExpects, $firstResult, $secondExpects, $secon } /** - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $firstExpects + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $firstExpects * @param bool $firstResult - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $secondExpects + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $secondExpects * @param bool $secondResult * @param bool $expectedResult * @dataProvider visibilityDataProvider diff --git a/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/Data/LinksTest.php b/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/Data/LinksTest.php index dd8e8ff38e9..93e691c9316 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/Data/LinksTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/Data/LinksTest.php @@ -98,8 +98,8 @@ protected function setUp() /** * @param int|null $id * @param string $typeId - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectedGetTitle - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectedGetValue + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $expectedGetTitle + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $expectedGetValue * @return void * @dataProvider getLinksTitleDataProvider */ diff --git a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Order/CollectionTest.php b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Order/CollectionTest.php index bf58e214ef4..3ad9827c7f4 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Order/CollectionTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Order/CollectionTest.php @@ -202,7 +202,7 @@ public function testCheckIsLive() * @param int $useAggregatedData * @param string $mainTable * @param int $isFilter - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $getIfNullSqlResult + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $getIfNullSqlResult * @dataProvider useAggregatedDataDataProvider * @return void */ @@ -309,7 +309,7 @@ public function testAddItemCountExpr() * @param int $isFilter * @param int $useAggregatedData * @param string $mainTable - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $getIfNullSqlResult + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $getIfNullSqlResult * @dataProvider totalsDataProvider * @return void */ diff --git a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Product/ViewedTest.php b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Product/ViewedTest.php index 17e13f9d64b..df9f0d21392 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Product/ViewedTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Product/ViewedTest.php @@ -190,8 +190,8 @@ function ($arg) { /** * @param mixed $from * @param mixed $to - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $truncateCount - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $deleteCount + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $truncateCount + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $deleteCount * @dataProvider intervalsDataProvider * @return void */ diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/AbstractSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/AbstractSenderTest.php index 97dc973e634..e6f507f87ec 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/AbstractSenderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/AbstractSenderTest.php @@ -157,8 +157,8 @@ public function stepIdentityContainerInit($identityMockClassName) } protected function stepSend( - \PHPUnit_Framework_MockObject_Matcher_InvokedCount $sendExpects, - \PHPUnit_Framework_MockObject_Matcher_InvokedCount $sendCopyToExpects + \PHPUnit\Framework\MockObject\Matcher\InvokedCount $sendExpects, + \PHPUnit\Framework\MockObject\Matcher\InvokedCount $sendCopyToExpects ) { $senderMock = $this->createPartialMock(\Magento\Sales\Model\Order\Email\Sender::class, ['send', 'sendCopyTo']); $senderMock->expects($sendExpects) diff --git a/lib/internal/Magento/Framework/TestFramework/Unit/Block/Adminhtml.php b/lib/internal/Magento/Framework/TestFramework/Unit/Block/Adminhtml.php index 08d618637db..53b5fd9e1d9 100644 --- a/lib/internal/Magento/Framework/TestFramework/Unit/Block/Adminhtml.php +++ b/lib/internal/Magento/Framework/TestFramework/Unit/Block/Adminhtml.php @@ -197,7 +197,7 @@ protected function _makeMock($className) * @param \PHPUnit_Framework_MockObject_MockObject $object * @param string $stubName * @param mixed $return - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount|null $expects + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount|null $expects * * @return \PHPUnit_Framework_MockObject_Builder_InvocationMocker */ diff --git a/lib/internal/Magento/Framework/TestFramework/Unit/Helper/ProxyTesting.php b/lib/internal/Magento/Framework/TestFramework/Unit/Helper/ProxyTesting.php index 0dc4d490280..3085770980d 100644 --- a/lib/internal/Magento/Framework/TestFramework/Unit/Helper/ProxyTesting.php +++ b/lib/internal/Magento/Framework/TestFramework/Unit/Helper/ProxyTesting.php @@ -40,12 +40,12 @@ public function invokeWithExpectations( $expectedParams = $params; } $builder = $proxiedObject->expects( - new \PHPUnit_Framework_MockObject_Matcher_InvokedCount(1) + new \PHPUnit\Framework\MockObject\Matcher\InvokedCount(1) )->method( $expectedMethod ); $builder = call_user_func_array([$builder, 'with'], $expectedParams); - $builder->will(new \PHPUnit_Framework_MockObject_Stub_Return($proxiedResult)); + $builder->will(new \PHPUnit\Framework\MockObject\Stub\ReturnStub($proxiedResult)); return call_user_func_array([$object, $method], $params); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php index a3f34b732be..70233c0196d 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php @@ -220,9 +220,9 @@ public function testToHtmlWhenModuleIsDisabled() * @param string|bool $cacheLifetime * @param string|bool $dataFromCache * @param string $dataForSaveCache - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsDispatchEvent - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsCacheLoad - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsCacheSave + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $expectsDispatchEvent + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $expectsCacheLoad + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $expectsCacheSave * @param string $expectedResult * @return void * @dataProvider getCacheLifetimeDataProvider diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Data/StructureTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Data/StructureTest.php index 703334f896d..ab623e59d37 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Data/StructureTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Data/StructureTest.php @@ -49,7 +49,7 @@ protected function setUp() } /** - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $loggerExpects + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $loggerExpects * @param string $stateMode * @return void * @dataProvider reorderChildElementLogDataProvider diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Generator/BlockTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Generator/BlockTest.php index 4db2da1c1ec..2a53dbe352c 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Generator/BlockTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Generator/BlockTest.php @@ -20,10 +20,10 @@ class BlockTest extends \PHPUnit\Framework\TestCase * @param array $testArgumentData * @param bool $testIsFlag * @param bool $isNeedEvaluate - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $addToParentGroupCount - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $setTemplateCount - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $setTtlCount - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $setIsFlag + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $addToParentGroupCount + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $setTemplateCount + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $setTtlCount + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $setIsFlag * @dataProvider provider * * @SuppressWarnings(PHPMD.ExcessiveMethodLength) diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/BlockTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/BlockTest.php index e69e778c855..ac1dd43f4dd 100755 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/BlockTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/BlockTest.php @@ -89,11 +89,11 @@ protected function setUp() /** * @param string $literal - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $scheduleStructureCount + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $scheduleStructureCount * @param string $ifconfigValue * @param array $expectedConditions - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $getCondition - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $setCondition + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $getCondition + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $setCondition * @param string $aclKey * @param string $aclValue * @@ -238,9 +238,9 @@ public function processBlockDataProvider() /** * @param string $literal * @param string $remove - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $getCondition - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $setCondition - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $setRemoveCondition + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $getCondition + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $setCondition + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $setRemoveCondition * @dataProvider processReferenceDataProvider */ public function testProcessReference( diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/ContainerTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/ContainerTest.php index e4834accbcc..1a3b77f1e78 100755 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/ContainerTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/ContainerTest.php @@ -56,9 +56,9 @@ protected function setUp() * @param string $containerName * @param array $structureElement * @param array $expectedData - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $getStructureCondition - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $setStructureCondition - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $setRemoveCondition + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $getStructureCondition + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $setStructureCondition + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $setRemoveCondition * * @dataProvider processDataProvider */ diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/ScheduledStructure/HelperTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/ScheduledStructure/HelperTest.php index 6421610c6db..401492a774a 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/ScheduledStructure/HelperTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/ScheduledStructure/HelperTest.php @@ -144,7 +144,7 @@ public function testScheduleNonExistentElement() } /** - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $loggerExpects + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $loggerExpects * @param string $stateMode * @return void * @dataProvider scheduleElementLogDataProvider diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Result/LayoutTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Result/LayoutTest.php index 8b6e8d41b56..d40d65dd2de 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Result/LayoutTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Result/LayoutTest.php @@ -98,8 +98,8 @@ public function testAddUpdate() * @param string $headerName * @param string $headerValue * @param bool $replaceHeader - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $setHttpResponseCodeCount - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $setHeaderCount + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $setHttpResponseCodeCount + * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $setHeaderCount * @dataProvider renderResultDataProvider */ public function testRenderResult( From f12ae1568986dff370c215b3322e0613e3250225 Mon Sep 17 00:00:00 2001 From: Michael Woodward Date: Fri, 13 Apr 2018 23:46:53 +0100 Subject: [PATCH 09/12] Fix carrier test Replaced hardcoded broken assertion --- app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php index 6fa063d2c27..6b8430fcd5c 100644 --- a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php @@ -366,8 +366,8 @@ public function testCollectRatesFail() $request = new RateRequest(); $request->setPackageWeight(1); - - $this->assertFalse(false, $this->model->collectRates($request)); + + $this->assertTrue($this->model->collectRates($request)->getError()); } /** From fd14539e74c313e719ae58fbd63dda381f6698dc Mon Sep 17 00:00:00 2001 From: Michael Woodward Date: Sat, 14 Apr 2018 13:43:05 +0100 Subject: [PATCH 10/12] Fix static test for LinkTest --- .../Framework/View/Test/Unit/Element/Html/LinkTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php index 142c029cc91..201dbb9119c 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php @@ -103,10 +103,13 @@ public function getLinkAttributesDataProvider() $linkWithAttributes->setDataUsingMethod($attribute, $attribute); } + $expectedFull = 'href="http://site.com/link.html" shape="shape" '; + $expectedFull .= 'tabindex="tabindex" onfocus="onfocus" onblur="onblur" id="id"'; + return [ 'full' => [ 'link' => $linkWithAttributes, - 'expected' => 'href="http://site.com/link.html" shape="shape" tabindex="tabindex" onfocus="onfocus" onblur="onblur" id="id"', + 'expected' => $expectedFull, ], 'empty' => [ 'link' => $linkWithoutAttributes, From 1dba0d09e4031b817179284517c314ba0742a8f3 Mon Sep 17 00:00:00 2001 From: Michael Woodward Date: Tue, 17 Apr 2018 08:21:20 +0100 Subject: [PATCH 11/12] Fix bad assertions in grid integration tests --- .../Magento/UrlRewrite/Block/Catalog/Product/GridTest.php | 2 +- .../testsuite/Magento/UrlRewrite/Block/Cms/Page/GridTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Catalog/Product/GridTest.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Catalog/Product/GridTest.php index d3d96c3862a..4780cf46684 100644 --- a/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Catalog/Product/GridTest.php +++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Catalog/Product/GridTest.php @@ -42,7 +42,7 @@ public function testPrepareGrid() ); $this->assertStringEndsWith('/category', $gridBlock->getRowUrl($row), 'Grid row URL is invalid'); - $this->assertEmpty(0, $gridBlock->getMassactionBlock()->getItems(), 'Grid should not have mass action items'); + $this->assertEmpty($gridBlock->getMassactionBlock()->getItems(), 'Grid should not have mass action items'); $this->assertTrue($gridBlock->getUseAjax(), '"use_ajax" value of grid is incorrect'); } } diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Cms/Page/GridTest.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Cms/Page/GridTest.php index 3fbb5d3be17..c0f3f9b4641 100644 --- a/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Cms/Page/GridTest.php +++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Cms/Page/GridTest.php @@ -41,7 +41,7 @@ public function testPrepareGrid() 'Grid row URL is invalid' ); - $this->assertEmpty(0, $gridBlock->getMassactionBlock()->getItems(), 'Grid should not have mass action items'); + $this->assertEmpty($gridBlock->getMassactionBlock()->getItems(), 'Grid should not have mass action items'); $this->assertTrue($gridBlock->getUseAjax(), '"use_ajax" value of grid is incorrect'); } From 0b6d46757065efb552c0cf5b13bd3d4502a3a40d Mon Sep 17 00:00:00 2001 From: Michael Woodward Date: Tue, 17 Apr 2018 14:15:55 +0100 Subject: [PATCH 12/12] Ignore unused paramater for MethodInvokedAtIndex::invoked --- .../TestFramework/Unit/Matcher/MethodInvokedAtIndex.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/TestFramework/Unit/Matcher/MethodInvokedAtIndex.php b/lib/internal/Magento/Framework/TestFramework/Unit/Matcher/MethodInvokedAtIndex.php index 8a6ab07d154..3eafd0fac1b 100644 --- a/lib/internal/Magento/Framework/TestFramework/Unit/Matcher/MethodInvokedAtIndex.php +++ b/lib/internal/Magento/Framework/TestFramework/Unit/Matcher/MethodInvokedAtIndex.php @@ -28,7 +28,7 @@ class MethodInvokedAtIndex implements \PHPUnit\Framework\MockObject\Matcher\Invo */ protected $indexes = []; - /** + /**PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex * @var int */ private $currentIndex = -1; @@ -95,6 +95,7 @@ public function verify(): void /** * @param Invocation $invocation Object containing information on a mocked or stubbed method which was invoked * @return mixed + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function invoked(Invocation $invocation) {