diff --git a/composer.json b/composer.json index 7bf33f9d..49fd9751 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,7 @@ }, "require-dev": { "phpunit/phpunit": "^6.5.0", + "ext-dom": "*", "squizlabs/php_codesniffer": "^3.5" }, "autoload": { diff --git a/composer.lock b/composer.lock index 89503de3..783e7271 100644 --- a/composer.lock +++ b/composer.lock @@ -4,27 +4,27 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "83b926ad9471c996f7224a1ffef6d148", + "content-hash": "0dff7ec282a94e353a4a10287477a020", "packages": [ { "name": "hassankhan/config", - "version": "v2.1.0", + "version": "2.2.0", "source": { "type": "git", "url": "https://github.com/hassankhan/config.git", - "reference": "16fa4d3320ac9bb611dda0c8ea980edb58d227c9" + "reference": "62b0fd17540136efa94ab6b39f04044c6dc5e4a7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/hassankhan/config/zipball/16fa4d3320ac9bb611dda0c8ea980edb58d227c9", - "reference": "16fa4d3320ac9bb611dda0c8ea980edb58d227c9", + "url": "https://api.github.com/repos/hassankhan/config/zipball/62b0fd17540136efa94ab6b39f04044c6dc5e4a7", + "reference": "62b0fd17540136efa94ab6b39f04044c6dc5e4a7", "shasum": "" }, "require": { "php": ">=5.5.9" }, "require-dev": { - "phpunit/phpunit": "~4.8 || ~5.7 || ~6.5 || ~7.5", + "phpunit/phpunit": "~4.8.36 || ~5.7 || ~6.5 || ~7.5", "scrutinizer/ocular": "~1.1", "squizlabs/php_codesniffer": "~2.2", "symfony/yaml": "~3.4" @@ -62,7 +62,7 @@ "yaml", "yml" ], - "time": "2019-09-01T15:51:42+00:00" + "time": "2020-12-07T16:04:15+00:00" }, { "name": "nikic/php-parser", @@ -214,24 +214,25 @@ }, { "name": "sabre/uri", - "version": "2.2.0", + "version": "2.2.1", "source": { "type": "git", "url": "https://github.com/sabre-io/uri.git", - "reference": "059d11012603be2e32ddb7543602965563ddbb09" + "reference": "f502edffafea8d746825bd5f0b923a60fd2715ff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sabre-io/uri/zipball/059d11012603be2e32ddb7543602965563ddbb09", - "reference": "059d11012603be2e32ddb7543602965563ddbb09", + "url": "https://api.github.com/repos/sabre-io/uri/zipball/f502edffafea8d746825bd5f0b923a60fd2715ff", + "reference": "f502edffafea8d746825bd5f0b923a60fd2715ff", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "~2.16.1", - "phpunit/phpunit": "^7 || ^8" + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.0" }, "type": "library", "autoload": { @@ -261,20 +262,20 @@ "uri", "url" ], - "time": "2020-01-31T18:53:43+00:00" + "time": "2020-10-03T10:33:23+00:00" }, { "name": "sabre/xml", - "version": "2.2.1", + "version": "2.2.3", "source": { "type": "git", "url": "https://github.com/sabre-io/xml.git", - "reference": "41c6ba148966b10cafd31d1a4e5feb1e2138d95c" + "reference": "c3b959f821c19b36952ec4a595edd695c216bfc6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sabre-io/xml/zipball/41c6ba148966b10cafd31d1a4e5feb1e2138d95c", - "reference": "41c6ba148966b10cafd31d1a4e5feb1e2138d95c", + "url": "https://api.github.com/repos/sabre-io/xml/zipball/c3b959f821c19b36952ec4a595edd695c216bfc6", + "reference": "c3b959f821c19b36952ec4a595edd695c216bfc6", "shasum": "" }, "require": { @@ -282,7 +283,7 @@ "ext-xmlreader": "*", "ext-xmlwriter": "*", "lib-libxml": ">=2.6.20", - "php": "^7.1", + "php": "^7.1 || ^8.0", "sabre/uri": ">=1.0,<3.0.0" }, "require-dev": { @@ -325,20 +326,20 @@ "dom", "xml" ], - "time": "2020-05-11T09:44:55+00:00" + "time": "2020-10-03T10:08:14+00:00" }, { "name": "symfony/console", - "version": "v4.4.10", + "version": "v4.4.19", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "326b064d804043005526f5a0494cfb49edb59bb0" + "reference": "24026c44fc37099fa145707fecd43672831b837a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/326b064d804043005526f5a0494cfb49edb59bb0", - "reference": "326b064d804043005526f5a0494cfb49edb59bb0", + "url": "https://api.github.com/repos/symfony/console/zipball/24026c44fc37099fa145707fecd43672831b837a", + "reference": "24026c44fc37099fa145707fecd43672831b837a", "shasum": "" }, "require": { @@ -373,11 +374,6 @@ "symfony/process": "" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.4-dev" - } - }, "autoload": { "psr-4": { "Symfony\\Component\\Console\\": "" @@ -400,26 +396,40 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Console Component", + "description": "Eases the creation of beautiful and testable command line interfaces", "homepage": "https://symfony.com", - "time": "2020-05-30T20:06:45+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-01-27T09:09:26+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.17.0", + "version": "v1.22.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9" + "reference": "c6c942b1ac76c82448322025e084cadc56048b4e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e94c8b1bbe2bc77507a1056cdb06451c75b427f9", - "reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/c6c942b1ac76c82448322025e084cadc56048b4e", + "reference": "c6c942b1ac76c82448322025e084cadc56048b4e", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" }, "suggest": { "ext-ctype": "For best performance" @@ -427,7 +437,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-main": "1.22-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -460,24 +474,38 @@ "polyfill", "portable" ], - "time": "2020-05-12T16:14:59+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-01-07T16:49:33+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.17.0", + "version": "v1.22.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "fa79b11539418b02fc5e1897267673ba2c19419c" + "reference": "f377a3dd1fde44d37b9831d68dc8dea3ffd28e13" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fa79b11539418b02fc5e1897267673ba2c19419c", - "reference": "fa79b11539418b02fc5e1897267673ba2c19419c", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f377a3dd1fde44d37b9831d68dc8dea3ffd28e13", + "reference": "f377a3dd1fde44d37b9831d68dc8dea3ffd28e13", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" }, "suggest": { "ext-mbstring": "For best performance" @@ -485,7 +513,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-main": "1.22-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -519,29 +551,47 @@ "portable", "shim" ], - "time": "2020-05-12T16:47:27+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-01-07T16:49:33+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.17.0", + "version": "v1.22.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "a760d8964ff79ab9bf057613a5808284ec852ccc" + "reference": "a678b42e92f86eca04b7fa4c0f6f19d097fb69e2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/a760d8964ff79ab9bf057613a5808284ec852ccc", - "reference": "a760d8964ff79ab9bf057613a5808284ec852ccc", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/a678b42e92f86eca04b7fa4c0f6f19d097fb69e2", + "reference": "a678b42e92f86eca04b7fa4c0f6f19d097fb69e2", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-main": "1.22-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -577,29 +627,47 @@ "portable", "shim" ], - "time": "2020-05-12T16:47:27+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-01-07T16:49:33+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.17.0", + "version": "v1.22.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "5e30b2799bc1ad68f7feb62b60a73743589438dd" + "reference": "dc3063ba22c2a1fd2f45ed856374d79114998f91" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/5e30b2799bc1ad68f7feb62b60a73743589438dd", - "reference": "5e30b2799bc1ad68f7feb62b60a73743589438dd", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/dc3063ba22c2a1fd2f45ed856374d79114998f91", + "reference": "dc3063ba22c2a1fd2f45ed856374d79114998f91", "shasum": "" }, "require": { - "php": ">=7.0.8" + "php": ">=7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-main": "1.22-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -639,20 +707,34 @@ "portable", "shim" ], - "time": "2020-05-12T16:47:27+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-01-07T16:49:33+00:00" }, { "name": "symfony/service-contracts", - "version": "v2.1.2", + "version": "v2.2.0", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "66a8f0957a3ca54e4f724e49028ab19d75a8918b" + "reference": "d15da7ba4957ffb8f1747218be9e1a121fd298a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/66a8f0957a3ca54e4f724e49028ab19d75a8918b", - "reference": "66a8f0957a3ca54e4f724e49028ab19d75a8918b", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/d15da7ba4957ffb8f1747218be9e1a121fd298a1", + "reference": "d15da7ba4957ffb8f1747218be9e1a121fd298a1", "shasum": "" }, "require": { @@ -665,7 +747,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -697,20 +783,34 @@ "interoperability", "standards" ], - "time": "2020-05-20T17:43:50+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-09-07T11:33:47+00:00" }, { "name": "symfony/yaml", - "version": "v4.4.10", + "version": "v4.4.19", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "c2d2cc66e892322cfcc03f8f12f8340dbd7a3f8a" + "reference": "17ed9f14c1aa05b1a5cf2e2c5ef2d0be28058ef9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/c2d2cc66e892322cfcc03f8f12f8340dbd7a3f8a", - "reference": "c2d2cc66e892322cfcc03f8f12f8340dbd7a3f8a", + "url": "https://api.github.com/repos/symfony/yaml/zipball/17ed9f14c1aa05b1a5cf2e2c5ef2d0be28058ef9", + "reference": "17ed9f14c1aa05b1a5cf2e2c5ef2d0be28058ef9", "shasum": "" }, "require": { @@ -727,11 +827,6 @@ "symfony/console": "For validating YAML files using the lint command" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.4-dev" - } - }, "autoload": { "psr-4": { "Symfony\\Component\\Yaml\\": "" @@ -754,9 +849,23 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Yaml Component", + "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", - "time": "2020-05-20T08:37:50+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-01-27T09:09:26+00:00" }, { "name": "tomzx/finder", @@ -979,36 +1088,31 @@ "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.3.1", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "f350df0268e904597e3bd9c4685c53e0e333feea" + "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f350df0268e904597e3bd9c4685c53e0e333feea", - "reference": "f350df0268e904597e3bd9c4685c53e0e333feea", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b", + "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^6.0", + "doctrine/coding-standard": "^8.0", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.13", - "phpstan/phpstan-phpunit": "^0.11", - "phpstan/phpstan-shim": "^0.11", - "phpunit/phpunit": "^7.0" + "phpbench/phpbench": "^0.13 || 1.0.0-alpha2", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-phpunit": "^0.12", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, "autoload": { "psr-4": { "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" @@ -1022,7 +1126,7 @@ { "name": "Marco Pivetta", "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" + "homepage": "https://ocramius.github.io/" } ], "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", @@ -1031,24 +1135,38 @@ "constructor", "instantiate" ], - "time": "2020-05-29T17:27:14+00:00" + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], + "time": "2020-11-10T18:47:58+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.9.5", + "version": "1.10.2", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef" + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/b2c28789e80a97badd14145fda39b545d83ca3ef", - "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220", + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "replace": { "myclabs/deep-copy": "self.version" @@ -1079,7 +1197,13 @@ "object", "object graph" ], - "time": "2020-01-17T21:11:47+00:00" + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2020-11-13T09:40:50+00:00" }, { "name": "phar-io/manifest", @@ -1185,25 +1309,25 @@ }, { "name": "phpdocumentor/reflection-common", - "version": "2.1.0", + "version": "2.2.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b" + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/6568f4687e5b41b054365f9ae03fcb1ed5f2069b", - "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", "shasum": "" }, "require": { - "php": ">=7.1" + "php": "^7.2 || ^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-2.x": "2.x-dev" } }, "autoload": { @@ -1230,32 +1354,31 @@ "reflection", "static analysis" ], - "time": "2020-04-27T09:25:28+00:00" + "time": "2020-06-27T09:03:43+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.1.0", + "version": "5.2.2", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e" + "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", - "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556", + "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556", "shasum": "" }, "require": { - "ext-filter": "^7.1", - "php": "^7.2", - "phpdocumentor/reflection-common": "^2.0", - "phpdocumentor/type-resolver": "^1.0", - "webmozart/assert": "^1" + "ext-filter": "*", + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.2", + "phpdocumentor/type-resolver": "^1.3", + "webmozart/assert": "^1.9.1" }, "require-dev": { - "doctrine/instantiator": "^1", - "mockery/mockery": "^1" + "mockery/mockery": "~1.3.2" }, "type": "library", "extra": { @@ -1283,34 +1406,33 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2020-02-22T12:28:44+00:00" + "time": "2020-09-03T19:13:55+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.1.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "7462d5f123dfc080dfdf26897032a6513644fc95" + "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/7462d5f123dfc080dfdf26897032a6513644fc95", - "reference": "7462d5f123dfc080dfdf26897032a6513644fc95", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", + "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", "shasum": "" }, "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "ext-tokenizer": "^7.2", - "mockery/mockery": "~1" + "ext-tokenizer": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.x-dev" + "dev-1.x": "1.x-dev" } }, "autoload": { @@ -1329,7 +1451,7 @@ } ], "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "time": "2020-02-18T18:59:58+00:00" + "time": "2020-09-17T18:55:26+00:00" }, { "name": "phpspec/prophecy", @@ -1790,23 +1912,23 @@ }, { "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" + "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/1de8cd5c010cb153fcd68b8d0f64606f523f7619", + "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": ">=5.6" }, "require-dev": { - "phpunit/phpunit": "^5.7 || ^6.0" + "phpunit/phpunit": "^8.5" }, "type": "library", "extra": { @@ -1831,7 +1953,13 @@ ], "description": "Looks up which function or method a line of code belongs to", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "time": "2017-03-04T06:30:41+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T08:15:22+00:00" }, { "name": "sebastian/comparator", @@ -2001,20 +2129,20 @@ }, { "name": "sebastian/exporter", - "version": "3.1.2", + "version": "3.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e" + "reference": "6b853149eab67d4da22291d36f5b0631c0fd856e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/68609e1261d215ea5b21b7987539cbfbe156ec3e", - "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/6b853149eab67d4da22291d36f5b0631c0fd856e", + "reference": "6b853149eab67d4da22291d36f5b0631c0fd856e", "shasum": "" }, "require": { - "php": "^7.0", + "php": ">=7.0", "sebastian/recursion-context": "^3.0" }, "require-dev": { @@ -2064,7 +2192,13 @@ "export", "exporter" ], - "time": "2019-09-14T09:02:43+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T07:47:53+00:00" }, { "name": "sebastian/global-state", @@ -2119,20 +2253,20 @@ }, { "name": "sebastian/object-enumerator", - "version": "3.0.3", + "version": "3.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" + "reference": "e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2", + "reference": "e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2", "shasum": "" }, "require": { - "php": "^7.0", + "php": ">=7.0", "sebastian/object-reflector": "^1.1.1", "sebastian/recursion-context": "^3.0" }, @@ -2162,24 +2296,30 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2017-08-03T12:35:26+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T07:40:27+00:00" }, { "name": "sebastian/object-reflector", - "version": "1.1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "773f97c67f28de00d397be301821b06708fca0be" + "reference": "9b8772b9cbd456ab45d4a598d2dd1a1bced6363d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", - "reference": "773f97c67f28de00d397be301821b06708fca0be", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/9b8772b9cbd456ab45d4a598d2dd1a1bced6363d", + "reference": "9b8772b9cbd456ab45d4a598d2dd1a1bced6363d", "shasum": "" }, "require": { - "php": "^7.0" + "php": ">=7.0" }, "require-dev": { "phpunit/phpunit": "^6.0" @@ -2207,24 +2347,30 @@ ], "description": "Allows reflection of object attributes, including inherited and non-public ones", "homepage": "https://github.com/sebastianbergmann/object-reflector/", - "time": "2017-03-29T09:07:27+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T07:37:18+00:00" }, { "name": "sebastian/recursion-context", - "version": "3.0.0", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" + "reference": "367dcba38d6e1977be014dc4b22f47a484dac7fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/367dcba38d6e1977be014dc4b22f47a484dac7fb", + "reference": "367dcba38d6e1977be014dc4b22f47a484dac7fb", "shasum": "" }, "require": { - "php": "^7.0" + "php": ">=7.0" }, "require-dev": { "phpunit/phpunit": "^6.0" @@ -2245,14 +2391,14 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de" }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, { "name": "Adam Harvey", "email": "aharvey@php.net" @@ -2260,7 +2406,13 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2017-03-03T06:23:57+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T07:34:24+00:00" }, { "name": "sebastian/resource-operations", @@ -2349,16 +2501,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.5.5", + "version": "3.5.8", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "73e2e7f57d958e7228fce50dc0c61f58f017f9f6" + "reference": "9d583721a7157ee997f235f327de038e7ea6dac4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/73e2e7f57d958e7228fce50dc0c61f58f017f9f6", - "reference": "73e2e7f57d958e7228fce50dc0c61f58f017f9f6", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/9d583721a7157ee997f235f327de038e7ea6dac4", + "reference": "9d583721a7157ee997f235f327de038e7ea6dac4", "shasum": "" }, "require": { @@ -2396,27 +2548,27 @@ "phpcs", "standards" ], - "time": "2020-04-17T01:09:41+00:00" + "time": "2020-10-23T02:01:07+00:00" }, { "name": "theseer/tokenizer", - "version": "1.1.3", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9" + "reference": "75a63c33a8577608444246075ea0af0d052e452a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/11336f6f84e16a720dae9d8e6ed5019efa85a0f9", - "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/75a63c33a8577608444246075ea0af0d052e452a", + "reference": "75a63c33a8577608444246075ea0af0d052e452a", "shasum": "" }, "require": { "ext-dom": "*", "ext-tokenizer": "*", "ext-xmlwriter": "*", - "php": "^7.0" + "php": "^7.2 || ^8.0" }, "type": "library", "autoload": { @@ -2436,24 +2588,30 @@ } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", - "time": "2019-06-13T22:48:21+00:00" + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2020-07-12T23:59:07+00:00" }, { "name": "webmozart/assert", - "version": "1.9.0", + "version": "1.9.1", "source": { "type": "git", - "url": "https://github.com/webmozart/assert.git", - "reference": "9dc4f203e36f2b486149058bade43c851dd97451" + "url": "https://github.com/webmozarts/assert.git", + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/9dc4f203e36f2b486149058bade43c851dd97451", - "reference": "9dc4f203e36f2b486149058bade43c851dd97451", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0", + "php": "^5.3.3 || ^7.0 || ^8.0", "symfony/polyfill-ctype": "^1.8" }, "conflict": { @@ -2485,7 +2643,7 @@ "check", "validate" ], - "time": "2020-06-16T10:16:42+00:00" + "time": "2020-07-08T17:02:28+00:00" } ], "aliases": [], @@ -2497,6 +2655,8 @@ "php": "~7.2.29||~7.3.0||~7.4.0", "ext-json": "*" }, - "platform-dev": [], + "platform-dev": { + "ext-dom": "*" + }, "plugin-api-version": "1.1.0" } diff --git a/src/Analyzer/DBSchema/DbSchemaColumnAnalyzer.php b/src/Analyzer/DBSchema/DbSchemaColumnAnalyzer.php index 613d894b..d0b8af95 100644 --- a/src/Analyzer/DBSchema/DbSchemaColumnAnalyzer.php +++ b/src/Analyzer/DBSchema/DbSchemaColumnAnalyzer.php @@ -58,19 +58,21 @@ public function analyze($registryBefore, $registryAfter) foreach ($registryTablesBefore as $moduleName => $moduleTables) { foreach ($moduleTables as $tableName => $tableData) { + $fileBefore = $registryBefore->mapping['table'][$moduleName]; $columns = $tableData['column'] ?? []; foreach ($columns as $column) { if ( isset($registryTablesAfter[$moduleName][$tableName]) && !isset($registryTablesAfter[$moduleName][$tableName]['column'][$column]) ) { - $operation = new ColumnRemove($moduleName, $tableName . '/' . $column); + $operation = new ColumnRemove($fileBefore, $tableName . '/' . $column); $this->getReport()->add($this->context, $operation); } } } } foreach ($registryTablesAfter as $moduleName => $moduleTables) { + $fileAfter = $registryAfter->mapping['table'][$moduleName]; foreach ($moduleTables as $tableName => $tableData) { $columns = $tableData['column'] ?? []; foreach ($columns as $column) { @@ -78,7 +80,7 @@ public function analyze($registryBefore, $registryAfter) isset($registryTablesBefore[$moduleName][$tableName]) && !isset($registryTablesBefore[$moduleName][$tableName]['column'][$column]) ) { - $operation = new ColumnAdd($moduleName, $tableName . '/' . $column); + $operation = new ColumnAdd($fileAfter, $tableName . '/' . $column); $this->getReport()->add($this->context, $operation); } } diff --git a/src/Analyzer/DBSchema/DbSchemaForeignKeyAnalyzer.php b/src/Analyzer/DBSchema/DbSchemaForeignKeyAnalyzer.php index ad37915d..7a362aef 100644 --- a/src/Analyzer/DBSchema/DbSchemaForeignKeyAnalyzer.php +++ b/src/Analyzer/DBSchema/DbSchemaForeignKeyAnalyzer.php @@ -56,6 +56,7 @@ public function analyze($registryBefore, $registryAfter) $registryTablesAfter = $registryAfter->data['table'] ?? []; foreach ($registryTablesBefore as $moduleName => $moduleTables) { + $fileBefore = $registryBefore->mapping['table'][$moduleName]; foreach ($moduleTables as $tableName => $tableData) { $keys = $tableData['foreign'] ?? []; foreach ($keys as $name => $key) { @@ -63,13 +64,13 @@ public function analyze($registryBefore, $registryAfter) continue; } if ($key !== null && !isset($registryTablesAfter[$moduleName][$tableName]['foreign'][$name])) { - $operation = new ForeignKeyDrop($moduleName, $tableName . '/' . $name); + $operation = new ForeignKeyDrop($fileBefore, $tableName . '/' . $name); $this->getReport()->add($this->context, $operation); continue; } foreach ($key as $item => $value) { if ($value !== $registryTablesAfter[$moduleName][$tableName]['foreign'][$name][$item]) { - $operation = new ForeignKeyChange($moduleName, $tableName . '/' . $name . '/' . $item); + $operation = new ForeignKeyChange($fileBefore, $tableName . '/' . $name . '/' . $item); $this->getReport()->add($this->context, $operation); } } @@ -78,6 +79,7 @@ public function analyze($registryBefore, $registryAfter) } foreach ($registryTablesAfter as $moduleName => $moduleTables) { + $fileAfter = $registryAfter->mapping['table'][$moduleName]; foreach ($moduleTables as $tableName => $tableData) { $keys = $tableData['foreign'] ?? []; foreach ($keys as $name => $key) { @@ -85,7 +87,7 @@ public function analyze($registryBefore, $registryAfter) continue; } if ($key !== null && !isset($registryTablesBefore[$moduleName][$tableName]['foreign'][$name])) { - $operation = new ForeignKeyAdd($moduleName, $tableName . '/' . $name); + $operation = new ForeignKeyAdd($fileAfter, $tableName . '/' . $name); $this->getReport()->add($this->context, $operation); } } diff --git a/src/Analyzer/DBSchema/DbSchemaPrimaryKeyAnalyzer.php b/src/Analyzer/DBSchema/DbSchemaPrimaryKeyAnalyzer.php index 42812ffe..83ffb85b 100644 --- a/src/Analyzer/DBSchema/DbSchemaPrimaryKeyAnalyzer.php +++ b/src/Analyzer/DBSchema/DbSchemaPrimaryKeyAnalyzer.php @@ -55,6 +55,7 @@ public function analyze($registryBefore, $registryAfter) $registryTablesAfter = $registryAfter->data['table'] ?? []; foreach ($registryTablesBefore as $moduleName => $moduleTables) { + $fileBefore = $registryBefore->mapping['table'][$moduleName]; foreach ($moduleTables as $tableName => $tableData) { $keys = $tableData['primary'] ?? []; foreach ($keys as $name => $key) { @@ -62,7 +63,7 @@ public function analyze($registryBefore, $registryAfter) continue; } if ($key !== null && !isset($registryTablesAfter[$moduleName][$tableName]['primary'][$name])) { - $operation = new PrimaryKeyDrop($moduleName, $tableName . '/' . $name); + $operation = new PrimaryKeyDrop($fileBefore, $tableName . '/' . $name); $this->getReport()->add($this->context, $operation); continue; } @@ -76,7 +77,7 @@ public function analyze($registryBefore, $registryAfter) } } if (!$matchedColumnFlag) { - $operation = new PrimaryKeyChange($moduleName, $tableName . '/' . $name); + $operation = new PrimaryKeyChange($fileBefore, $tableName . '/' . $name); $this->getReport()->add($this->context, $operation); break; } @@ -86,6 +87,7 @@ public function analyze($registryBefore, $registryAfter) } foreach ($registryTablesAfter as $moduleName => $moduleTables) { + $fileAfter = $registryAfter->mapping['table'][$moduleName]; foreach ($moduleTables as $tableName => $tableData) { $keys = $tableData['primary'] ?? []; foreach ($keys as $name => $key) { @@ -93,7 +95,7 @@ public function analyze($registryBefore, $registryAfter) continue; } if ($key !== null && !isset($registryTablesBefore[$moduleName][$tableName]['primary'][$name])) { - $operation = new PrimaryKeyAdd($moduleName, $tableName . '/' . $name); + $operation = new PrimaryKeyAdd($fileAfter, $tableName . '/' . $name); $this->getReport()->add($this->context, $operation); continue; } @@ -108,7 +110,7 @@ public function analyze($registryBefore, $registryAfter) } } if (!$matchedColumnFlag) { - $operation = new PrimaryKeyChange($moduleName, $tableName . '/' . $name); + $operation = new PrimaryKeyChange($fileAfter, $tableName . '/' . $name); $this->getReport()->add($this->context, $operation); break; } diff --git a/src/Analyzer/DBSchema/DbSchemaTableAnalyzer.php b/src/Analyzer/DBSchema/DbSchemaTableAnalyzer.php index 662abec2..aa16d4ad 100644 --- a/src/Analyzer/DBSchema/DbSchemaTableAnalyzer.php +++ b/src/Analyzer/DBSchema/DbSchemaTableAnalyzer.php @@ -55,15 +55,16 @@ public function analyze($registryBefore, $registryAfter) $registryTablesAfter = $registryAfter->data['table'] ?? []; foreach ($registryTablesBefore as $moduleName => $moduleTables) { + $fileBefore = $registryBefore->mapping['table'][$moduleName]; foreach ($moduleTables as $tableName => $tableData) { if (!isset($registryTablesAfter[$moduleName][$tableName])) { - $operation = new TableDropped($moduleName, $tableName); + $operation = new TableDropped($fileBefore, $tableName); $this->getReport()->add($this->context, $operation); continue; } if ($tableData['resource'] !== $registryTablesAfter[$moduleName][$tableName]['resource']) { $operation = new TableChangeResource( - $moduleName, + $fileBefore, $tableName, $tableData['resource'], $registryTablesAfter[$moduleName][$tableName]['resource'] @@ -73,12 +74,13 @@ public function analyze($registryBefore, $registryAfter) } } foreach ($registryTablesAfter as $moduleName => $moduleTables) { + $fileAfter = $registryAfter->mapping['table'][$moduleName]; foreach ($moduleTables as $tableName => $tableData) { if ( !isset($registryTablesBefore[$moduleName][$tableName]) && !$this->isModificationTableDeclaration($registryTablesAfter, $moduleName, $tableName) ) { - $operation = new TableAdded($moduleName, $tableName); + $operation = new TableAdded($fileAfter, $tableName); $this->getReport()->add($this->context, $operation); } } diff --git a/src/Analyzer/DBSchema/DbSchemaUniqueKeyAnalyzer.php b/src/Analyzer/DBSchema/DbSchemaUniqueKeyAnalyzer.php index f8fa1812..dc7c88b4 100644 --- a/src/Analyzer/DBSchema/DbSchemaUniqueKeyAnalyzer.php +++ b/src/Analyzer/DBSchema/DbSchemaUniqueKeyAnalyzer.php @@ -56,6 +56,7 @@ public function analyze($registryBefore, $registryAfter) $registryTablesAfter = $registryAfter->data['table'] ?? []; foreach ($registryTablesBefore as $moduleName => $moduleTables) { + $fileBefore = $registryBefore->mapping['table'][$moduleName]; foreach ($moduleTables as $tableName => $tableData) { $keys = $tableData['unique'] ?? []; foreach ($keys as $name => $key) { @@ -63,7 +64,7 @@ public function analyze($registryBefore, $registryAfter) continue; } if ($key !== null && !isset($registryTablesAfter[$moduleName][$tableName]['unique'][$name])) { - $operation = new UniqueKeyDrop($moduleName, $tableName . '/' . $name); + $operation = new UniqueKeyDrop($fileBefore, $tableName . '/' . $name); $this->getReport()->add($this->context, $operation); continue; } @@ -77,7 +78,7 @@ public function analyze($registryBefore, $registryAfter) } } if (!$matchedColumnFlag) { - $operation = new UniqueKeyChange($moduleName, $tableName . '/' . $name); + $operation = new UniqueKeyChange($fileBefore, $tableName . '/' . $name); $this->getReport()->add($this->context, $operation); break; } @@ -87,6 +88,7 @@ public function analyze($registryBefore, $registryAfter) } foreach ($registryTablesAfter as $moduleName => $moduleTables) { + $fileAfter = $registryAfter->mapping['table'][$moduleName]; foreach ($moduleTables as $tableName => $tableData) { $keys = $tableData['unique'] ?? []; foreach ($keys as $name => $key) { @@ -94,7 +96,7 @@ public function analyze($registryBefore, $registryAfter) continue; } if ($key !== null && !isset($registryTablesBefore[$moduleName][$tableName]['unique'][$name])) { - $operation = new UniqueKeyAdd($moduleName, $tableName . '/' . $name); + $operation = new UniqueKeyAdd($fileAfter, $tableName . '/' . $name); $this->getReport()->add($this->context, $operation); continue; } @@ -109,7 +111,7 @@ public function analyze($registryBefore, $registryAfter) } } if (!$matchedColumnFlag) { - $operation = new UniqueKeyChange($moduleName, $tableName . '/' . $name); + $operation = new UniqueKeyChange($fileAfter, $tableName . '/' . $name); $this->getReport()->add($this->context, $operation); break; } diff --git a/src/Analyzer/DBSchema/DbSchemaWhitelistAnalyzer.php b/src/Analyzer/DBSchema/DbSchemaWhitelistAnalyzer.php index 0b10c288..1b1fa623 100644 --- a/src/Analyzer/DBSchema/DbSchemaWhitelistAnalyzer.php +++ b/src/Analyzer/DBSchema/DbSchemaWhitelistAnalyzer.php @@ -11,11 +11,12 @@ use Magento\SemanticVersionChecker\Analyzer\AnalyzerInterface; use Magento\SemanticVersionChecker\Operation\InvalidWhitelist; +use Magento\SemanticVersionChecker\Operation\WhiteListWasRemoved; use PHPSemVerChecker\Registry\Registry; use PHPSemVerChecker\Report\Report; /** - * Implements an analyzer fdr the database schema whitelist files. + * Implements an analyzer for the database schema whitelist files. * @noinspection PhpUnused */ class DbSchemaWhitelistAnalyzer implements AnalyzerInterface @@ -54,17 +55,23 @@ public function analyze($registryBefore, $registryAfter) $dbWhiteListContent = $registryAfter->data['whitelist_json'] ?? []; foreach ($registryTablesAfter as $moduleName => $tablesData) { + $whiteListFileAfter = $registryAfter->mapping['whitelist_json'][$moduleName] ?? ''; + if (!file_exists($whiteListFileAfter)) { + $tableFileAfter = $registryAfter->mapping['table'][$moduleName]; + $whiteListFileAfter = dirname($tableFileAfter) . '/db_schema_whitelist.json'; + $operation = new WhiteListWasRemoved($whiteListFileAfter, $moduleName); + $this->report->add('database', $operation); + continue; + } if (count($tablesData)) { foreach (array_keys($tablesData) as $table) { if (!isset($dbWhiteListContent[$moduleName][$table])) { - $operation = new InvalidWhitelist($moduleName, $table); + $operation = new InvalidWhitelist($whiteListFileAfter, $table); $this->report->add('database', $operation); } } } } - - return $this->report; } } diff --git a/src/Analyzer/DBSchema/DbSchemaWhitelistReductionOrRemovalAnalyzer.php b/src/Analyzer/DBSchema/DbSchemaWhitelistReductionOrRemovalAnalyzer.php index 3dcdd78b..97a5e596 100644 --- a/src/Analyzer/DBSchema/DbSchemaWhitelistReductionOrRemovalAnalyzer.php +++ b/src/Analyzer/DBSchema/DbSchemaWhitelistReductionOrRemovalAnalyzer.php @@ -49,8 +49,9 @@ public function analyze($registryBefore, $registryAfter) /** @var array $tablesData */ foreach ($whiteListBefore as $moduleName => $beforeModuleTablesData) { + $fileBefore = $registryBefore->mapping['whitelist_json'][$moduleName]; if (!isset($whiteListAfter[$moduleName])) { - $operation = new WhiteListWasRemoved($moduleName); + $operation = new WhiteListWasRemoved($fileBefore, $moduleName); $this->report->add('database', $operation); continue; } @@ -58,14 +59,14 @@ public function analyze($registryBefore, $registryAfter) /** @var array $beforeTableData */ foreach ($beforeModuleTablesData as $tableName => $beforeTableData) { if (!$this->isArrayExistsAndHasSameSize($afterModuleTablesData, $beforeTableData, $tableName)) { - $this->addReport($moduleName, $tableName); + $this->addReport($fileBefore, $tableName); continue; } $afterTableData = $afterModuleTablesData[$tableName]; /** @var array $beforeTablePartData */ foreach ($beforeTableData as $tablePartName => $beforeTablePartData) { if (!$this->isArrayExistsAndHasSameSize($afterTableData, $beforeTablePartData, $tablePartName)) { - $this->addReport($moduleName, $tableName . '/' . $tablePartName); + $this->addReport($fileBefore, $tableName . '/' . $tablePartName); continue; } $afterTablePartData = $afterTableData[$tablePartName]; @@ -73,7 +74,7 @@ public function analyze($registryBefore, $registryAfter) foreach ($beforeTablePartData as $name => $beforeStatus) { //checks if array exists in new whitelist.json and if it has different amount of items inside if (!isset($afterTablePartData[$name])) { - $this->addReport($moduleName, $tableName . '/' . $tablePartName . '/' . $name); + $this->addReport($fileBefore, $tableName . '/' . $tablePartName . '/' . $name); } } } @@ -102,14 +103,14 @@ public function isArrayExistsAndHasSameSize(array $after, array $beforeArray, st } /** - * @param string $moduleName + * @param string $location * @param string $target * * @return void */ - public function addReport(string $moduleName, string $target): void + public function addReport(string $location, string $target): void { - $operation = new WhiteListReduced($moduleName, $target); + $operation = new WhiteListReduced($location, $target); $this->report->add('database', $operation); } } diff --git a/src/Analyzer/DbSchemaWhitelistAnalyzer.php b/src/Analyzer/DbSchemaWhitelistAnalyzer.php deleted file mode 100644 index 6017f5a4..00000000 --- a/src/Analyzer/DbSchemaWhitelistAnalyzer.php +++ /dev/null @@ -1,81 +0,0 @@ -data['table'] ?? []; - $registryTablesBefore = $registryBefore->data['table'] ?? []; - - foreach ($registryTablesAfter as $moduleName => $tablesData) { - if (count($tablesData)) { - //Take file like an example - //We will replace module_name in file_path in order to get - //correct module - $dbFile = $registryAfter->getCurrentFile(); - $dbWhiteListFile = preg_replace( - '/(.*Magento\/)\w+(\/.*)/', - '$1' . explode("_", $moduleName)[1] . '$2', - $dbFile - ); - $dbWhiteListFile = str_replace( - 'db_schema.xml', - 'db_schema_whitelist.json', - $dbWhiteListFile - ); - if (!file_exists($dbWhiteListFile)) { - $operation = new WhiteListWasRemoved($moduleName); - $report->add('database', $operation); - continue; - } else { - $dbWhiteListContent = json_decode( - file_get_contents($dbWhiteListFile), - true - ); - } - - $tables = array_replace($tablesData, $registryTablesBefore[$moduleName] ?? []); - foreach (array_keys($tables) as $table) { - if (!isset($dbWhiteListContent[$table])) { - $operation = new InvalidWhitelist($dbWhiteListFile, $table); - $report->add('database', $operation); - } - } - } - } - - - return $report; - } -} diff --git a/src/Analyzer/DiXml/VirtualTypeAnalyzer.php b/src/Analyzer/DiXml/VirtualTypeAnalyzer.php index 1db35f2f..5dd021c4 100644 --- a/src/Analyzer/DiXml/VirtualTypeAnalyzer.php +++ b/src/Analyzer/DiXml/VirtualTypeAnalyzer.php @@ -56,17 +56,18 @@ public function analyze($registryBefore, $registryAfter) foreach ($nodesBefore as $moduleName => $moduleNodes) { /* @var VirtualType $nodeBefore */ + $fileBefore = $registryBefore->mapping[XmlRegistry::NODES_KEY][$moduleName]; foreach ($moduleNodes as $name => $nodeBefore) { // search nodesAfter the by name $nodeAfter = $nodesAfter[$moduleName][$name] ?? false; if ($nodeAfter !== false && $nodeBefore !== $nodeAfter) { /* @var VirtualType $nodeAfter */ - $this->triggerNodeChange($nodeBefore, $nodeAfter); + $this->triggerNodeChange($nodeBefore, $nodeAfter, $fileBefore); continue; } - $operation = new VirtualTypeRemoved($moduleName, $name); + $operation = new VirtualTypeRemoved($fileBefore, $name); $this->report->add('di', $operation); } } @@ -103,8 +104,9 @@ private function getVirtualTypeNode(XmlRegistry $xmlRegistry): array * * @param VirtualType $nodeBefore * @param VirtualType $nodeAfter + * @param string $beforeFilePath */ - private function triggerNodeChange(VirtualType $nodeBefore, VirtualType $nodeAfter): void + private function triggerNodeChange(VirtualType $nodeBefore, VirtualType $nodeAfter, string $beforeFilePath): void { $bcFieldBefore = [ 'type' => $nodeBefore->getType(), @@ -124,7 +126,7 @@ private function triggerNodeChange(VirtualType $nodeBefore, VirtualType $nodeAft foreach ($bcFieldBefore as $fieldName => $valueBefore) { $valueAfter = $bcFieldAfter[$fieldName]; if ($valueBefore !== $valueAfter) { - $operation = new VirtualTypeChanged($nodeBefore->getName(), $fieldName); + $operation = new VirtualTypeChanged($beforeFilePath, $fieldName); $this->report->add('di', $operation); } } diff --git a/src/Analyzer/Layout/Analyzer.php b/src/Analyzer/Layout/Analyzer.php index 7a65a3c1..e5e4c8ef 100644 --- a/src/Analyzer/Layout/Analyzer.php +++ b/src/Analyzer/Layout/Analyzer.php @@ -46,8 +46,8 @@ public function __construct(Report $report) /** * Compared registryBefore and registryAfter find changes for layout block types * - * @param XmlRegistry|Registry $registryBefore - * @param XmlRegistry|Registry $registryAfter + * @param XmlRegistry $registryBefore + * @param XmlRegistry $registryAfter * @return Report */ public function analyze($registryBefore, $registryAfter) @@ -60,23 +60,18 @@ public function analyze($registryBefore, $registryAfter) foreach (array_keys($nodesBefore) as $moduleName) { $moduleNodesBefore = $nodesBefore[$moduleName] ?? []; - $moduleNodesAfter = []; - - /** - * @var LayoutNodeInterface $node - */ - foreach ($nodesAfter[$moduleName] ?? [] as $node) { - $moduleNodesAfter[$moduleName][$node->getUniqueKey()] = $node; - } + $moduleNodesAfter = $nodesAfter[$moduleName] ?? []; /** * @var string $nodeName * @var LayoutNodeInterface $node */ foreach ($moduleNodesBefore as $nodeName => $node) { - $nodeAfter = $moduleNodesAfter[$moduleName][$node->getUniqueKey()] ?? false; + $uniqueKey = $node->getUniqueKey(); + $nodeAfter = $moduleNodesAfter[$uniqueKey] ?? false; if ($nodeAfter === false) { - $this->triggerNodeRemoved($moduleName, $node); + $beforeFilePath = $registryBefore->getLayoutFile($moduleName, $uniqueKey); + $this->triggerNodeRemoved($node, $beforeFilePath); } } } @@ -85,23 +80,23 @@ public function analyze($registryBefore, $registryAfter) } /** - * @param string $moduleName * @param $node + * @param string $beforeFilePath */ - private function triggerNodeRemoved(string $moduleName, $node): void + private function triggerNodeRemoved($node, string $beforeFilePath): void { if ($node instanceof Block) { - $this->report->add('layout', new BlockRemoved($moduleName, $node->getName())); + $this->report->add('layout', new BlockRemoved($beforeFilePath, $node->getName())); return; } if ($node instanceof Container) { - $this->report->add('layout', new ContainerRemoved($moduleName, $node->getName())); + $this->report->add('layout', new ContainerRemoved($beforeFilePath, $node->getName())); return; } if ($node instanceof Update) { - $this->report->add('layout', new UpdateRemoved($moduleName, $node->getHandle())); + $this->report->add('layout', new UpdateRemoved($beforeFilePath, $node->getHandle())); return; } } diff --git a/src/Analyzer/Less/Analyzer.php b/src/Analyzer/Less/Analyzer.php index 8272bde0..1ef3fe02 100644 --- a/src/Analyzer/Less/Analyzer.php +++ b/src/Analyzer/Less/Analyzer.php @@ -15,6 +15,7 @@ use Magento\SemanticVersionChecker\Operation\Less\VariableRemoved; use Magento\SemanticVersionChecker\Operation\Less\MixinRemoved; use Magento\SemanticVersionChecker\Registry\LessRegistry; +use Magento\SemanticVersionChecker\Registry\XmlRegistry; use PHPSemVerChecker\Registry\Registry; use PHPSemVerChecker\Report\Report; use Less_Tree; @@ -74,6 +75,7 @@ public function analyze($registryBefore, $registryAfter) foreach ($commonModules as $moduleName) { $moduleLessFilesBefore = $nodesBefore[$moduleName]; $moduleLessFilesAfter = $nodesAfter[$moduleName]; + $commonLessFiles = array_intersect_key($moduleLessFilesBefore, $moduleLessFilesAfter); foreach (array_keys($commonLessFiles) as $lessFileName) { @@ -86,10 +88,12 @@ public function analyze($registryBefore, $registryAfter) if (count($removedNodeNames)) { //report removals $removedNodes = array_intersect_key($lessNodesBefore, array_flip($removedNodeNames)); - $this->reportRemovedNodes($lessFileName, $removedNodes); + $fileBefore = $registryBefore->mapping[LessRegistry::NODES_KEY][$moduleName][$lessFileName]; + $this->reportRemovedNodes($fileBefore, $removedNodes); } elseif (!count($addedNodeNames) && !count($removedNodeNames)) { //report changes inside nodes - $this->reportUpdatedNodes($lessFileName, $lessNodesBefore, $lessNodesAfter); + $fileAfter = $registryAfter->mapping[LessRegistry::NODES_KEY][$moduleName][$lessFileName]; + $this->reportUpdatedNodes($fileAfter, $lessNodesBefore, $lessNodesAfter); } } } diff --git a/src/Analyzer/SystemXml/Analyzer.php b/src/Analyzer/SystemXml/Analyzer.php index 4841e0bf..5fe050a3 100644 --- a/src/Analyzer/SystemXml/Analyzer.php +++ b/src/Analyzer/SystemXml/Analyzer.php @@ -77,10 +77,10 @@ public function analyze($registryBefore, $registryAfter) $removedModules = array_diff($modulesBefore, $modulesAfter); //process added files - $this->reportAddedFiles($addedModules); + $this->reportAddedFiles($addedModules, $registryAfter); //process removed files - $this->reportRemovedFiles($removedModules); + $this->reportRemovedFiles($removedModules, $registryBefore); //process common files foreach ($commonModules as $moduleName) { @@ -88,11 +88,15 @@ public function analyze($registryBefore, $registryAfter) $moduleNodesAfter = $nodesAfter[$moduleName]; $addedNodes = array_diff_key($moduleNodesAfter, $moduleNodesBefore); $removedNodes = array_diff_key($moduleNodesBefore, $moduleNodesAfter); - - $this->reportAddedNodes($moduleName, $addedNodes); - $this->reportRemovedNodes($moduleName, $removedNodes); + if ($removedNodes) { + $beforeFile = $registryBefore->mapping[XmlRegistry::NODES_KEY][$moduleName]; + $this->reportRemovedNodes($beforeFile, $removedNodes); + } + if ($addedNodes) { + $afterFile = $registryAfter->mapping[XmlRegistry::NODES_KEY][$moduleName]; + $this->reportAddedNodes($afterFile, $addedNodes); + } } - return $this->report; } @@ -125,11 +129,13 @@ private function getNodes(XmlRegistry $registry): array * Creates reports for $modules considering that system.xml has been added to them. * * @param string[] $modules + * @param XmlRegistry $registryAfter */ - private function reportAddedFiles(array $modules) + private function reportAddedFiles(array $modules, XmlRegistry $registryAfter) { foreach ($modules as $module) { - $this->report->add('system', new FileAdded($module, 'system.xml')); + $afterFile = $registryAfter->mapping[XmlRegistry::NODES_KEY][$module]; + $this->report->add('system', new FileAdded($afterFile, 'system.xml')); } } @@ -162,11 +168,13 @@ private function reportAddedNodes(string $file, array $nodes) * Creates reports for $modules considering that system.xml has been removed from them. * * @param array $modules + * @param XmlRegistry $registryBefore */ - private function reportRemovedFiles(array $modules) + private function reportRemovedFiles(array $modules, XmlRegistry $registryBefore) { foreach ($modules as $module) { - $this->report->add('system', new FileRemoved($module, 'system.xml')); + $beforeFile = $registryBefore->mapping[XmlRegistry::NODES_KEY][$module]; + $this->report->add('system', new FileRemoved($beforeFile, 'system.xml')); } } diff --git a/src/Analyzer/Xsd/Analyzer.php b/src/Analyzer/Xsd/Analyzer.php index 5e6530f8..fd63ffe1 100644 --- a/src/Analyzer/Xsd/Analyzer.php +++ b/src/Analyzer/Xsd/Analyzer.php @@ -73,10 +73,10 @@ public function analyze($registryBefore, $registryAfter) $commonModules = array_intersect(array_keys($nodesBefore), array_keys($nodesAfter)); //process added modules - $this->reportAddedModules($addedModules); + $this->reportAddedModules($addedModules, $registryAfter); //process removed modules - $this->reportRemovedModules($removedModules); + $this->reportRemovedModules($removedModules, $registryBefore); //process common modules foreach ($commonModules as $moduleName) { @@ -91,10 +91,10 @@ public function analyze($registryBefore, $registryAfter) $commonFiles = array_intersect($filesBefore, $filesAfter); //process added files - $this->reportAddedSchemaDeclarations($moduleName, $addedFiles); + $this->reportAddedSchemaDeclarations($moduleName, $addedFiles, $registryAfter); //process removed files - $this->reportRemovedSchemaDeclarations($moduleName, $removedFiles); + $this->reportRemovedSchemaDeclarations($moduleName, $removedFiles, $registryBefore); //process common files foreach ($commonFiles as $fileName) { @@ -106,10 +106,16 @@ public function analyze($registryBefore, $registryAfter) $removedNodes = array_diff_key($nodesBefore, $nodesAfter); //process added nodes - $this->reportAddedNodes($moduleName, $addedNodes); + if ($addedNodes) { + $filePath = $registryAfter->mapping[XmlRegistry::NODES_KEY][$moduleName][$fileName]; + $this->reportAddedNodes($filePath, $addedNodes); + } //process removed nodes - $this->reportRemovedNodes($moduleName, $removedNodes); + if($removedNodes) { + $filePath = $registryBefore->mapping[XmlRegistry::NODES_KEY][$moduleName][$fileName]; + $this->reportRemovedNodes($filePath, $removedNodes); + } } } @@ -159,12 +165,13 @@ private function getNodes(XmlRegistry $registry): array * Creates reports for $modules that have been added. * * @param array $modules + * @param Registry $beforeRegistry */ - private function reportAddedModules(array $modules): void + private function reportAddedModules(array $modules, Registry $beforeRegistry): void { foreach ($modules as $moduleName => $files) { - $fileNames = array_keys($files); - $this->reportAddedSchemaDeclarations($moduleName, $fileNames); + $relativeFilePaths = array_keys($files); + $this->reportAddedSchemaDeclarations($moduleName, $relativeFilePaths, $beforeRegistry); } } @@ -202,12 +209,14 @@ private function reportAddedNodes(string $module, array $nodes): void * Creates reports for $files in $module that have been added. * * @param string $module - * @param string[] $files + * @param string[] $relativeFilePaths + * @param Registry $registry */ - private function reportAddedSchemaDeclarations(string $module, array $files): void + private function reportAddedSchemaDeclarations(string $module, array $relativeFilePaths, Registry $registry): void { - foreach ($files as $file) { - $this->report->add(self::CONTEXT, new SchemaDeclarationAdded($module, $file)); + foreach ($relativeFilePaths as $relativeFilePath) { + $fullFilePath = $registry->mapping[XmlRegistry::NODES_KEY][$module][$relativeFilePath]; + $this->report->add(self::CONTEXT, new SchemaDeclarationAdded($fullFilePath, $relativeFilePath)); } } @@ -215,32 +224,33 @@ private function reportAddedSchemaDeclarations(string $module, array $files): vo * Creates reports for $modules that have been removed. * * @param array $modules + * @param Registry $registryBefore */ - private function reportRemovedModules(array $modules): void + private function reportRemovedModules(array $modules, Registry $registryBefore): void { foreach ($modules as $moduleName => $files) { - $fileNames = array_keys($files); - $this->reportRemovedSchemaDeclarations($moduleName, $fileNames); + $relativeFilePaths = array_keys($files); + $this->reportRemovedSchemaDeclarations($moduleName, $relativeFilePaths, $registryBefore); } } /** * Creates reports for $nodes that have been removed from $file in $module. * - * @param string $module + * @param string $filePath * @param NodeInterface[] $nodes */ - private function reportRemovedNodes(string $module, array $nodes): void + private function reportRemovedNodes(string $filePath, array $nodes): void { foreach ($nodes as $node) { switch (true) { case $node instanceof AttributeNode: - $data = new AttributeRemoved($module, $node->getName()); + $data = new AttributeRemoved($filePath, $node->getName()); $this->report->add(self::CONTEXT, $data); break; case $node instanceof ElementNode: - $data = new NodeRemoved($module, $node->getName()); + $data = new NodeRemoved($filePath, $node->getName()); $this->report->add(self::CONTEXT, $data); break; @@ -254,12 +264,14 @@ private function reportRemovedNodes(string $module, array $nodes): void * Creates reports for $files that have been removed in $module * * @param string $module - * @param array $files + * @param array $relativeFilePaths + * @param Registry $registryBefore */ - private function reportRemovedSchemaDeclarations(string $module, array $files): void + private function reportRemovedSchemaDeclarations(string $module, array $relativeFilePaths, Registry $registryBefore): void { - foreach ($files as $file) { - $this->report->add(self::CONTEXT, new SchemaDeclarationRemoved($module, $file)); + foreach ($relativeFilePaths as $relativeFilePath) { + $fullPath = $registryBefore->mapping[XmlRegistry::NODES_KEY][$module][$relativeFilePath]; + $this->report->add(self::CONTEXT, new SchemaDeclarationRemoved($fullPath, $relativeFilePath)); } } } diff --git a/src/Console/Command/CompareSourceCommand.php b/src/Console/Command/CompareSourceCommand.php index 1c373019..04959f1d 100644 --- a/src/Console/Command/CompareSourceCommand.php +++ b/src/Console/Command/CompareSourceCommand.php @@ -13,6 +13,7 @@ use Magento\SemanticVersionChecker\FileChangeDetector; use Magento\SemanticVersionChecker\ReportBuilder; use Magento\SemanticVersionChecker\Reporter\HtmlDbSchemaReporter; +use Magento\SemanticVersionChecker\Reporter\HtmlPackageLevelChangesRenderer; use Magento\SemanticVersionChecker\ReportTypes; use Magento\SemanticVersionChecker\SemanticVersionChecker; use PHPSemVerChecker\SemanticVersioning\Level; @@ -96,7 +97,6 @@ protected function configure() /** * @param InputInterface $input * @param OutputInterface $cliOutput - * @return void */ protected function execute(InputInterface $input, OutputInterface $cliOutput) { @@ -180,6 +180,8 @@ protected function execute(InputInterface $input, OutputInterface $cliOutput) 'Changed filesNo changed files found.' ); } + $pkgLevelChangeRenderer = new HtmlPackageLevelChangesRenderer($versionReport, $input, $logOutputStream); + $pkgLevelChangeRenderer->outputPackageChanges(); $logOutputStream->writeln($this->getHtmlFooter()); } else { @@ -218,8 +220,9 @@ protected function execute(InputInterface $input, OutputInterface $cliOutput) "It exceeds the allowed change level, which is $allowedChangeLevel " . '(' . $versionIncWord . ').' ); - exit(-1); + return -1; } + return 0; } private function validateAllowedLevel($input) @@ -342,6 +345,19 @@ private function getHtmlHeader() th.column30 { width: 30%; } +.btn-tooltip:hover:after { + content: "Click to Copy JSON"; + position: absolute; + background-color: gray; + color: white; +} + .btn-tooltip-copied:hover:after { + content: "Copied!"; + position: absolute; + background-color: gray; + color: white; + } + diff --git a/src/Helper/PackageNameResolver.php b/src/Helper/PackageNameResolver.php new file mode 100644 index 00000000..669fca19 --- /dev/null +++ b/src/Helper/PackageNameResolver.php @@ -0,0 +1,74 @@ +input = $input; + } + + /** + * Gets the matching composer.json given a filepath. Will return null if composer.json is not found + * + * @param string $filepath + * @return string|null + */ + private function getComposerPackageLocation(string $filepath):?string { + $sourceBeforeDir = realpath($this->input->getArgument('source-before')); + $sourceAfterDir = realpath($this->input->getArgument('source-after')); + $level = 1; + $composerDirPath = dirname($filepath, $level); + while ($composerDirPath !== $sourceBeforeDir + && $composerDirPath !== $sourceAfterDir + && $composerDirPath !== '.') { + + $composerPath = $composerDirPath . '/composer.json'; + if (is_file($composerPath)) { + return $composerPath; + } + $composerDirPath = dirname($filepath, ++$level); + } + return null; + } + + /** + * Get the real name of package that contains the input file + * + * @param string $filepath + * @return string|null + */ + public function getPackageName(string $filepath):?string { + $composerFilePath = $this->getComposerPackageLocation($filepath); + if (!$composerFilePath) { + return null; + } + $composerFile = file_get_contents($composerFilePath); + $composerJson = json_decode($composerFile); + return $composerJson->name; + } + +} \ No newline at end of file diff --git a/src/Operation/InvalidWhitelist.php b/src/Operation/InvalidWhitelist.php index b0410d51..d48fcc1b 100644 --- a/src/Operation/InvalidWhitelist.php +++ b/src/Operation/InvalidWhitelist.php @@ -43,15 +43,15 @@ class InvalidWhitelist extends Operation * * @var string */ - protected $fileBefore; + protected $location; /** - * @param string $fileBefore + * @param string $location * @param string $target */ - public function __construct($fileBefore, $target) + public function __construct($location, $target) { - $this->fileBefore = $fileBefore; + $this->location = $location; $this->target = $target; } @@ -62,7 +62,7 @@ public function __construct($fileBefore, $target) */ public function getLocation() { - return $this->fileBefore; + return $this->location; } public function getReason() diff --git a/src/Operation/WhiteListWasRemoved.php b/src/Operation/WhiteListWasRemoved.php index 1670d951..b8635caf 100644 --- a/src/Operation/WhiteListWasRemoved.php +++ b/src/Operation/WhiteListWasRemoved.php @@ -42,12 +42,18 @@ class WhiteListWasRemoved extends Operation * @var string */ protected $target; + /** + * @var string + */ + private $location; /** + * @param string $location * @param string $target */ - public function __construct($target) + public function __construct($location, $target) { + $this->location = $location; $this->target = $target; } @@ -58,7 +64,7 @@ public function __construct($target) */ public function getLocation(): string { - return $this->target; + return $this->location; } /** diff --git a/src/Registry/XmlRegistry.php b/src/Registry/XmlRegistry.php index ef9bb9e3..32ec1b11 100644 --- a/src/Registry/XmlRegistry.php +++ b/src/Registry/XmlRegistry.php @@ -9,6 +9,8 @@ namespace Magento\SemanticVersionChecker\Registry; +use Magento\SemanticVersionChecker\Node\Layout\Container; +use Magento\SemanticVersionChecker\Node\Layout\LayoutNodeInterface; use PHPSemVerChecker\Registry\Registry; class XmlRegistry extends Registry @@ -29,6 +31,28 @@ public function addXmlNode(string $context, $data): void $this->data[self::NODES_KEY][$context][] = $data; } + /** + * Add layout container node to mapping and data + * + * @param LayoutNodeInterface $layoutNode + * @param string $moduleName + */ + public function addLayoutContainerNode(LayoutNodeInterface $layoutNode, string $moduleName) { + $this->data[self::NODES_KEY][$moduleName][$layoutNode->getUniqueKey()] = $layoutNode; + $this->mapping[self::NODES_KEY][$moduleName][$layoutNode->getUniqueKey()] = $this->getCurrentFile(); + } + + /** + * Get the corresponding file given the module name and layoutNode key + * + * @param string $moduleName + * @param string $uniqueKey + * @return mixed + */ + public function getLayoutFile(string $moduleName, string $uniqueKey) { + return $this->mapping[self::NODES_KEY][$moduleName][$uniqueKey]; + } + /** * Return all nodes that were found in the xml. * @return array diff --git a/src/Reporter/HtmlPackageLevelChangesRenderer.php b/src/Reporter/HtmlPackageLevelChangesRenderer.php new file mode 100644 index 00000000..ca9ed4ff --- /dev/null +++ b/src/Reporter/HtmlPackageLevelChangesRenderer.php @@ -0,0 +1,207 @@ +report = $report; + $this->input = $input; + $this->output = $output; + $this->packageNameResolver = new PackageNameResolver($input); + } + + /** + * Output Package Level Changes table. + */ + public function outputPackageChanges() + { + $pkgChangesJson = $this->getPackageChanges(); + $this->output->writeln('Package Level Changes'); + //Skip writing table if no severe changes are detected + if (!$pkgChangesJson) { + $this->output->writeln('No BIC changes found to packages'); + return; + } + $this->output->writeln('
'); + $this->output->writeln( + '' . + '' + ); + + foreach ($pkgChangesJson as $pkg) { + $this->output->writeln( + '' + ); + } + $this->output->writeln('
LevelPackage Name
'. $pkg['level'] . '' . $pkg['name'] . '
'); + $this->printClipboardJS(); + $pkgChangesJsonString = json_encode($pkgChangesJson, JSON_PRETTY_PRINT); + $this->output->writeln('
');
+        $this->output->writeln($pkgChangesJsonString);
+
+        $this->output->writeln('
'); + } + + /** + * Outputs JS to copy JSON to clipboard + */ + private function printClipboardJS() { + $this->output->writeln( << + + +COPY_PKG_JSON_SCRIPT + ); + } + + /** + * Get array of changed packages and their severity + * + * @return array + */ + private function getPackageChanges():array + { + $results = []; + foreach (self::$contexts as $context) { + foreach (Level::asList('desc') as $level) { + $reportForLevel = $this->report[$context][$level] ?? []; + /** @var \PHPSemVerChecker\Operation\Operation $operation */ + foreach ($reportForLevel as $operation) { + $pkgName = $this->packageNameResolver->getPackageName($operation->getLocation()); + if ($pkgName === null) { + $error = "Unable to resolve package name for composer.json for change to file: " + . $operation->getLocation(); + $this->output->writeln('
' . $error  . '
'); + continue; + } + $this->saveLevelOfChange($pkgName, $level, $results); + } + } + } + $results = $this->transformOutputArray($results); + return $results; + } + + /** + * Insert package into results array. Skip inserting if change is less severe than currently stored packageChange + * + * @param string $pkgName + * @param int $level + * @param array $results + */ + private function saveLevelOfChange(string $pkgName, int $level, array &$results) { + if (!isset($results[$pkgName]) || $level > $results[$pkgName]) { + $results[$pkgName] = $level; + } + } + + /** + * Transforms array of pkgChanges into expected output format + * + * @param array $pkgChanges + * @return array + */ + private function transformOutputArray(array $pkgChanges) { + $results = []; + $minimumChangeLevel = $this->input->getArgument('allowed-change-level'); + foreach ($pkgChanges as $pkgName => $level) { + if ($level > $minimumChangeLevel) { + $results[] = [ + 'name' => $pkgName, + 'level' => Level::toString($level) + ]; + } + } + return $results; + } +} \ No newline at end of file diff --git a/src/Scanner/DbSchemaScanner.php b/src/Scanner/DbSchemaScanner.php index 8f40bb72..2cfa00c5 100644 --- a/src/Scanner/DbSchemaScanner.php +++ b/src/Scanner/DbSchemaScanner.php @@ -106,6 +106,7 @@ public function scanJson(string $filePath): void { $tables = json_decode(file_get_contents($filePath), true); $moduleName = $this->getModuleNameByPath->resolveByEtcDirFilePath($this->registry->getCurrentFile()); + $this->getRegistry()->mapping['whitelist_json'][$moduleName] = $filePath; foreach ($tables as $tableName => $tableData) { $this->getRegistry()->data['whitelist_json'][$moduleName][$tableName] = $tableData; } @@ -155,7 +156,9 @@ private function isJson(string $file): bool private function processTable(array $data) { $name = $data['@attributes']['name']; - $moduleName = $this->getModuleNameByPath->resolveByEtcDirFilePath($this->registry->getCurrentFile()); + $file = $this->getRegistry()->getCurrentFile(); + $moduleName = $this->getModuleNameByPath->resolveByEtcDirFilePath($file); + $this->getRegistry()->mapping['table'][$moduleName] = $file; $resource = isset($data['@attributes']['resource']) ? $data['@attributes']['resource'] : 'default'; $this->getRegistry()->data['table'][$moduleName][$name]['resource'] = $resource; diff --git a/src/Scanner/DiConfigScanner.php b/src/Scanner/DiConfigScanner.php index c347e6a1..ed178326 100644 --- a/src/Scanner/DiConfigScanner.php +++ b/src/Scanner/DiConfigScanner.php @@ -55,6 +55,8 @@ public function scan(string $file): void private function registerVirtualTypeNodes(DOMNodeList $virtualTypeNodes, string $fileName): void { $moduleName = $this->getModuleNameByPath->resolveByEtcDirFilePath($fileName); + $this->getRegistry()->mapping[XmlRegistry::NODES_KEY][$moduleName] = $fileName; + $scope = $this->getScopeFromFile($fileName); /** @var DOMNode $node */ foreach ($virtualTypeNodes as $node) { diff --git a/src/Scanner/EtSchemaScanner.php b/src/Scanner/EtSchemaScanner.php index 2dcdaa3c..4ee601ce 100644 --- a/src/Scanner/EtSchemaScanner.php +++ b/src/Scanner/EtSchemaScanner.php @@ -61,6 +61,7 @@ public function scan(string $file): void $moduleName = $this->getModuleNameByPath->resolveByEtcDirFilePath($file); $data = $this->converter->convert($doc); $this->getRegistry()->data[EtSchemaAnalyzer::CONTEXT][$moduleName] = $data; + $this->getRegistry()->mapping[EtSchemaAnalyzer::CONTEXT][$moduleName] = $file; } /** diff --git a/src/Scanner/LayoutConfigScanner.php b/src/Scanner/LayoutConfigScanner.php index a724d247..4798486a 100644 --- a/src/Scanner/LayoutConfigScanner.php +++ b/src/Scanner/LayoutConfigScanner.php @@ -51,9 +51,11 @@ public function __construct(XmlRegistry $registry, ModuleNamespaceResolver $getM */ public function scan(string $file): void { + $this->registry->setCurrentFile($file); $doc = new DOMDocument(); $doc->loadXML(file_get_contents($file)); $moduleName = $this->getModuleNameByPath->resolveByViewDirFilePath($file); + $this->registerContainerNodes($doc->getElementsByTagName('container'), $moduleName); $this->registerBlockNodes($doc->getElementsByTagName('block'), $moduleName); $this->registerUpdateNodes($doc->getElementsByTagName('update'), $moduleName); @@ -77,7 +79,8 @@ private function registerContainerNodes(DOMNodeList $getElementsByTagName, strin foreach ($getElementsByTagName as $node) { $name = $node->getAttribute('name') ?? ''; $label = $node->getAttribute('label') ?? ''; - $this->registry->addXmlNode($moduleName, new Container($name, $label)); + $layoutNode = new Container($name, $label); + $this->registry->addLayoutContainerNode($layoutNode, $moduleName); } } @@ -96,8 +99,8 @@ private function registerBlockNodes(DOMNodeList $getElementsByTagName, string $m if ($node->getAttribute('cacheable') === 'false') { $cacheable = false; } - - $this->registry->addXmlNode($moduleName, new Block($name, $class, $template, $cacheable)); + $layoutNode = new Block($name, $class, $template, $cacheable); + $this->registry->addLayoutContainerNode($layoutNode, $moduleName); } } @@ -110,7 +113,8 @@ private function registerUpdateNodes(DOMNodeList $getElementsByTagName, string $ /** @var DOMNode $node */ foreach ($getElementsByTagName as $node) { $handle = $node->getAttribute('handle') ?? ''; - $this->registry->addXmlNode($moduleName, new Update($handle)); + $layoutNode = new Update($handle); + $this->registry->addLayoutContainerNode($layoutNode, $moduleName); } } } diff --git a/src/Scanner/LessScanner.php b/src/Scanner/LessScanner.php index deaddcd0..2b5e52e6 100644 --- a/src/Scanner/LessScanner.php +++ b/src/Scanner/LessScanner.php @@ -75,6 +75,7 @@ private function registerNode(Less_Tree $node) $relativeFilePath = $this->getRelativePath($file, $moduleName); $this->registry->data[LessRegistry::NODES_KEY][$moduleName][$relativeFilePath][] = $node; + $this->registry->mapping[LessRegistry::NODES_KEY][$moduleName][$relativeFilePath] = $file; } /** diff --git a/src/Scanner/MftfScanner.php b/src/Scanner/MftfScanner.php index 72f11c01..b883eb8b 100644 --- a/src/Scanner/MftfScanner.php +++ b/src/Scanner/MftfScanner.php @@ -87,8 +87,7 @@ private function registerEntityNode(array $entityNode): void $name = $entityNode['attributes']['name']; $file = $this->registry->getCurrentFile(); $moduleName = $this->moduleNamespaceResolver->resolveByTestMftfPath($file); - $relativeFilePath = $this->getRelativePath($file, $moduleName); - $entityNode['filePaths'][] = $relativeFilePath; + $entityNode['filePaths'][] = $file; // trim {}test => test $entityNode['type'] = str_replace(['{', '}'], '', $entityNode['name']); diff --git a/src/Scanner/SystemXmlScanner.php b/src/Scanner/SystemXmlScanner.php index a65aed8c..1685825f 100644 --- a/src/Scanner/SystemXmlScanner.php +++ b/src/Scanner/SystemXmlScanner.php @@ -59,6 +59,7 @@ public function scan(string $file): void { $doc = new DOMDocument(); $moduleName = $this->moduleNameResolver->resolveByEtcDirFilePath($file); + $this->getRegistry()->mapping[XmlRegistry::NODES_KEY][$moduleName] = $file; $doc->load($file); $this->xPath = new DOMXPath($doc); diff --git a/src/Scanner/XsdScanner.php b/src/Scanner/XsdScanner.php index 0a19fcb9..528b44c2 100644 --- a/src/Scanner/XsdScanner.php +++ b/src/Scanner/XsdScanner.php @@ -138,6 +138,7 @@ private function registerNode(NodeInterface $node) $relativeFilePath = $this->getRelativePath($file, $moduleName); $this->registry->data[XmlRegistry::NODES_KEY][$moduleName][$relativeFilePath][] = $node; + $this->registry->mapping[XmlRegistry::NODES_KEY][$moduleName][$relativeFilePath] = $file; } /** @@ -154,4 +155,9 @@ private function getRelativePath(string $file, string $module): string return substr($file, $moduleSubPathPosition + strlen($moduleSubPath)); } + + private function getModulePath(string $file, string $module) { + $relativePath = $this->getRelativePath($file, $module); + return substr($file, 0, strlen($file) - strlen($relativePath)); + } } diff --git a/tests/Unit/Console/Command/CompareSourceCommandDatabaseSchemasTest.php b/tests/Unit/Console/Command/CompareSourceCommandDatabaseSchemasTest.php index 3633a212..8e2dddec 100644 --- a/tests/Unit/Console/Command/CompareSourceCommandDatabaseSchemasTest.php +++ b/tests/Unit/Console/Command/CompareSourceCommandDatabaseSchemasTest.php @@ -64,8 +64,11 @@ public function changesDataProvider() $pathToFixtures . '/drop-foreign-key/source-code-before', $pathToFixtures . '/drop-foreign-key/source-code-after', [ - '/Database \(MAJOR\)/', - '/unit_test_table\/FL_ALLOWED_SEVERITIES\s*\|\s*Foreign key was removed\s*\|\s*M108/' + '#Database \(MAJOR\)#', + '#[\w/]+' . '/drop-foreign-key/source-code-before/Magento/DbSchema/etc/db_schema\.xml:0#', + '#unit_test_table/FL_ALLOWED_SEVERITIES\s*\|\s*Foreign key was removed\s*\|\s*M108#', + '#[\w/]+' . '/drop-foreign-key/source-code-before/Magento/DbSchema/etc/db_schema_whitelist\.json:0 \| unit_test_table/constraint#', + '#unit_test_table/constraint\s*\|\s*Module db schema whitelist reduced \(unit_test_table/constraint\)#' ], 'Major change is detected.' ], @@ -73,8 +76,9 @@ public function changesDataProvider() $pathToFixtures . '/change-foreign-key/source-code-before', $pathToFixtures . '/change-foreign-key/source-code-after', [ - '/Database \(MAJOR\)/', - '/unit_test_table\/FL_ALLOWED_SEVERITIES\/referenceTable\s*\|\s*Foreign key was changed\s*\|\s*M205/' + '#Database \(MAJOR\)#', + '#[\w/]+' . 'change-foreign-key/source-code-before/Magento/DbSchema/etc/db_schema\.xml:0#', + '#unit_test_table/FL_ALLOWED_SEVERITIES/referenceTable\s*\|\s*Foreign key was changed\s*\|\s*M205#' ], 'Major change is detected.' ], @@ -82,8 +86,9 @@ public function changesDataProvider() $pathToFixtures . '/add-foreign-key/source-code-before', $pathToFixtures . '/add-foreign-key/source-code-after', [ - '/Database \(MAJOR\)/', - '/unit_test_table\/FL_ALLOWED_SEVERITIES\s*\|\s*Foreign key was added\s*\|\s*M204/' + '#Database \(MAJOR\)#', + '#[\w/]+' . 'add-foreign-key/source-code-after/Magento/DbSchema/etc/db_schema\.xml:0#', + '#unit_test_table/FL_ALLOWED_SEVERITIES\s*\|\s*Foreign key was added\s*\|\s*M204#' ], 'Major change is detected.' ], @@ -91,8 +96,11 @@ public function changesDataProvider() $pathToFixtures . '/drop-primary-key/source-code-before', $pathToFixtures . '/drop-primary-key/source-code-after', [ - '/Database \(MAJOR\)/', - '/unit_test_table\/PRIMARY\s*\|\s*Primary key was removed\s*\|\s*M207/' + '#Database \(MAJOR\)#', + '#[\w/]+' . 'drop-primary-key/source-code-before/Magento/DbSchema/etc/db_schema\.xml:0#', + '#[\w/]+' . 'drop-primary-key/source-code-before/Magento/DbSchema/etc/db_schema_whitelist.json:0#', + '#unit_test_table\s*\|\s*Module db schema whitelist reduced \(unit_test_table\)\.\s*\|\s*M110#', + '#unit_test_table/PRIMARY\s*\|\s*Primary key was removed\s*\|\s*M207#' ], 'Major change is detected.' ], @@ -101,6 +109,8 @@ public function changesDataProvider() $pathToFixtures . '/change-primary-key/source-code-after', [ '/Database \(MAJOR\)/', + '#[\w/]+' . 'change-primary-key/source-code-after/Magento/DbSchema/etc/db_schema\.xml:0#', + '#[\w/]+' . 'change-primary-key/source-code-before/Magento/DbSchema/etc/db_schema\.xml:0#', '/unit_test_table\/PRIMARY\s*\|\s*Primary key was changed\s*\|\s*M206/' ], 'Major change is detected.' @@ -110,6 +120,7 @@ public function changesDataProvider() $pathToFixtures . '/add-primary-key/source-code-after', [ '/Database \(MAJOR\)/', + '#[\w/]+' . 'add-primary-key/source-code-after/Magento/DbSchema/etc/db_schema\.xml:0#', '/unit_test_table\/PRIMARY\s*\|\s*Primary key was added\s*\|\s*M205/' ], 'Major change is detected.' @@ -119,7 +130,10 @@ public function changesDataProvider() $pathToFixtures . '/drop-unique-key/source-code-after', [ '/Database \(MAJOR\)/', - '/unit_test_table\/UNIQUE_KEY\s*\|\s*Unique key was removed\s*\|\s*M209/' + '/unit_test_table\/UNIQUE_KEY\s*\|\s*Unique key was removed\s*\|\s*M209/', + '#unit_test_table/constraint\s*\|\s*Module db schema whitelist reduced \(unit_test_table/constraint\)\.\s*\|\s*M110#', + '#[\w/]+' . 'drop-unique-key/source-code-before/Magento/DbSchema/etc/db_schema.xml:0#', + '#[\w/]+' . 'drop-unique-key/source-code-before/Magento/DbSchema/etc/db_schema_whitelist.json:0#' ], 'Major change is detected.' ], @@ -128,7 +142,9 @@ public function changesDataProvider() $pathToFixtures . '/change-unique-key/source-code-after', [ '/Database \(MAJOR\)/', - '/unit_test_table\/UNIQUE_KEY\s*\|\s*Unique key was changed\s*\|\s*M210/' + '/unit_test_table\/UNIQUE_KEY\s*\|\s*Unique key was changed\s*\|\s*M210/', + '#[\w/]+' . 'change-unique-key/source-code-before/Magento/DbSchema/etc/db_schema\.xml:0#', + '#[\w/]+' . 'change-unique-key/source-code-after/Magento/DbSchema/etc/db_schema\.xml:0#' ], 'Major change is detected.' ], @@ -137,7 +153,8 @@ public function changesDataProvider() $pathToFixtures . '/add-unique-key/source-code-after', [ '/Database \(MAJOR\)/', - '/unit_test_table\/UNIQUE_KEY\s*\|\s*Unique key was added\s*\|\s*M208/' + '/unit_test_table\/UNIQUE_KEY\s*\|\s*Unique key was added\s*\|\s*M208/', + '#[\w/]+' . 'add-unique-key/source-code-after/Magento/DbSchema/etc/db_schema\.xml:0#' ], 'Major change is detected.' ], @@ -147,7 +164,9 @@ public function changesDataProvider() [ '/Database \(MAJOR\)/', '/unit_test_table\/time_occurred\s*\|\s*Column was removed\s*\|\s*M107/', - '/Module db schema whitelist reduced \(unit\_test\_table\/column\).\s*\|\s*M110/' + '/Module db schema whitelist reduced \(unit\_test\_table\/column\).\s*\|\s*M110/', + '#[\w/]+' . 'column-removed/source-code-before/Magento/DbSchema/etc/db_schema_whitelist\.json:0#', + '#[\w/]+' . 'column-removed/source-code-before/Magento/DbSchema/etc/db_schema\.xml:0#' ], 'Major change is detected.' ], @@ -156,6 +175,7 @@ public function changesDataProvider() $pathToFixtures . '/column-added/source-code-after', [ '/Database \(MINOR\)/', + '#[\w/]+' . 'column-added/source-code-after/Magento/DbSchema/etc/db_schema\.xml:0#', '/unit_test_table\/time_occurred\s*\|\s*Column was added\s*\|\s*M203/' ], 'Minor change is detected.' @@ -166,7 +186,9 @@ public function changesDataProvider() [ '/Database \(MAJOR\)/', '/other_unit_test_table\s*\|\s*Table was dropped\s*\|\s*M104/', - '/Module db schema whitelist reduced \(other\_unit\_test\_table\).\s*\|\s*M110/' + '/Module db schema whitelist reduced \(other\_unit\_test\_table\).\s*\|\s*M110/', + '#[\w/]+' . '/table-dropped/source-code-before/Magento/DbSchema/etc/db_schema\.xml:0#', + '#[\w/]+' . '/table-dropped/source-code-before/Magento/DbSchema/etc/db_schema_whitelist\.json:0#' ], 'Major change is detected.' ], @@ -175,7 +197,12 @@ public function changesDataProvider() $pathToFixtures . '/table-added/source-code-after', [ '/Database \(MINOR\)/', - '/other_unit_test_table\s*\|\s*Table was added\s*\|\s*M202/' + '/other_unit_test_table\s*\|\s*Table was added\s*\|\s*M202/', + '#other_table\s*\|\s*Table was added\s*\|\s*M202#', + '#other_table\s*\|\s*Whitelist do not have table other_table declared in db_schema\.xml\s*\|\s*M109#', + '#[\w/]+' . '/table-added/source-code-after/Magento/DbSchema/etc/db_schema\.xml:0#', + '#[\w/]+' . '/table-added/source-code-after/Magento/DbSchema/etc/db_schema_whitelist\.json:0#', + ], 'Minor change is detected.' ], @@ -185,6 +212,9 @@ public function changesDataProvider() [ '/Database \(MAJOR\)/', '/unit_test_table\s*\|\s*Table was dropped\s*\|\s*M104/', + '#[\w/]+' . 'table-changed/source-code-after/Magento/DbSchema/etc/db_schema\.xml:0#', + '#[\w/]+' . 'table-changed/source-code-before/Magento/DbSchema/etc/db_schema\.xml:0#', + '#[\w/]+' . 'table-changed/source-code-before/Magento/DbSchema/etc/db_schema_whitelist\.json:0#', '/unit_test_table\s*\|\s*Module db schema whitelist reduced \(unit\_test\_table\).\s*\|\s*M110/', '/new_unit_test_table\s*\|\s*Table was added\s*\|\s*M202/' ], @@ -195,6 +225,7 @@ public function changesDataProvider() $pathToFixtures . '/table-resource-changed/source-code-after', [ '/Database \(MAJOR\)/', + '#[\w/]+' . '/table-resource-changed/source-code-before/Magento/DbSchema/etc/db_schema\.xml:0#', '/unit_test_table\s*\|\s*Table chard was changed from default to sales\s*\|\s*M105/' ], 'Major change is detected.' @@ -204,10 +235,12 @@ public function changesDataProvider() $pathToFixtures . '/whitelist-was-reduced/source-code-after', [ '/Database \(MAJOR\)/', - '/Magento_DbSchema:0\s*\|\s*unit_test_table\s*\|\s*Module db schema whitelist reduced \(unit\_test\_table\).\s*\|\s*M110/', - '/Magento_DbSchema:0\s*\|\s*unit_test_table3\s*\|\s*Module db schema whitelist reduced \(unit\_test\_table3\).\s*\|\s*M110/', - '/Magento_DbSchemaSecond:0\s*\|\s*unit_test_table2\s*\|\s*Module db schema whitelist reduced \(unit\_test\_table2\).\s*\|\s*M110/', - '/Magento_DbSchemaSecond:0\s*\|\s*unit_test_table3\s*\|\s*Module db schema whitelist reduced \(unit\_test\_table3\).\s*\|\s*M110/' + '/Magento\/DbSchema\/etc\/db_schema_whitelist.json:0\s*\|\s*unit_test_table\s*\|\s*Module db schema whitelist reduced \(unit\_test\_table\).\s*\|\s*M110/', + '/Magento\/DbSchemaSecond\/etc\/db_schema_whitelist\.json:0\s*\|\s*unit_test_table3\s*\|\s*Module db schema whitelist reduced \(unit\_test\_table3\).\s*\|\s*M110/', + '/Magento\/DbSchemaSecond\/etc\/db_schema_whitelist\.json:0\s*\|\s*unit_test_table2\s*\|\s*Module db schema whitelist reduced \(unit\_test\_table2\).\s*\|\s*M110/', + '/Magento\/DbSchema\/etc\/db_schema_whitelist.json:0\s*\|\s*unit_test_table3\s*\|\s*Module db schema whitelist reduced \(unit\_test\_table3\).\s*\|\s*M110/', + '#[\w/]+' . '/whitelist-was-reduced/source-code-before/Magento/DbSchemaSecond/etc/db_schema\.xml:0#', + '#[\w/]+' . '/whitelist-was-reduced/source-code-before/Magento/DbSchema/etc/db_schema\.xml:0#' ], 'Major change is detected.' ], @@ -216,7 +249,7 @@ public function changesDataProvider() $pathToFixtures . '/whitelist-was-removed/source-code-after', [ '/Database \(MAJOR\)/', - '/Magento_DbSchema\s*\|\s*Db Whitelist from module Magento_DbSchema was removed\s*\|\s*M109/' + '/Magento\/DbSchema\/etc\/db_schema_whitelist\.json:0\s*\|\s*Magento_DbSchema\s*|\s*Db Whitelist from module Magento_DbSchema was removed\s*\|\s*M109/' ], 'Major change is detected.' ] diff --git a/tests/Unit/Console/Command/CompareSourceCommandDiXmlTest.php b/tests/Unit/Console/Command/CompareSourceCommandDiXmlTest.php index 0d7b2cbb..759785d2 100644 --- a/tests/Unit/Console/Command/CompareSourceCommandDiXmlTest.php +++ b/tests/Unit/Console/Command/CompareSourceCommandDiXmlTest.php @@ -7,12 +7,12 @@ namespace Magento\SemanticVersionChecker\Test\Unit\Console\Command; -use Magento\SemanticVersionChecker\Test\Unit\Console\Command\CompareSourceCommandTest\AbstractTestCase; +use Magento\SemanticVersionChecker\Test\Unit\Console\Command\CompareSourceCommandTest\AbstractTestCaseWithRegExp; /** * Test semantic version checker CLI command dealing with di.xml */ -class CompareSourceCommandDiXmlTest extends AbstractTestCase +class CompareSourceCommandDiXmlTest extends AbstractTestCaseWithRegExp { /** * Test semantic version checker CLI command for changes of the database schema. @@ -21,7 +21,7 @@ class CompareSourceCommandDiXmlTest extends AbstractTestCase * @param string $pathToSourceCodeAfter * @param string[] $expectedLogEntries * @param string $expectedOutput - * @param string[] $unexpectedLogEntries + * @param bool $shouldSkipTest * @return void * @throws \Exception * @dataProvider changesDataProvider @@ -31,14 +31,14 @@ public function testExecute( $pathToSourceCodeAfter, $expectedLogEntries, $expectedOutput, - $unexpectedLogEntries = [] + $shouldSkipTest = false ) { $this->doTestExecute( $pathToSourceCodeBefore, $pathToSourceCodeAfter, $expectedLogEntries, $expectedOutput, - $unexpectedLogEntries + $shouldSkipTest ); } @@ -51,7 +51,7 @@ public function changesDataProvider() $pathToFixtures . '/no-change/source-code-before', $pathToFixtures . '/no-change/source-code-after', [ - + '#Suggested semantic versioning change: NONE#', ], '' ], @@ -59,7 +59,7 @@ public function changesDataProvider() $pathToFixtures . '/moved-to-global/source-code-before', $pathToFixtures . '/moved-to-global/source-code-after', [ - 'Suggested semantic versioning change: NONE', + '#Suggested semantic versioning change: NONE#', ], 'Patch change is detected.', ], @@ -67,7 +67,9 @@ public function changesDataProvider() $pathToFixtures . '/moved-to-specific/source-code-before', $pathToFixtures . '/moved-to-specific/source-code-after', [ - 'Suggested semantic versioning change: MAJOR', + '#Suggested semantic versioning change: MAJOR#', + '#MAJOR\s*\|\s' . '[\w/]+' . '/moved-to-specific/source-code-before/Magento/TestModule/etc/di\.xml:0#', + '#scope\s*\|\s*Virtual Type was changed\s*\|\s*M201#' ], 'Major change is detected.', ], @@ -75,7 +77,9 @@ public function changesDataProvider() $pathToFixtures . '/remove-type/source-code-before', $pathToFixtures . '/remove-type/source-code-after', [ - 'Suggested semantic versioning change: MAJOR', + '#Suggested semantic versioning change: MAJOR#', + '#MAJOR\s*\|\s' . '[\w/]+' . 'remove-type/source-code-before/Magento/TestModule/etc/di\.xml:0#', + '#customCacheInstance2\s*\|\s*Virtual Type was removed\s*\|\s*M200\s*#' ], 'Major change is detected.', ], @@ -83,15 +87,19 @@ public function changesDataProvider() $pathToFixtures . '/change-type/source-code-before', $pathToFixtures . '/change-type/source-code-after', [ - 'Suggested semantic versioning change: MAJOR', + '#Suggested semantic versioning change: MAJOR#', + '#MAJOR\s*\|\s' . '[\w/]+' . '/change-type/source-code-before/Magento/TestModule/etc/di\.xml:0#', + '#type\s*\|\s*Virtual Type was changed\s*\|\s*M201#' ], 'Major change is detected.', ], 'change-name' => [ - $pathToFixtures . '/change-type/source-code-before', - $pathToFixtures . '/change-type/source-code-after', + $pathToFixtures . '/change-name/source-code-before', + $pathToFixtures . '/change-name/source-code-after', [ - 'Suggested semantic versioning change: MAJOR', + '#Suggested semantic versioning change: MAJOR#', + '#MAJOR\s*\|\s*' . '[\w/]+' . '/change-name/source-code-before/Magento/TestModule/etc/di\.xml:0#', + '#cacheInstance\s*\|\s*Virtual Type was removed\s*\|\s*M200#' ], 'Major change is detected.', ], diff --git a/tests/Unit/Console/Command/CompareSourceCommandLayoutTest.php b/tests/Unit/Console/Command/CompareSourceCommandLayoutTest.php index 6bb0b966..814b4a51 100644 --- a/tests/Unit/Console/Command/CompareSourceCommandLayoutTest.php +++ b/tests/Unit/Console/Command/CompareSourceCommandLayoutTest.php @@ -7,12 +7,12 @@ namespace Magento\SemanticVersionChecker\Test\Unit\Console\Command; -use Magento\SemanticVersionChecker\Test\Unit\Console\Command\CompareSourceCommandTest\AbstractTestCase; +use Magento\SemanticVersionChecker\Test\Unit\Console\Command\CompareSourceCommandTest\AbstractTestCaseWithRegExp; /** * Test semantic version checker CLI command dealing with layout xml. */ -class CompareSourceCommandLayoutTest extends AbstractTestCase +class CompareSourceCommandLayoutTest extends AbstractTestCaseWithRegExp { /** * Test semantic version checker CLI command for changes of the database schema. @@ -21,7 +21,7 @@ class CompareSourceCommandLayoutTest extends AbstractTestCase * @param string $pathToSourceCodeAfter * @param string[] $expectedLogEntries * @param string $expectedOutput - * @param string[] $unexpectedLogEntries + * @param bool $shouldSkipTest * @return void * @throws \Exception * @dataProvider changesDataProvider @@ -31,27 +31,30 @@ public function testExecute( $pathToSourceCodeAfter, $expectedLogEntries, $expectedOutput, - $unexpectedLogEntries = [] + $shouldSkipTest = false ) { $this->doTestExecute( $pathToSourceCodeBefore, $pathToSourceCodeAfter, $expectedLogEntries, $expectedOutput, - $unexpectedLogEntries + $shouldSkipTest ); } public function changesDataProvider() { $pathToFixtures = __DIR__ . '/CompareSourceCommandTest/_files/layout_xml'; + getcwd(); return [ 'block_remove' => [ $pathToFixtures . '/block_remove/source-code-before', $pathToFixtures . '/block_remove/source-code-after', [ - 'Suggested semantic versioning change: MAJOR', + '#Suggested semantic versioning change: MAJOR#', + '#MAJOR\s*\|\s' . '[\w/]+' . '/block_remove/source-code-before/Magento/Customer/view/adminhtml/layout/customer_index_viewwishlist\.xml:0#', + '#admin\.customer\.view\.wishlist\s*\|\s*Block was removed\s*\|\s*M220#' ], 'Major change is detected.', ], @@ -59,7 +62,9 @@ public function changesDataProvider() $pathToFixtures . '/container_remove/source-code-before', $pathToFixtures . '/container_remove/source-code-after', [ - 'Suggested semantic versioning change: MAJOR', + '#Suggested semantic versioning change: MAJOR#', + '#MAJOR\s*\|\s*' . '[\w/]+' . '/container_remove/source-code-before/Magento/Customer/view/adminhtml/layout/customer_index_viewwishlist\.xml:0#', + '#root\s*\|\s*Container was removed\s*\|\s*M221#' ], 'Major change is detected.', ], @@ -67,7 +72,9 @@ public function changesDataProvider() $pathToFixtures . '/update_remove/source-code-before', $pathToFixtures . '/update_remove/source-code-after', [ - 'Suggested semantic versioning change: MAJOR', + '#Suggested semantic versioning change: MAJOR#', + '#MAJOR\s*\|\s*' . '[\w/]+' . '/update_remove/source-code-before/Magento/ConfigurableProduct/view/adminhtml/layout/catalog_product_configurable\.xml:0#', + '#catalog_product_superconfig_config\s*\|\s*An Update was removed\s*\|\s*M222#' ], 'Major change is detected.', ], diff --git a/tests/Unit/Console/Command/CompareSourceCommandMftfTest.php b/tests/Unit/Console/Command/CompareSourceCommandMftfTest.php index ebb1b3c4..5728d283 100644 --- a/tests/Unit/Console/Command/CompareSourceCommandMftfTest.php +++ b/tests/Unit/Console/Command/CompareSourceCommandMftfTest.php @@ -89,6 +89,7 @@ public function changesDataProvider() $pathToFixtures . '/actionGroup-removed/source-code-after', [ 'Mftf (MAJOR)', + 'actionGroup-removed/source-code-before/Magento/TestModule/Test/Mftf/ActionGroup/actionGroup.xml:0', 'ActionGroup/ActionGroup1 | was removed | M200' ], 'Major change is detected.' @@ -98,6 +99,7 @@ public function changesDataProvider() $pathToFixtures . '/actionGroup-added/source-code-after', [ 'Mftf (MINOR)', + 'actionGroup-added/source-code-after/Magento/TestModule/Test/Mftf/ActionGroup/actionGroup.xml:0', 'ActionGroup/ActionGroup2 | was added | M225' ], 'Minor change is detected.' @@ -107,6 +109,7 @@ public function changesDataProvider() $pathToFixtures . '/new-module-actionGroup-added/source-code-after', [ 'Mftf (MINOR)', + 'new-module-actionGroup-added/source-code-after/Magento/TestModuleTwo/Test/Mftf/ActionGroup/actionGroup.xml:0', 'ActionGroup/ActionGroup2 | was added | M225' ], 'Minor change is detected.' @@ -116,6 +119,7 @@ public function changesDataProvider() $pathToFixtures . '/actionGroup-argument-changed/source-code-after', [ 'Mftf (MAJOR)', + 'actionGroup-argument-changed/source-code-before/Magento/TestModule/Test/Mftf/ActionGroup/actionGroup.xml:0', 'ActionGroup/ActionGroup1/arg1/type | was changed | M203' ], 'Major change is detected.' @@ -125,6 +129,7 @@ public function changesDataProvider() $pathToFixtures . '/actionGroup-argument-removed/source-code-after', [ 'Mftf (MAJOR)', + 'actionGroup-argument-removed/source-code-before/Magento/TestModule/Test/Mftf/ActionGroup/actionGroup.xml:0', 'ActionGroup/ActionGroup1/Arguments/arg1 | was removed | M201' ], 'Major change is detected.' @@ -134,6 +139,7 @@ public function changesDataProvider() $pathToFixtures . '/actionGroup-argument-added/source-code-after', [ 'Mftf (MAJOR)', + 'actionGroup-argument-added/source-code-before/Magento/TestModule/Test/Mftf/ActionGroup/actionGroup.xml:0', 'ActionGroup/ActionGroup1/arg2 | was added | M227' ], 'Major change is detected.' @@ -143,6 +149,7 @@ public function changesDataProvider() $pathToFixtures . '/actionGroup-action-changed/source-code-after', [ 'Mftf (PATCH)', + 'actionGroup-action-changed/source-code-before/Magento/TestModule/Test/Mftf/ActionGroup/actionGroup.xml:0', 'ActionGroup/ActionGroup1/action1/userInput | was changed | M204' ], 'Patch change is detected.' @@ -152,6 +159,7 @@ public function changesDataProvider() $pathToFixtures . '/actionGroup-action-type-changed/source-code-after', [ 'Mftf (PATCH)', + 'actionGroup-action-type-changed/source-code-before/Magento/TestModule/Test/Mftf/ActionGroup/actionGroup.xml:0', 'ActionGroup/ActionGroup1/action1 | type was changed | M223' ], 'Patch change is detected.' @@ -161,6 +169,7 @@ public function changesDataProvider() $pathToFixtures . '/actionGroup-action-removed/source-code-after', [ 'Mftf (MAJOR)', + 'actionGroup-action-removed/source-code-before/Magento/TestModule/Test/Mftf/ActionGroup/actionGroup.xml:0', 'ActionGroup/ActionGroup1/action2 | was removed | M202' ], 'Major change is detected.' @@ -170,6 +179,7 @@ public function changesDataProvider() $pathToFixtures . '/actionGroup-action-added/source-code-after', [ 'Mftf (MINOR)', + 'actionGroup-action-added/source-code-before/Magento/TestModule/Test/Mftf/ActionGroup/actionGroup.xml:0', 'ActionGroup/ActionGroup1/action3 | was added | M226' ], 'Minor change is detected.' @@ -179,6 +189,7 @@ public function changesDataProvider() $pathToFixtures . '/data-removed/source-code-after', [ 'Mftf (MAJOR)', + 'data-removed/source-code-before/Magento/TestModule/Test/Mftf/Data/data.xml:0', 'Data/DataEntity1 | Entity was removed | M205' ], 'Major change is detected.' @@ -188,6 +199,7 @@ public function changesDataProvider() $pathToFixtures . '/data-added/source-code-after', [ 'Mftf (MINOR)', + 'data-added/source-code-after/Magento/TestModule/Test/Mftf/Data/data.xml:0', 'Data/DataEntity2 | was added | M228' ], 'Minor change is detected.' @@ -197,6 +209,7 @@ public function changesDataProvider() $pathToFixtures . '/new-module-data-added/source-code-after', [ 'Mftf (MINOR)', + 'new-module-data-added/source-code-after/Magento/TestModuleTwo/Test/Mftf/Data/data.xml:0', 'Data/DataEntity2 | was added | M228' ], 'Minor change is detected.' @@ -206,6 +219,7 @@ public function changesDataProvider() $pathToFixtures . '/data-array-removed/source-code-after', [ 'Mftf (MAJOR)', + 'data-array-removed/source-code-before/Magento/TestModule/Test/Mftf/Data/data.xml:0', 'Data/DataEntity1/arraykey | Entity element was removed | M206' ], 'Major change is detected.' @@ -215,6 +229,7 @@ public function changesDataProvider() $pathToFixtures . '/data-array-added/source-code-after', [ 'Mftf (MINOR)', + 'data-array-added/source-code-before/Magento/TestModule/Test/Mftf/Data/data.xml:0', 'Data/DataEntity1/arraykeynew | was added | M229' ], 'Minor change is detected.' @@ -224,6 +239,7 @@ public function changesDataProvider() $pathToFixtures . '/data-array-item-removed/source-code-after', [ 'Mftf (MINOR)', + 'data-array-item-removed/source-code-before/Magento/TestModule/Test/Mftf/Data/data.xml:0', 'Data/DataEntity1/arraykey/(tre) | Entity element was removed | M207' ], 'Minor change is detected.' @@ -233,6 +249,7 @@ public function changesDataProvider() $pathToFixtures . '/data-field-removed/source-code-after', [ 'Mftf (MAJOR)', + 'data-field-removed/source-code-before/Magento/TestModule/Test/Mftf/Data/data.xml:0', 'Data/DataEntity1/datakey | Entity element was removed | M208' ], 'Major change is detected.' @@ -242,6 +259,7 @@ public function changesDataProvider() $pathToFixtures . '/data-field-added/source-code-after', [ 'Mftf (MINOR)', + 'data-field-added/source-code-before/Magento/TestModule/Test/Mftf/Data/data.xml:0', 'Data/DataEntity1/datakeynew | Entity element was added | M230' ], 'Minor change is detected.' @@ -251,6 +269,7 @@ public function changesDataProvider() $pathToFixtures . '/data-reqentity-removed/source-code-after', [ 'Mftf (MAJOR)', + 'data-reqentity-removed/source-code-before/Magento/TestModule/Test/Mftf/Data/data.xml:0', 'Data/DataEntity1/reqentity | Entity element was removed | M209' ], 'Major change is detected.' @@ -259,6 +278,7 @@ public function changesDataProvider() $pathToFixtures . '/data-reqentity-added/source-code-before', $pathToFixtures . '/data-reqentity-added/source-code-after', [ + 'data-reqentity-added/source-code-before/Magento/TestModule/Test/Mftf/Data/data.xml:0', 'Mftf (PATCH)', 'Data/DataEntity1/reqnew | element was added | M231' ], @@ -268,6 +288,7 @@ public function changesDataProvider() $pathToFixtures . '/data-var-removed/source-code-before', $pathToFixtures . '/data-var-removed/source-code-after', [ + 'data-var-removed/source-code-before/Magento/TestModule/Test/Mftf/Data/data.xml:0', 'Mftf (MAJOR)', 'Data/DataEntity1/var1 | Entity element was removed | M210' ], @@ -278,6 +299,7 @@ public function changesDataProvider() $pathToFixtures . '/data-var-added/source-code-after', [ 'Mftf (MINOR)', + 'data-var-added/source-code-before/Magento/TestModule/Test/Mftf/Data/data.xml:0', 'Data/DataEntity1/var2 | element was added | M232' ], 'Minor change is detected.' @@ -286,6 +308,7 @@ public function changesDataProvider() $pathToFixtures . '/metadata-removed/source-code-before', $pathToFixtures . '/metadata-removed/source-code-after', [ + 'metadata-removed/source-code-before/Magento/TestModule/Test/Mftf/Metadata/meta.xml:0', 'Mftf (MAJOR)', 'Metadata/createEntity | was removed | M211' ], @@ -296,6 +319,7 @@ public function changesDataProvider() $pathToFixtures . '/metadata-added/source-code-after', [ 'Mftf (MINOR)', + 'metadata-added/source-code-after/Magento/TestModule/Test/Mftf/Metadata/meta.xml:0', 'Metadata/createEntity2 | was added | M240' ], 'Minor change is detected.' @@ -305,6 +329,7 @@ public function changesDataProvider() $pathToFixtures . '/new-module-metadata-added/source-code-after', [ 'Mftf (MINOR)', + 'new-module-metadata-added/source-code-after/Magento/TestModuleTwo/Test/Mftf/Metadata/meta.xml:0', 'Metadata/createEntity2 | was added | M240' ], 'Minor change is detected.' @@ -314,6 +339,7 @@ public function changesDataProvider() $pathToFixtures . '/metadata-datatype-changed/source-code-after', [ 'Mftf (MINOR)', + 'metadata-datatype-changed/source-code-before/Magento/TestModule/Test/Mftf/Metadata/meta.xml:0', 'Metadata/createEntity/dataType | was changed | M241' ], 'Minor change is detected.' @@ -322,6 +348,7 @@ public function changesDataProvider() $pathToFixtures . '/metadata-type-changed/source-code-before', $pathToFixtures . '/metadata-type-changed/source-code-after', [ + 'metadata-type-changed/source-code-before/Magento/TestModule/Test/Mftf/Metadata/meta.xml:0', 'Mftf (MINOR)', 'Metadata/createEntity/type | was changed | M241' ], @@ -331,6 +358,7 @@ public function changesDataProvider() $pathToFixtures . '/metadata-auth-changed/source-code-before', $pathToFixtures . '/metadata-auth-changed/source-code-after', [ + 'metadata-auth-changed/source-code-before/Magento/TestModule/Test/Mftf/Metadata/meta.xml:0', 'Mftf (MINOR)', 'Metadata/createEntity/auth | was changed | M241' ], @@ -340,6 +368,7 @@ public function changesDataProvider() $pathToFixtures . '/metadata-url-changed/source-code-before', $pathToFixtures . '/metadata-url-changed/source-code-after', [ + 'metadata-url-changed/source-code-before/Magento/TestModule/Test/Mftf/Metadata/meta.xml:0', 'Mftf (MINOR)', 'Metadata/createEntity/url | was changed | M241' ], @@ -350,6 +379,7 @@ public function changesDataProvider() $pathToFixtures . '/metadata-method-changed/source-code-after', [ 'Mftf (MINOR)', + 'metadata-method-changed/source-code-before/Magento/TestModule/Test/Mftf/Metadata/meta.xml:0', 'Metadata/createEntity/method | was changed | M241' ], 'Minor change is detected.' @@ -358,6 +388,7 @@ public function changesDataProvider() $pathToFixtures . '/metadata-top-level-child-removed/source-code-before', $pathToFixtures . '/metadata-top-level-child-removed/source-code-after', [ + 'metadata-top-level-child-removed/source-code-before/Magento/TestModule/Test/Mftf/Metadata/meta.xml:0', 'Mftf (MAJOR)', 'Metadata/createEntity/toplevelField | child element was removed | M212' ], @@ -368,6 +399,7 @@ public function changesDataProvider() $pathToFixtures . '/metadata-top-level-child-added/source-code-after', [ 'Mftf (MINOR)', + 'metadata-top-level-child-added/source-code-before/Magento/TestModule/Test/Mftf/Metadata/meta.xml:0', 'Metadata/createEntity/toplevelField | child element was added | M242' ], 'Minor change is detected.' @@ -377,6 +409,7 @@ public function changesDataProvider() $pathToFixtures . '/metadata-bottom-level-child-removed/source-code-after', [ 'Mftf (MAJOR)', + 'metadata-bottom-level-child-removed/source-code-before/Magento/TestModule/Test/Mftf/Metadata/meta.xml:0', 'Metadata/createEntity/toplevelObj/childField | child element was removed | M212' ], 'Major change is detected.' @@ -386,6 +419,7 @@ public function changesDataProvider() $pathToFixtures . '/metadata-bottom-level-child-added/source-code-after', [ 'Mftf (MINOR)', + 'metadata-bottom-level-child-added/source-code-before/Magento/TestModule/Test/Mftf/Metadata/meta.xml:0', 'Metadata/createEntity/toplevelObj/childField | child element was added | M242' ], 'Minor change is detected.' @@ -395,6 +429,7 @@ public function changesDataProvider() $pathToFixtures . '/page-removed/source-code-after', [ 'Mftf (MAJOR)', + 'page-removed/source-code-before/Magento/TestModule/Test/Mftf/Page/page.xml:0', 'Page/SamplePage | was removed | M213' ], 'Major change is detected.' @@ -403,6 +438,7 @@ public function changesDataProvider() $pathToFixtures . '/page-added/source-code-before', $pathToFixtures . '/page-added/source-code-after', [ + 'page-added/source-code-after/Magento/TestModule/Test/Mftf/Page/page.xml:0', 'Mftf (MINOR)', 'Page/SamplePageNew | was added | M233' ], @@ -412,6 +448,7 @@ public function changesDataProvider() $pathToFixtures . '/new-module-page-added/source-code-before', $pathToFixtures . '/new-module-page-added/source-code-after', [ + 'new-module-page-added/source-code-after/Magento/TestModuleTwo/Test/Mftf/Page/page.xml:0', 'Mftf (MINOR)', 'Page/SamplePageNew | was added | M233' ], @@ -422,6 +459,7 @@ public function changesDataProvider() $pathToFixtures . '/page-section-removed/source-code-after', [ 'Mftf (MAJOR)', + 'page-section-removed/source-code-before/Magento/TestModule/Test/Mftf/Page/page.xml:0', 'Page/SamplePage/Section2 |
was removed | M214' ], 'Major change is detected.' @@ -431,6 +469,7 @@ public function changesDataProvider() $pathToFixtures . '/page-section-added/source-code-after', [ 'Mftf (MINOR)', + 'page-section-added/source-code-before/Magento/TestModule/Test/Mftf/Page/page.xml:0', 'Page/SamplePage/SectionNew |
was added | M234' ], 'Minor change is detected.' @@ -439,6 +478,7 @@ public function changesDataProvider() $pathToFixtures . '/section-removed/source-code-before', $pathToFixtures . '/section-removed/source-code-after', [ + 'section-removed/source-code-before/Magento/TestModule/Test/Mftf/Section/section.xml:0', 'Mftf (MAJOR)', 'Section/SampleSection |
was removed | M215' ], @@ -449,6 +489,7 @@ public function changesDataProvider() $pathToFixtures . '/section-added/source-code-after', [ 'Mftf (MINOR)', + 'section-added/source-code-after/Magento/TestModule/Test/Mftf/Section/section.xml:0', 'Section/NewSection |
was added | M235' ], 'Minor change is detected.' @@ -458,6 +499,7 @@ public function changesDataProvider() $pathToFixtures . '/new-module-section-added/source-code-after', [ 'Mftf (MINOR)', + 'new-module-section-added/source-code-after/Magento/TestModuleTwo/Test/Mftf/Section/section.xml:0', 'Section/NewSection |
was added | M235' ], 'Minor change is detected.' @@ -467,6 +509,7 @@ public function changesDataProvider() $pathToFixtures . '/section-element-removed/source-code-after', [ 'Mftf (MAJOR)', + 'section-element-removed/source-code-before/Magento/TestModule/Test/Mftf/Section/section.xml:0', 'Section/SampleSection/element2 |
was removed | M216' ], 'Major change is detected.' @@ -476,6 +519,7 @@ public function changesDataProvider() $pathToFixtures . '/section-element-selector-changed/source-code-after', [ 'Mftf (PATCH)', + 'section-element-selector-changed/source-code-before/Magento/TestModule/Test/Mftf/Section/section.xml:0', 'Section/SampleSection/element1/selector |
selector was changed | M219' ], 'Patch change is detected.' @@ -485,6 +529,7 @@ public function changesDataProvider() $pathToFixtures . '/section-element-type-changed/source-code-after', [ 'Mftf (PATCH)', + 'section-element-type-changed/source-code-before/Magento/TestModule/Test/Mftf/Section/section.xml:0', 'Section/SampleSection/element1/type |
type was changed | M218' ], 'Patch change is detected.' @@ -493,6 +538,7 @@ public function changesDataProvider() $pathToFixtures . '/section-element-parameterized-added/source-code-before', $pathToFixtures . '/section-element-parameterized-added/source-code-after', [ + 'section-element-parameterized-added/source-code-before/Magento/TestModule/Test/Mftf/Section/section.xml:0', 'Mftf (MAJOR)', 'Section/SampleSection/element1/parameterized |
parameterized was changed | M250' ], @@ -503,6 +549,7 @@ public function changesDataProvider() $pathToFixtures . '/section-element-parameterized-removed/source-code-after', [ 'Mftf (MAJOR)', + 'section-element-parameterized-removed/source-code-before/Magento/TestModule/Test/Mftf/Section/section.xml:0', 'Section/SampleSection/element1/parameterized |
parameterized was changed | M250' ], 'Major change is detected.' @@ -512,6 +559,7 @@ public function changesDataProvider() $pathToFixtures . '/section-element-added/source-code-after', [ 'Mftf (MINOR)', + 'section-element-added/source-code-before/Magento/TestModule/Test/Mftf/Section/section.xml:0', 'Section/SampleSection/newElement |
was added | M236' ], 'Minor change is detected.' @@ -521,6 +569,7 @@ public function changesDataProvider() $pathToFixtures . '/test-removed/source-code-after', [ 'Mftf (MAJOR)', + 'test-removed/source-code-before/Magento/TestModule/Test/Mftf/Test/test.xml:0', 'Test/SampleTest | was removed | M218' ], 'Major change is detected.' @@ -530,6 +579,7 @@ public function changesDataProvider() $pathToFixtures . '/test-added/source-code-after', [ 'Mftf (MINOR)', + 'test-added/source-code-after/Magento/TestModule/Test/Mftf/Test/test.xml:0', 'Test/NewTest | was added | M237' ], 'Minor change is detected.' @@ -539,6 +589,7 @@ public function changesDataProvider() $pathToFixtures . '/new-module-test-added/source-code-after', [ 'Mftf (MINOR)', + 'new-module-test-added/source-code-after/Magento/TestModuleTwo/Test/Mftf/Test/test.xml:0', 'Test/NewTest | was added | M237' ], 'Minor change is detected.' @@ -548,6 +599,7 @@ public function changesDataProvider() $pathToFixtures . '/test-action-changed/source-code-after', [ 'Mftf (PATCH)', + 'test-action-changed/source-code-before/Magento/TestModule/Test/Mftf/Test/test.xml:0', 'Test/SampleTest/key1/userInput | was changed | M222' ], 'Patch change is detected.' @@ -557,6 +609,7 @@ public function changesDataProvider() $pathToFixtures . '/test-action-sequence-changed/source-code-after', [ 'Mftf (MAJOR)', + 'test-action-sequence-changed/source-code-before/Magento/TestModule/Test/Mftf/Test/test.xml:0', 'Test/SampleTest | sequence was changed | M223' ], 'Major change is detected.' @@ -566,6 +619,7 @@ public function changesDataProvider() $pathToFixtures . '/test-action-type-changed/source-code-after', [ 'Mftf (PATCH)', + 'test-action-type-changed/source-code-before/Magento/TestModule/Test/Mftf/Test/test.xml:0', 'Test/SampleTest/action1 | type was changed | M224' ], 'Patch change is detected.' @@ -575,6 +629,7 @@ public function changesDataProvider() $pathToFixtures . '/test-action-removed/source-code-after', [ 'Mftf (MAJOR)', + 'test-action-removed/source-code-before/Magento/TestModule/Test/Mftf/Test/test.xml:0', 'Test/SampleTest/key2 | was removed | M219' ], 'Major change is detected.' @@ -584,6 +639,7 @@ public function changesDataProvider() $pathToFixtures . '/test-action-added/source-code-after', [ 'Mftf (MINOR)', + 'test-action-added/source-code-before/Magento/TestModule/Test/Mftf/Test/test.xml:0', 'Test/SampleTest/newAction | was added | M238' ], 'Minor change is detected.' @@ -593,6 +649,7 @@ public function changesDataProvider() $pathToFixtures . '/test-before-action-removed/source-code-after', [ 'Mftf (MAJOR)', + 'test-before-action-removed/source-code-before/Magento/TestModule/Test/Mftf/Test/test.xml:0', 'Test/SampleTest/before/key1 | was removed | M219' ], 'Major change is detected.' @@ -602,6 +659,7 @@ public function changesDataProvider() $pathToFixtures . '/test-before-action-added/source-code-after', [ 'Mftf (MINOR)', + 'test-before-action-added/source-code-before/Magento/TestModule/Test/Mftf/Test/test.xml:0', 'Test/SampleTest/before/newAction | was added | M238' ], 'Minor change is detected.' @@ -611,6 +669,7 @@ public function changesDataProvider() $pathToFixtures . '/test-before-action-sequence-changed/source-code-after', [ 'Mftf (MAJOR)', + 'test-before-action-sequence-changed/source-code-before/Magento/TestModule/Test/Mftf/Test/test.xml:0', 'Test/SampleTest/before | sequence was changed | M223' ], 'Major change is detected.' @@ -619,6 +678,7 @@ public function changesDataProvider() $pathToFixtures . '/test-after-action-removed/source-code-before', $pathToFixtures . '/test-after-action-removed/source-code-after', [ + 'test-after-action-removed/source-code-before/Magento/TestModule/Test/Mftf/Test/test.xml:0', 'Mftf (MAJOR)', 'Test/SampleTest/after/key1 | was removed | M219' ], @@ -629,6 +689,7 @@ public function changesDataProvider() $pathToFixtures . '/test-after-action-added/source-code-after', [ 'Mftf (MINOR)', + 'test-after-action-added/source-code-before/Magento/TestModule/Test/Mftf/Test/test.xml:0', 'Test/SampleTest/after/newAction | was added | M238' ], 'Minor change is detected.' @@ -638,6 +699,7 @@ public function changesDataProvider() $pathToFixtures . '/test-after-action-sequence-changed/source-code-after', [ 'Mftf (MAJOR)', + 'test-after-action-sequence-changed/source-code-before/Magento/TestModule/Test/Mftf/Test/test.xml:0', 'Test/SampleTest/after | sequence was changed | M223' ], 'Major change is detected.' @@ -647,6 +709,7 @@ public function changesDataProvider() $pathToFixtures . '/test-annotation-changed/source-code-after', [ 'Mftf (PATCH)', + 'test-annotation-changed/source-code-before/Magento/TestModule/Test/Mftf/Test/test.xml:0', 'Test/SampleTest/annotations/{}description | was removed or changed | M221' ], 'Patch change is detected.' @@ -656,6 +719,7 @@ public function changesDataProvider() $pathToFixtures . '/test-group-removed/source-code-after', [ 'Mftf (MAJOR)', + 'test-group-removed/source-code-before/Magento/TestModule/Test/Mftf/Test/test.xml:0', 'Test/SampleTest/annotations/{}group(sampleGroup) | was removed | M220' ], 'Major change is detected.' @@ -665,6 +729,7 @@ public function changesDataProvider() $pathToFixtures . '/test-remove-action-added/source-code-after', [ 'Mftf (MAJOR)', + 'test-remove-action-added/source-code-before/Magento/TestModule/Test/Mftf/Test/test.xml:0', 'Test/SampleTest/newRemoveAction | was added | M401' ], 'Major change is detected.' @@ -674,6 +739,7 @@ public function changesDataProvider() $pathToFixtures . '/test-remove-action-removed/source-code-after', [ 'Mftf (MAJOR)', + 'test-remove-action-removed/source-code-before/Magento/TestModule/Test/Mftf/Test/test.xml:0', 'Test/SampleTest/key2 | was removed | M402' ], 'Major change is detected.' @@ -683,6 +749,7 @@ public function changesDataProvider() $pathToFixtures . '/test-action-group-ref-changed/source-code-after', [ 'Mftf (MINOR)', + 'test-action-group-ref-changed/source-code-before/Magento/TestModule/Test/Mftf/Test/test.xml:0', 'Test/SampleTest/key2/ref | ref was changed | M241' ], 'Minor change is detected.' @@ -692,6 +759,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-added/source-code-after', [ 'Mftf (MINOR)', + 'suite-added/source-code-after/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/Sample2Suite | was added | M407' ], 'Minor change is detected.' @@ -701,6 +769,7 @@ public function changesDataProvider() $pathToFixtures . '/new-module-suite-added/source-code-after', [ 'Mftf (MINOR)', + 'new-module-suite-added/source-code-after/Magento/TestModuleTwo/Test/Mftf/Suite/suite.xml:0', 'Suite/Sample2Suite | was added | M407' ], 'Minor change is detected.' @@ -710,6 +779,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-removed/source-code-after', [ 'Mftf (MAJOR)', + 'suite-removed/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/Sample2Suite | was removed | M408' ], 'Major change is detected.' @@ -719,6 +789,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-after-action-added/source-code-after', [ 'Mftf (MINOR)', + 'suite-after-action-added/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/after/y | was added | M415' ], 'Minor change is detected.' @@ -728,6 +799,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-after-action-changed/source-code-after', [ 'Mftf (PATCH)', + 'suite-after-action-changed/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/after/x/url | was changed | M416' ], 'Patch change is detected.' @@ -737,6 +809,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-after-action-removed/source-code-after', [ 'Mftf (MAJOR)', + 'suite-after-action-removed/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/after/y | was removed | M412' ], 'Major change is detected.' @@ -746,6 +819,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-after-action-group-ref-changed/source-code-after', [ 'Mftf (MINOR)', + 'suite-after-action-group-ref-changed/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/after/z/ref | ref was changed | M417' ], 'Minor change is detected.' @@ -755,6 +829,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-after-action-sequence-changed/source-code-after', [ 'Mftf (MAJOR)', + 'suite-after-action-sequence-changed/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/after | sequence was changed | M418' ], 'Major change is detected.' @@ -764,6 +839,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-after-action-type-changed/source-code-after', [ 'Mftf (PATCH)', + 'suite-after-action-type-changed/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/after/y | type was changed | M419' ], 'Patch change is detected.' @@ -773,6 +849,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-before-action-added/source-code-after', [ 'Mftf (MINOR)', + 'suite-before-action-added/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/before/b | was added | M415' ], 'Minor change is detected.' @@ -782,6 +859,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-before-action-changed/source-code-after', [ 'Mftf (PATCH)', + 'suite-before-action-changed/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/before/b/userInput | was changed | M416' ], 'Patch change is detected.' @@ -791,6 +869,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-before-action-removed/source-code-after', [ 'Mftf (MAJOR)', + 'suite-before-action-removed/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/before/b | was removed | M412' ], 'Major change is detected.' @@ -800,6 +879,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-before-action-group-ref-changed/source-code-after', [ 'Mftf (MINOR)', + 'suite-before-action-group-ref-changed/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/before/c/ref | ref was changed | M417' ], 'Minor change is detected.' @@ -809,6 +889,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-before-action-sequence-changed/source-code-after', [ 'Mftf (MAJOR)', + 'suite-before-action-sequence-changed/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/before | sequence was changed | M418' ], 'Major change is detected.' @@ -818,6 +899,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-before-action-type-changed/source-code-after', [ 'Mftf (PATCH)', + 'suite-before-action-type-changed/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/before/b | type was changed | M419' ], 'Patch change is detected.' @@ -827,6 +909,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-exclude-added/source-code-after', [ 'Mftf (PATCH)', + 'suite-exclude-added/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/exclude/module1 | was added | M409', 'Suite/SampleSuite/exclude/test1 | was added | M409', ], @@ -837,6 +920,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-exclude-removed/source-code-after', [ 'Mftf (PATCH)', + 'suite-exclude-removed/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/exclude/module1 | was removed | M410' ], 'Patch change is detected.' @@ -846,6 +930,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-include-added/source-code-after', [ 'Mftf (PATCH)', + 'suite-include-added/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/include/module1 | was added | M409', 'Suite/SampleSuite/include/test1 | was added | M409', ], @@ -856,6 +941,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-include-removed/source-code-after', [ 'Mftf (PATCH)', + 'suite-include-removed/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/include/module1 | was removed | M410' ], 'Patch change is detected.' @@ -865,6 +951,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-include-changed/source-code-after', [ 'Mftf (PATCH)', + 'suite-include-changed/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/include/group1 | was removed | M410', 'Suite/SampleSuite/include/group2 | was added | M409', ], @@ -875,6 +962,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-exclude-changed/source-code-after', [ 'Mftf (PATCH)', + 'suite-exclude-changed/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/exclude/group1 | was removed | M410', 'Suite/SampleSuite/exclude/group2 | was added | M409', ], @@ -885,6 +973,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-after-remove-action-added/source-code-after', [ 'Mftf (MAJOR)', + 'suite-after-remove-action-added/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/after/x | was added | M420' ], 'Major change is detected.' @@ -894,6 +983,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-after-remove-action-removed/source-code-after', [ 'Mftf (MAJOR)', + 'suite-after-remove-action-removed/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/after/x | was removed | M421' ], 'Major change is detected.' @@ -903,6 +993,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-before-remove-action-added/source-code-after', [ 'Mftf (MAJOR)', + 'suite-before-remove-action-added/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/before/x | was added | M420' ], 'Major change is detected.' @@ -912,6 +1003,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-before-remove-action-removed/source-code-after', [ 'Mftf (MAJOR)', + 'suite-before-remove-action-removed/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/before/x | was removed | M421' ], 'Major change is detected.' @@ -921,6 +1013,7 @@ public function changesDataProvider() $pathToFixtures . '/actionGroup-remove-action-key-changed/source-code-after', [ 'Mftf (MAJOR)', + 'actionGroup-remove-action-key-changed/source-code-before/Magento/TestModule/Test/Mftf/ActionGroup/actionGroup.xml:0', 'ActionGroup/ActionGroup1/action2 | was removed | M406', 'ActionGroup/ActionGroup1/action1 | was added | M404', ], @@ -931,6 +1024,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-before-remove-action-key-changed/source-code-after', [ 'Mftf (MAJOR)', + 'suite-before-remove-action-key-changed/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/before/a | was removed | M421', 'Suite/SampleSuite/before/b | was added | M420', ], @@ -941,6 +1035,7 @@ public function changesDataProvider() $pathToFixtures . '/suite-after-remove-action-key-changed/source-code-after', [ 'Mftf (MAJOR)', + ' suite-after-remove-action-key-changed/source-code-before/Magento/TestModule/Test/Mftf/Suite/suite.xml:0', 'Suite/SampleSuite/after/a | was removed | M421', 'Suite/SampleSuite/after/b | was added | M420', ], @@ -951,6 +1046,7 @@ public function changesDataProvider() $pathToFixtures . '/test-remove-action-key-changed/source-code-after', [ 'Mftf (MAJOR)', + 'test-remove-action-key-changed/source-code-before/Magento/TestModule/Test/Mftf/Test/test.xml:0', 'Test/SampleTest/key2 | was removed | M402', 'Test/SampleTest/key1 | was added | M401', ], diff --git a/tests/Unit/Console/Command/CompareSourceCommandSystemXmlTest.php b/tests/Unit/Console/Command/CompareSourceCommandSystemXmlTest.php index bfda69f7..72170c1b 100644 --- a/tests/Unit/Console/Command/CompareSourceCommandSystemXmlTest.php +++ b/tests/Unit/Console/Command/CompareSourceCommandSystemXmlTest.php @@ -60,7 +60,7 @@ public function changesDataProvider() $pathToFixtures . '/file-added/source-code-after', [ 'Suggested semantic versioning change: MINOR', - 'Magento_TestModule:0 | system.xml | System configuration file was added | M300', + 'Magento/TestModule/etc/adminhtml/system.xml:0 | system.xml | System configuration file was added | M300', ], 'Minor change is detected.', ], @@ -69,7 +69,7 @@ public function changesDataProvider() $pathToFixtures . '/file-removed/source-code-after', [ 'Suggested semantic versioning change: MAJOR', - 'Magento_TestModule:0 | system.xml | System configuration file was added | M301', + 'Magento/TestModule/etc/adminhtml/system.xml:0 | system.xml | System configuration file was added | M301', ], 'Major change is detected.', ], @@ -78,7 +78,7 @@ public function changesDataProvider() $pathToFixtures . '/section-added/source-code-after', [ 'Suggested semantic versioning change: MINOR', - 'Magento_TestModule:0 | added_section | A section-node was added | M306', + 'Magento/TestModule/etc/adminhtml/system.xml:0 | added_section | A section-node was added | M306', ], 'Minor change is detected.', ], @@ -87,7 +87,7 @@ public function changesDataProvider() $pathToFixtures . '/section-removed/source-code-after', [ 'Suggested semantic versioning change: MAJOR', - 'Magento_TestModule:0 | removed_section | a section-node was removed | MM307', + 'Magento/TestModule/etc/adminhtml/system.xml:0 | removed_section | a section-node was removed | MM307', ], 'Major change is detected.', ], @@ -96,7 +96,7 @@ public function changesDataProvider() $pathToFixtures . '/group-added/source-code-after', [ 'Suggested semantic versioning change: MINOR', - 'Magento_TestModule:0 | magento_testmodule/added_group | A group-node was added | M304', + 'Magento/TestModule/etc/adminhtml/system.xml:0 | magento_testmodule/added_group | A group-node was added | M304', ], 'Minor change is detected.', ], @@ -105,7 +105,7 @@ public function changesDataProvider() $pathToFixtures . '/group-removed/source-code-after', [ 'Suggested semantic versioning change: MAJOR', - 'Magento_TestModule:0 | magento_testmodule/removed_group | A group-node was removed | M305', + 'Magento/TestModule/etc/adminhtml/system.xml:0 | magento_testmodule/removed_group | A group-node was removed | M305', ], 'Major change is detected.', ], @@ -114,7 +114,7 @@ public function changesDataProvider() $pathToFixtures . '/field-added/source-code-after', [ 'Suggested semantic versioning change: MINOR', - 'Magento_TestModule:0 | magento_testmodule/general/added_field | A field-node was added | M302', + 'Magento/TestModule/etc/adminhtml/system.xml:0 | magento_testmodule/general/added_field | A field-node was added | M302', ], 'Minor change is detected.', ], @@ -123,7 +123,7 @@ public function changesDataProvider() $pathToFixtures . '/field-removed/source-code-after', [ 'Suggested semantic versioning change: MAJOR', - 'Magento_TestModule:0 | magento_testmodule/general/removed_field | A field-node was removed | M303', + 'Magento/TestModule/etc/adminhtml/system.xml:0 | magento_testmodule/general/removed_field | A field-node was removed | M303', ], 'Major change is detected.', ], diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/AbstractHtmlTestCaseForHtml.php b/tests/Unit/Console/Command/CompareSourceCommandTest/AbstractHtmlTestCaseForHtml.php new file mode 100644 index 00000000..b41e34e4 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/AbstractHtmlTestCaseForHtml.php @@ -0,0 +1,196 @@ +command = new CompareSourceCommand(); + $this->svcLogPath = TESTS_TEMP_DIR . '/svc-' . time() . '.html'; + } + + protected function tearDown() + { + parent::tearDown(); + unlink($this->svcLogPath); + } + + /** + * Executes the command that shall be tested and performs assertions. + * + * 1. Run semantic version checker command to compare 2 source code directories + * 2. Assert that SVC log contains expected entries + * 3. Assert console output + * 4. Assert return code + * + * @param string $pathToSourceCodeBefore + * @param string $pathToSourceCodeAfter + * @param int $allowedChangeLevel + * @param HtmlParseInfoContainer[] $expectedHtmlEntries + * @param array $expectedPackageSection + * @param string $expectedOutput + * @param $expectedStatusCode + * @param $reportTypes + * @param bool $shouldSkipTest + * @throws Exception + */ + protected function doTestExecute( + string $pathToSourceCodeBefore, + string $pathToSourceCodeAfter, + int $allowedChangeLevel, + array $expectedHtmlEntries, + array $expectedPackageSection, + string $expectedOutput, + int $expectedStatusCode, + array $reportTypes, + bool $shouldSkipTest + ): void { + try { + $commandTester = $this->executeCommand($pathToSourceCodeBefore, $pathToSourceCodeAfter, $allowedChangeLevel, $reportTypes); + $svcDom = $this->getSvcReportDOM(); + self::assertJsonContent($expectedPackageSection, $svcDom); + foreach ($expectedHtmlEntries as $expectedHtmlEntry) { + $this->assertHtml($expectedHtmlEntry->xpath, $expectedHtmlEntry->pattern, $svcDom); + } + $this->assertContains($expectedOutput, $commandTester->getDisplay()); + $this->assertEquals($expectedStatusCode, $commandTester->getStatusCode()); + } catch (Exception $e) { + if ($shouldSkipTest) { + $this->markTestSkipped($e->getMessage()); + } else { + throw $e; + } + } + } + + /** + * Validate json in html svc document + * + * @param array $expectedJson + * @param DOMDocument $docDom + */ + private static function assertJsonContent(array $expectedJson, DOMDocument $docDom) { + if (!$expectedJson) { + $xpathQuery = '/html/body/table/tbody/tr[last()]/td[2]'; + $pattern = '#No BIC changes found to packages#i'; + self::assertHtml($xpathQuery, $pattern, $docDom); + } else { + $docXpath = new DOMXPath($docDom); + $xpathQuery = '//*[@id="packageChangesJson"]/text()'; + static::assertHtml($xpathQuery, null, $docDom); //ensure xpath resolves + $jsonText = $docDom->saveHTML($docXpath->query($xpathQuery)->item(0)); + $encodedJson = json_decode($jsonText); + //store expectedJson in same format + $expectedJson = json_decode(json_encode($expectedJson)); + sort($expectedJson); + sort($encodedJson); + self::assertEquals($expectedJson, $encodedJson); + } + } + + /** + * Assert HTML document resolves xpath, resolves finding pattern, or resolves finding pattern within resolved xpath + * + * @param $xpathQuery + * @param $regex + * @param DOMDocument $docDom + */ + public static function assertHtml($xpathQuery, $regex, DOMDocument $docDom) + { + $docXpath = new DOMXPath($docDom); + if ($xpathQuery) { + $nodeList = $docXpath->query($xpathQuery); + if (!$nodeList || !$nodeList->length) { + $body = $docXpath->document->saveHTML(); + static::fail('xpath selector: ' . $xpathQuery . " was invalid. Unable to return result from document:\n" . $body); //throws exception + } + if ($regex) { + $body = $docDom->saveHTML($nodeList->item(0)); + static::assertRegExp($regex, $body); + } + } else { + $body = $docXpath->document->saveHTML(); + static::assertRegExp($regex, $body); + } + } + + /** + * Executes {@link CompareSourceCommandTest::$command} via {@link CommandTester}, using the arguments as command + * line parameters. + * + * The command line parameters are specified as follows: + *
    + *
  • source-before: The content of the argument $pathToSourceCodeBefore
  • + *
  • source-after: The content of the argument $pathToSourceCodeAfter
  • + *
  • --log-output-location: The content of {@link CompareSourceCommandTest::$svcLogPath}
  • + *
  • --include-patterns: The path to the file ./_files/application_includes.txt
  • + *
+ * + * @param string $pathToSourceCodeBefore + * @param string $pathToSourceCodeAfter + * @param int $allowedChangeLevel + * @param array $reportTypes + * @return CommandTester + */ + protected function executeCommand(string $pathToSourceCodeBefore, string $pathToSourceCodeAfter, int $allowedChangeLevel, array $reportTypes): CommandTester + { + $commandTester = new CommandTester($this->command); + $commandTester->execute( + [ + 'source-before' => $pathToSourceCodeBefore, + 'source-after' => $pathToSourceCodeAfter, + '--log-output-location' => $this->svcLogPath, + '--include-patterns' => __DIR__ . '/_files/application_includes.txt', + '--report-type' => $reportTypes, + 'allowed-change-level' => $allowedChangeLevel, + ] + ); + return $commandTester; + } + + /** + * Returns the contents of the file specified in {@link CompareSourceCommandTest::$svcLogPath}. + * + * @return DOMDocument + */ + private function getSvcReportDOM() : ?DOMDocument + { + $source = file_get_contents($this->svcLogPath); + if (!$source) { + return null; + } + $doc = new DOMDocument(); + $doc->loadHTML($source); + return $doc; + } +} diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/HtmlParseInfoContainer.php b/tests/Unit/Console/Command/CompareSourceCommandTest/HtmlParseInfoContainer.php new file mode 100644 index 00000000..b56dc526 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/HtmlParseInfoContainer.php @@ -0,0 +1,38 @@ +xpath = $xpath; + $this->pattern = $pattern; + } + +} \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/api-class/added-extends/TestClass.php b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/api-class/added-extends/TestClass.php new file mode 100644 index 00000000..18cafd21 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/api-class/added-extends/TestClass.php @@ -0,0 +1,14 @@ + + + + + + + + + + +
+ diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/db_schema/add-foreign-key/Magento/DbSchema/etc/db_schema_whitelist.json b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/db_schema/add-foreign-key/Magento/DbSchema/etc/db_schema_whitelist.json new file mode 100644 index 00000000..d4b9b315 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/db_schema/add-foreign-key/Magento/DbSchema/etc/db_schema_whitelist.json @@ -0,0 +1,14 @@ +{ + "unit_test_table": { + "column": { + "id_column": true, + "severity": true, + "title": true, + "time_occurred": true + }, + "constraint": { + "PRIMARY": true, + "FL_ALLOWED_SEVERITIES": true + } + } +} \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/db_schema/composer.json b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/db_schema/composer.json new file mode 100644 index 00000000..a9eb0de0 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/db_schema/composer.json @@ -0,0 +1,4 @@ +{ + "name": "test/db_schema", + "description": "module composer package" +} \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/di_xml/change-name/Magento/TestModule/etc/di.xml b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/di_xml/change-name/Magento/TestModule/etc/di.xml new file mode 100644 index 00000000..cfcd705f --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/di_xml/change-name/Magento/TestModule/etc/di.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/di_xml/composer.json b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/di_xml/composer.json new file mode 100644 index 00000000..d13e6924 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/di_xml/composer.json @@ -0,0 +1,4 @@ +{ + "name": "test/di_xml", + "description": "module composer package" +} \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/layout_xml/block_remove/Magento/Customer/view/adminhtml/layout/customer_index_viewwishlist.xml b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/layout_xml/block_remove/Magento/Customer/view/adminhtml/layout/customer_index_viewwishlist.xml new file mode 100644 index 00000000..ce6713c8 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/layout_xml/block_remove/Magento/Customer/view/adminhtml/layout/customer_index_viewwishlist.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/layout_xml/composer.json b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/layout_xml/composer.json new file mode 100644 index 00000000..c9944188 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/layout_xml/composer.json @@ -0,0 +1,4 @@ +{ + "name": "test/layout_xml", + "description": "module composer package" +} \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/less/composer.json b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/less/composer.json new file mode 100644 index 00000000..45020131 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/less/composer.json @@ -0,0 +1,4 @@ +{ + "name": "test/less", + "description": "module composer package" +} \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/less/removed-import/Magento/TestModule/view/frontend/web/css/source/test.less b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/less/removed-import/Magento/TestModule/view/frontend/web/css/source/test.less new file mode 100644 index 00000000..32f58709 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/less/removed-import/Magento/TestModule/view/frontend/web/css/source/test.less @@ -0,0 +1 @@ +// Exemplary import declaration \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/mftf/composer.json b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/mftf/composer.json new file mode 100644 index 00000000..166f4e71 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/mftf/composer.json @@ -0,0 +1,4 @@ +{ + "name": "test/mftf", + "description": "module composer package" +} \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/mftf/suite-after-action-changed/Magento/TestModule/Test/Mftf/Suite/suite.xml b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/mftf/suite-after-action-changed/Magento/TestModule/Test/Mftf/Suite/suite.xml new file mode 100644 index 00000000..79ddf8ec --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/mftf/suite-after-action-changed/Magento/TestModule/Test/Mftf/Suite/suite.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/system_xml/composer.json b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/system_xml/composer.json new file mode 100644 index 00000000..11a77f4a --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/system_xml/composer.json @@ -0,0 +1,4 @@ +{ + "name": "test/system_xml", + "description": "module composer package" +} \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/system_xml/field_removed/Magento/TestModule/etc/adminhtml/system.xml b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/system_xml/field_removed/Magento/TestModule/etc/adminhtml/system.xml new file mode 100644 index 00000000..5e9f0cdd --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/system_xml/field_removed/Magento/TestModule/etc/adminhtml/system.xml @@ -0,0 +1,19 @@ + + + + +
+ + + + + +
+
+
\ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/xsd-schema/attribute-removed/Magento/TestModule/etc/test-schema.xsd b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/xsd-schema/attribute-removed/Magento/TestModule/etc/test-schema.xsd new file mode 100644 index 00000000..5e463a6b --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/xsd-schema/attribute-removed/Magento/TestModule/etc/test-schema.xsd @@ -0,0 +1,15 @@ + + + + + + + Type to which a required attribute is added + + + \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/xsd-schema/composer.json b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/xsd-schema/composer.json new file mode 100644 index 00000000..55cce453 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-after/xsd-schema/composer.json @@ -0,0 +1,4 @@ +{ + "name": "test/xsd-schema", + "description": "module composer package" +} \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/api-class/added-extends/TestClass.php b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/api-class/added-extends/TestClass.php new file mode 100644 index 00000000..7f9a6cf5 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/api-class/added-extends/TestClass.php @@ -0,0 +1,14 @@ + + + + + + + + + +
+ diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/db_schema/add-foreign-key/Magento/DbSchema/etc/db_schema_whitelist.json b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/db_schema/add-foreign-key/Magento/DbSchema/etc/db_schema_whitelist.json new file mode 100644 index 00000000..0d2f33a3 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/db_schema/add-foreign-key/Magento/DbSchema/etc/db_schema_whitelist.json @@ -0,0 +1,13 @@ +{ + "unit_test_table": { + "column": { + "id_column": true, + "severity": true, + "title": true, + "time_occurred": true + }, + "constraint": { + "PRIMARY": true + } + } +} \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/db_schema/composer.json b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/db_schema/composer.json new file mode 100644 index 00000000..a9eb0de0 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/db_schema/composer.json @@ -0,0 +1,4 @@ +{ + "name": "test/db_schema", + "description": "module composer package" +} \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/di_xml/change-name/Magento/TestModule/etc/di.xml b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/di_xml/change-name/Magento/TestModule/etc/di.xml new file mode 100644 index 00000000..cdf21834 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/di_xml/change-name/Magento/TestModule/etc/di.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/di_xml/composer.json b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/di_xml/composer.json new file mode 100644 index 00000000..d13e6924 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/di_xml/composer.json @@ -0,0 +1,4 @@ +{ + "name": "test/di_xml", + "description": "module composer package" +} \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/layout_xml/block_remove/Magento/Customer/view/adminhtml/layout/customer_index_viewwishlist.xml b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/layout_xml/block_remove/Magento/Customer/view/adminhtml/layout/customer_index_viewwishlist.xml new file mode 100644 index 00000000..6551657b --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/layout_xml/block_remove/Magento/Customer/view/adminhtml/layout/customer_index_viewwishlist.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/layout_xml/composer.json b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/layout_xml/composer.json new file mode 100644 index 00000000..c9944188 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/layout_xml/composer.json @@ -0,0 +1,4 @@ +{ + "name": "test/layout_xml", + "description": "module composer package" +} \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/less/composer.json b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/less/composer.json new file mode 100644 index 00000000..45020131 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/less/composer.json @@ -0,0 +1,4 @@ +{ + "name": "test/less", + "description": "module composer package" +} \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/less/removed-import/Magento/TestModule/view/frontend/web/css/source/test.less b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/less/removed-import/Magento/TestModule/view/frontend/web/css/source/test.less new file mode 100644 index 00000000..01a5c03f --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/less/removed-import/Magento/TestModule/view/frontend/web/css/source/test.less @@ -0,0 +1,2 @@ +// Exemplary import declaration +@import 'testimport'; \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/mftf/composer.json b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/mftf/composer.json new file mode 100644 index 00000000..166f4e71 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/mftf/composer.json @@ -0,0 +1,4 @@ +{ + "name": "test/mftf", + "description": "module composer package" +} \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/mftf/suite-after-action-changed/Magento/TestModule/Test/Mftf/Suite/suite.xml b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/mftf/suite-after-action-changed/Magento/TestModule/Test/Mftf/Suite/suite.xml new file mode 100644 index 00000000..56adf146 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/mftf/suite-after-action-changed/Magento/TestModule/Test/Mftf/Suite/suite.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/system_xml/composer.json b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/system_xml/composer.json new file mode 100644 index 00000000..11a77f4a --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/system_xml/composer.json @@ -0,0 +1,4 @@ +{ + "name": "test/system_xml", + "description": "module composer package" +} \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/system_xml/field_removed/Magento/TestModule/etc/adminhtml/system.xml b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/system_xml/field_removed/Magento/TestModule/etc/adminhtml/system.xml new file mode 100644 index 00000000..c9522062 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/system_xml/field_removed/Magento/TestModule/etc/adminhtml/system.xml @@ -0,0 +1,22 @@ + + + + +
+ + + + + + + + +
+
+
\ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/xsd-schema/attribute-removed/Magento/TestModule/etc/test-schema.xsd b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/xsd-schema/attribute-removed/Magento/TestModule/etc/test-schema.xsd new file mode 100644 index 00000000..5cc68556 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/xsd-schema/attribute-removed/Magento/TestModule/etc/test-schema.xsd @@ -0,0 +1,18 @@ + + + + + + + Type from which attributes are removed + + + + + + \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/xsd-schema/composer.json b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/xsd-schema/composer.json new file mode 100644 index 00000000..55cce453 --- /dev/null +++ b/tests/Unit/Console/Command/CompareSourceCommandTest/_files/all/source-code-before/xsd-schema/composer.json @@ -0,0 +1,4 @@ +{ + "name": "test/xsd-schema", + "description": "module composer package" +} \ No newline at end of file diff --git a/tests/Unit/Console/Command/CompareSourceCommandXsdSchemasTest.php b/tests/Unit/Console/Command/CompareSourceCommandXsdSchemasTest.php index 97d67413..60e6c467 100644 --- a/tests/Unit/Console/Command/CompareSourceCommandXsdSchemasTest.php +++ b/tests/Unit/Console/Command/CompareSourceCommandXsdSchemasTest.php @@ -60,6 +60,7 @@ public function changesDataProvider() $pathToFixtures . '/optional-node-added/source-code-after', [ 'Suggested semantic versioning change: MINOR', + 'optional-node-added/source-code-after/Magento/TestModule/etc/test-schema.xsd:0', 'addedOptionalElement | An optional node was added | M0133', ], 'Minor change is detected.', @@ -69,6 +70,7 @@ public function changesDataProvider() $pathToFixtures . '/optional-attribute-added/source-code-after', [ 'Suggested semantic versioning change: MINOR', + 'optional-attribute-added/source-code-after/Magento/TestModule/etc/test-schema.xsd:0', 'optionalAttribute | An optional attribute was added | M0134', ], 'Minor change is detected.', @@ -78,6 +80,7 @@ public function changesDataProvider() $pathToFixtures . '/required-node-added/source-code-after', [ 'Suggested semantic versioning change: MAJOR', + 'required-node-added/source-code-after/Magento/TestModule/etc/test-schema.xsd:0', 'addedRequiredElement | A required node was added | M0135', ], 'Major change is detected.', @@ -87,6 +90,7 @@ public function changesDataProvider() $pathToFixtures . '/required-attribute-added/source-code-after', [ 'Suggested semantic versioning change: MAJOR', + 'required-attribute-added/source-code-after/Magento/TestModule/etc/test-schema.xsd:0', 'requiredAttribute | A required attribute was added | M0136', ], 'Major change is detected.', @@ -96,8 +100,8 @@ public function changesDataProvider() $pathToFixtures . '/node-removed/source-code-after', [ 'Suggested semantic versioning change: MAJOR', - 'requiredElement | A node was removed | M0137', - 'optionalElement | A node was removed | M0137', + 'node-removed/source-code-before/Magento/TestModule/etc/test-schema.xsd:0 | requiredElement | A node was removed | M0137', + 'node-removed/source-code-before/Magento/TestModule/etc/test-schema.xsd:0 | optionalElement | A node was removed | M0137', ], 'Major change is detected.', ], @@ -106,8 +110,8 @@ public function changesDataProvider() $pathToFixtures . '/attribute-removed/source-code-after', [ 'Suggested semantic versioning change: MAJOR', - 'requiredAttribute | An attribute was removed | M0138', - 'optionalAttribute | An attribute was removed | M0138', + 'attribute-removed/source-code-before/Magento/TestModule/etc/test-schema.xsd:0 | requiredAttribute | An attribute was removed | M0138', + 'attribute-removed/source-code-before/Magento/TestModule/etc/test-schema.xsd:0 | optionalAttribute | An attribute was removed | M0138', ], 'Major change is detected.', ], @@ -116,7 +120,8 @@ public function changesDataProvider() $pathToFixtures . '/schema-declaration-removed/source-code-after', [ 'Suggested semantic versioning change: MAJOR', - '/etc/test-schema.xsd | A schema declaration was removed | M0139', + 'schema-declaration-removed/source-code-before/Magento/TestModule/etc/test-schema.xsd:0', + '/etc/test-schema.xsd | A schema declaration was removed | M0139' ], 'Major change is detected.', ], @@ -125,6 +130,7 @@ public function changesDataProvider() $pathToFixtures . '/schema-declaration-added/source-code-after', [ 'Suggested semantic versioning change: MINOR', + 'schema-declaration-added/source-code-after/Magento/TestModule/etc/test-schema.xsd:0', '/etc/test-schema.xsd | A schema declaration was added | M0140', ], 'Minor change is detected.', @@ -134,6 +140,7 @@ public function changesDataProvider() $pathToFixtures . '/module-added/source-code-after', [ 'Suggested semantic versioning change: MINOR', + 'module-added/source-code-after/Magento/TestModule/etc/test-schema.xsd:0', '/etc/test-schema.xsd | A schema declaration was added | M0140', ], 'Minor change is detected.', @@ -143,6 +150,7 @@ public function changesDataProvider() $pathToFixtures . '/module-removed/source-code-after', [ 'Suggested semantic versioning change: MAJOR', + 'module-removed/source-code-before/Magento/TestModule/etc/test-schema.xsd:0', '/etc/test-schema.xsd | A schema declaration was removed | M0139', ], 'Major change is detected.', diff --git a/tests/Unit/Console/Command/HtmlTest.php b/tests/Unit/Console/Command/HtmlTest.php new file mode 100644 index 00000000..7e9ac0f9 --- /dev/null +++ b/tests/Unit/Console/Command/HtmlTest.php @@ -0,0 +1,165 @@ +api annotation. + * + * @param string $pathToSourceCodeBefore + * @param string $pathToSourceCodeAfter + * @param int $allowedChangeLevel + * @param array $expectedHtmlEntries + * @param array $expectedPackageSection + * @param string $expectedOutput + * @param int $expectedStatusCode + * @param array $reportTypes + * @param bool $shouldSkipTest + * @return void + * @throws \Exception + * @dataProvider changesDataProvider + */ + public function testExecute( + string $pathToSourceCodeBefore, + string $pathToSourceCodeAfter, + int $allowedChangeLevel, + array $expectedHtmlEntries, + array $expectedPackageSection, + string $expectedOutput, + int $expectedStatusCode, + array $reportTypes, + bool $shouldSkipTest = false + ) { + $this->doTestExecute( + $pathToSourceCodeBefore, + $pathToSourceCodeAfter, + $allowedChangeLevel, + $expectedHtmlEntries, + $expectedPackageSection, + $expectedOutput, + $expectedStatusCode, + $reportTypes, + $shouldSkipTest + ); + } + + public function changesDataProvider() + { + $pathToFixtures = __DIR__ . '/CompareSourceCommandTest/_files/all'; + + return [ + 'test disallowing all versioned changes for all report types (excludes NonApi)' => [ + $pathToFixtures . '/source-code-before', + $pathToFixtures . '/source-code-after', + Level::NONE, + [ + new HtmlParseInfoContainer('#MAJOR#', '//html/body/table/tbody/tr[1]/td[2]'), + new HtmlParseInfoContainer('#Package Level Changes#', '//html/body/table/tbody/tr[last()]/td[1]'), + ], + [ + ['name' => 'test/api-class', 'level' => 'MINOR' ], + ['name' => 'test/api-trait', 'level' => 'MAJOR' ], + ['name' => 'test/layout_xml', 'level' => 'MAJOR' ], + ['name' => 'test/db_schema', 'level' => 'MAJOR' ], + ['name' => 'test/di_xml', 'level' => 'MAJOR' ], + ['name' => 'test/system_xml', 'level' => 'MAJOR' ], + ['name' => 'test/xsd-schema', 'level' => 'MAJOR' ], + ['name' => 'test/less', 'level' => 'MAJOR' ], + ['name' => 'test/mftf', 'level' => 'PATCH' ], + ], + 'Major change is detected.', + -1, + self::getAllReportTypes() + ], + 'test disallowing only Major changes for all types (excludes Non-api php files)' => [ + $pathToFixtures . '/source-code-before', + $pathToFixtures . '/source-code-after', + Level::MINOR, + [ + new HtmlParseInfoContainer('#MAJOR#', '//html/body/table/tbody/tr[1]/td[2]'), + new HtmlParseInfoContainer('#Package Level Changes#', '//html/body/table/tbody/tr[last()]/td[1]'), + ], + [ + ['name' => 'test/api-trait', 'level' => 'MAJOR' ], + ['name' => 'test/layout_xml', 'level' => 'MAJOR' ], + ['name' => 'test/db_schema', 'level' => 'MAJOR' ], + ['name' => 'test/di_xml', 'level' => 'MAJOR' ], + ['name' => 'test/system_xml', 'level' => 'MAJOR' ], + ['name' => 'test/xsd-schema', 'level' => 'MAJOR' ], + ['name' => 'test/less', 'level' => 'MAJOR' ], + ], + 'Major change is detected.', + -1, + self::getAllReportTypes() + ], + 'test allowing only patch changes for all types (excludes Non-api php files)' => [ + $pathToFixtures . '/source-code-before', + $pathToFixtures . '/source-code-after', + Level::PATCH, + [ + new HtmlParseInfoContainer('#MAJOR#', '//html/body/table/tbody/tr[1]/td[2]'), + new HtmlParseInfoContainer('#Package Level Changes#', '//html/body/table/tbody/tr[last()]/td[1]'), + ], + [ + ['name' => 'test/api-class', 'level' => 'MINOR' ], + ['name' => 'test/api-trait', 'level' => 'MAJOR' ], + ['name' => 'test/layout_xml', 'level' => 'MAJOR' ], + ['name' => 'test/db_schema', 'level' => 'MAJOR' ], + ['name' => 'test/di_xml', 'level' => 'MAJOR' ], + ['name' => 'test/system_xml', 'level' => 'MAJOR' ], + ['name' => 'test/xsd-schema', 'level' => 'MAJOR' ], + ['name' => 'test/less', 'level' => 'MAJOR' ], + ], + 'Major change is detected.', + -1, + self::getAllReportTypes() + ], + 'test allowing all changes for all types (excludes Non-api php files)' => [ + $pathToFixtures . '/source-code-before', + $pathToFixtures . '/source-code-after', + Level::MAJOR, + [ + new HtmlParseInfoContainer('#MAJOR#', '//html/body/table/tbody/tr[1]/td[2]'), + new HtmlParseInfoContainer('#Package Level Changes#', '//html/body/table/tbody/tr[last()]/td[1]'), + ], + [], + 'Major change is detected.', + 0, + self::getAllReportTypes() + ], + ]; + } + + /** + * Get all report types + * + * @return array + */ + private static function getAllReportTypes():array { + if(!self::$reportTypesList) { + self::$reportTypesList = (new ReflectionClass(ReportTypes::class))->getConstants(); + } + return self::$reportTypesList; + } +}