From cab2f92f973d0887fb78bd20d15354ceef588736 Mon Sep 17 00:00:00 2001 From: Sergio Vera Date: Mon, 23 Aug 2021 16:06:50 +0200 Subject: [PATCH 01/15] AC-659: Create phpcs static check for ModuleXMLTest --- Magento2/Sniffs/Legacy/ModuleXMLSniff.php | 57 +++++++++++++++++++++ Magento2/Tests/Legacy/ModuleXMLUnitTest.php | 29 +++++++++++ Magento2/Tests/Legacy/ModuleXMLUnitTest.xml | 10 ++++ Magento2/ruleset.xml | 7 +++ composer.json | 3 +- 5 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 Magento2/Sniffs/Legacy/ModuleXMLSniff.php create mode 100644 Magento2/Tests/Legacy/ModuleXMLUnitTest.php create mode 100644 Magento2/Tests/Legacy/ModuleXMLUnitTest.xml diff --git a/Magento2/Sniffs/Legacy/ModuleXMLSniff.php b/Magento2/Sniffs/Legacy/ModuleXMLSniff.php new file mode 100644 index 00000000..087027e9 --- /dev/null +++ b/Magento2/Sniffs/Legacy/ModuleXMLSniff.php @@ -0,0 +1,57 @@ +getTokensAsString(0, 999999)); + + if ($xml->xpath('/config/module/@version') !== false) { + $phpcsFile->addWarning( + 'The "version" attribute is obsolete. Use "setup_version" instead.', + $stackPtr, + $this->warningCode + ); + } + + if ($xml->xpath('/config/module/@active') !== false) { + $phpcsFile->addWarning( + 'The "active" attribute is obsolete. The list of active modules is defined in deployment configuration.', + $stackPtr, + $this->warningCode + ); + } + } +} diff --git a/Magento2/Tests/Legacy/ModuleXMLUnitTest.php b/Magento2/Tests/Legacy/ModuleXMLUnitTest.php new file mode 100644 index 00000000..d5c4328f --- /dev/null +++ b/Magento2/Tests/Legacy/ModuleXMLUnitTest.php @@ -0,0 +1,29 @@ + 2 + ]; + } +} \ No newline at end of file diff --git a/Magento2/Tests/Legacy/ModuleXMLUnitTest.xml b/Magento2/Tests/Legacy/ModuleXMLUnitTest.xml new file mode 100644 index 00000000..e94daaf7 --- /dev/null +++ b/Magento2/Tests/Legacy/ModuleXMLUnitTest.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/Magento2/ruleset.xml b/Magento2/ruleset.xml index 3ea0c969..dcf3c608 100644 --- a/Magento2/ruleset.xml +++ b/Magento2/ruleset.xml @@ -223,6 +223,13 @@ 8 warning + + *\.php$ + module.xml + ModuleXMLUnitTest.xml + 8 + warning + diff --git a/composer.json b/composer.json index d6004a88..42cbd3be 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,8 @@ "require": { "php": ">=7.3", "squizlabs/php_codesniffer": "^3.6", - "webonyx/graphql-php": "^14.9" + "webonyx/graphql-php": "^14.9", + "ext-simplexml": "*" }, "require-dev": { "phpunit/phpunit": "^9.5.8" From e935df801705227ed7743d5da691d64ed2bb1168 Mon Sep 17 00:00:00 2001 From: Sergio Vera Date: Mon, 23 Aug 2021 16:10:03 +0200 Subject: [PATCH 02/15] AC-659: Create phpcs static check for ModuleXMLTest --- Magento2/Tests/Legacy/ModuleXMLUnitTest.php | 2 +- Magento2/Tests/Legacy/ModuleXMLUnitTest.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Magento2/Tests/Legacy/ModuleXMLUnitTest.php b/Magento2/Tests/Legacy/ModuleXMLUnitTest.php index d5c4328f..718ebf9f 100644 --- a/Magento2/Tests/Legacy/ModuleXMLUnitTest.php +++ b/Magento2/Tests/Legacy/ModuleXMLUnitTest.php @@ -26,4 +26,4 @@ public function getWarningList() 1 => 2 ]; } -} \ No newline at end of file +} diff --git a/Magento2/Tests/Legacy/ModuleXMLUnitTest.xml b/Magento2/Tests/Legacy/ModuleXMLUnitTest.xml index e94daaf7..28c02b6f 100644 --- a/Magento2/Tests/Legacy/ModuleXMLUnitTest.xml +++ b/Magento2/Tests/Legacy/ModuleXMLUnitTest.xml @@ -7,4 +7,4 @@ --> - \ No newline at end of file + From aa530654413d585b77662e25ab21a9e711d9a28f Mon Sep 17 00:00:00 2001 From: Sergio Vera Date: Mon, 23 Aug 2021 16:12:14 +0200 Subject: [PATCH 03/15] AC-659: Create phpcs static check for ModuleXMLTest --- composer.lock | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.lock b/composer.lock index 72a2ad6a..fc31a666 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1ed3638000f0e172d4e01c45333fcfb6", + "content-hash": "148dc78a64f9790450688c1d3310f3e7", "packages": [ { "name": "squizlabs/php_codesniffer", @@ -2228,7 +2228,8 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.3" + "php": ">=7.3", + "ext-simplexml": "*" }, "platform-dev": [], "plugin-api-version": "2.1.0" From 8d23aa4fc00f03f141a1013a95c475af5a1ccfd8 Mon Sep 17 00:00:00 2001 From: Sergio Vera Date: Tue, 24 Aug 2021 14:42:45 +0200 Subject: [PATCH 04/15] AC-659: Create phpcs static check for ModuleXMLTest --- Magento2/Sniffs/Legacy/ModuleXMLSniff.php | 57 ++++++++++++++++----- Magento2/Tests/Legacy/ModuleXMLUnitTest.php | 2 +- Magento2/ruleset.xml | 8 +-- composer.json | 3 +- 4 files changed, 51 insertions(+), 19 deletions(-) diff --git a/Magento2/Sniffs/Legacy/ModuleXMLSniff.php b/Magento2/Sniffs/Legacy/ModuleXMLSniff.php index 087027e9..a60c9fdb 100644 --- a/Magento2/Sniffs/Legacy/ModuleXMLSniff.php +++ b/Magento2/Sniffs/Legacy/ModuleXMLSniff.php @@ -8,6 +8,7 @@ use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; +use SimpleXMLElement; /** * Test for obsolete nodes/attributes in the module.xml @@ -36,22 +37,52 @@ public function register(): array */ public function process(File $phpcsFile, $stackPtr) { - $xml = simplexml_load_string($phpcsFile->getTokensAsString(0, 999999)); + $line = $phpcsFile->getTokens()[$stackPtr]['content']; + if (strpos(trim($line), 'xpath('/config/module/@version') !== false) { - $phpcsFile->addWarning( - 'The "version" attribute is obsolete. Use "setup_version" instead.', - $stackPtr, - $this->warningCode - ); + $xml = simplexml_load_string($phpcsFile->getTokensAsString(0, 999999)); + + $foundElements = $xml->xpath('/config/module'); + if ($foundElements === false) { + return; } - if ($xml->xpath('/config/module/@active') !== false) { - $phpcsFile->addWarning( - 'The "active" attribute is obsolete. The list of active modules is defined in deployment configuration.', - $stackPtr, - $this->warningCode - ); + foreach ($foundElements as $element) { + if (!$this->elementIsCurrentlySniffedLine($element, $stackPtr)) { + continue; + } + + if (property_exists($element->attributes(), 'version')) { + $phpcsFile->addWarning( + 'The "version" attribute is obsolete. Use "setup_version" instead.', + $stackPtr, + $this->warningCode + ); + } + + if (property_exists($element->attributes(), 'active')) { + $phpcsFile->addWarning( + 'The "active" attribute is obsolete. The list of active modules is defined in deployment configuration.', + $stackPtr, + $this->warningCode + ); + } + } + } + + /** + * @param SimpleXMLElement $element + * @param int $stackPtr + * @return bool + */ + private function elementIsCurrentlySniffedLine(SimpleXMLElement $element, int $stackPtr): bool + { + $node = dom_import_simplexml($element); + if ($node->getLineNo() === $stackPtr+1) { + return true; } + return false; } } diff --git a/Magento2/Tests/Legacy/ModuleXMLUnitTest.php b/Magento2/Tests/Legacy/ModuleXMLUnitTest.php index 718ebf9f..0220b1d8 100644 --- a/Magento2/Tests/Legacy/ModuleXMLUnitTest.php +++ b/Magento2/Tests/Legacy/ModuleXMLUnitTest.php @@ -23,7 +23,7 @@ public function getErrorList() public function getWarningList() { return [ - 1 => 2 + 9 => 2 ]; } } diff --git a/Magento2/ruleset.xml b/Magento2/ruleset.xml index dcf3c608..bc9f4385 100644 --- a/Magento2/ruleset.xml +++ b/Magento2/ruleset.xml @@ -3,7 +3,7 @@ Magento Coding Standard - + @@ -224,9 +224,8 @@ warning - *\.php$ - module.xml - ModuleXMLUnitTest.xml + *\/module.xml$ + *\/ModuleXMLUnitTest.xml$ 8 warning @@ -265,6 +264,7 @@ warning + *\.xml$ 7 warning diff --git a/composer.json b/composer.json index 42cbd3be..f5037b17 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,8 @@ "php": ">=7.3", "squizlabs/php_codesniffer": "^3.6", "webonyx/graphql-php": "^14.9", - "ext-simplexml": "*" + "ext-simplexml": "*", + "ext-dom": "*" }, "require-dev": { "phpunit/phpunit": "^9.5.8" From 135630e5804b0fd760f48c1651def302ee292276 Mon Sep 17 00:00:00 2001 From: Sergio Vera Date: Tue, 24 Aug 2021 14:48:33 +0200 Subject: [PATCH 05/15] AC-659: Create phpcs static check for ModuleXMLTest --- composer.lock | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.lock b/composer.lock index fc31a666..04231d90 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "148dc78a64f9790450688c1d3310f3e7", + "content-hash": "8c3c7509df274fdeaf09edfd7eac6cf5", "packages": [ { "name": "squizlabs/php_codesniffer", @@ -2229,7 +2229,8 @@ "prefer-lowest": false, "platform": { "php": ">=7.3", - "ext-simplexml": "*" + "ext-simplexml": "*", + "ext-dom": "*" }, "platform-dev": [], "plugin-api-version": "2.1.0" From 85de47c2a62f3b538dd4ee8bd80e179f395136a0 Mon Sep 17 00:00:00 2001 From: Sergio Vera Date: Tue, 24 Aug 2021 14:50:59 +0200 Subject: [PATCH 06/15] AC-659: Create phpcs static check for ModuleXMLTest --- Magento2/Sniffs/Legacy/ModuleXMLSniff.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Magento2/Sniffs/Legacy/ModuleXMLSniff.php b/Magento2/Sniffs/Legacy/ModuleXMLSniff.php index a60c9fdb..b7fe303b 100644 --- a/Magento2/Sniffs/Legacy/ModuleXMLSniff.php +++ b/Magento2/Sniffs/Legacy/ModuleXMLSniff.php @@ -64,7 +64,8 @@ public function process(File $phpcsFile, $stackPtr) if (property_exists($element->attributes(), 'active')) { $phpcsFile->addWarning( - 'The "active" attribute is obsolete. The list of active modules is defined in deployment configuration.', + 'The "active" attribute is obsolete. The list of active modules '. + 'is defined in deployment configuration.', $stackPtr, $this->warningCode ); @@ -73,6 +74,8 @@ public function process(File $phpcsFile, $stackPtr) } /** + * Check if the element passed is in the currently sniffed line + * * @param SimpleXMLElement $element * @param int $stackPtr * @return bool From 5f4d45f06d5217ae35c08b719f72d0e0cc945b12 Mon Sep 17 00:00:00 2001 From: Sergio Vera Date: Tue, 24 Aug 2021 15:00:09 +0200 Subject: [PATCH 07/15] AC-659: Create phpcs static check for ModuleXMLTest --- Magento2/Sniffs/Legacy/ModuleXMLSniff.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Magento2/Sniffs/Legacy/ModuleXMLSniff.php b/Magento2/Sniffs/Legacy/ModuleXMLSniff.php index b7fe303b..1cfa6ef9 100644 --- a/Magento2/Sniffs/Legacy/ModuleXMLSniff.php +++ b/Magento2/Sniffs/Legacy/ModuleXMLSniff.php @@ -65,7 +65,7 @@ public function process(File $phpcsFile, $stackPtr) if (property_exists($element->attributes(), 'active')) { $phpcsFile->addWarning( 'The "active" attribute is obsolete. The list of active modules '. - 'is defined in deployment configuration.', + 'is defined in deployment configuration.', $stackPtr, $this->warningCode ); @@ -75,7 +75,7 @@ public function process(File $phpcsFile, $stackPtr) /** * Check if the element passed is in the currently sniffed line - * + * * @param SimpleXMLElement $element * @param int $stackPtr * @return bool From 70636590ce96dc8be89df5e14ae877c9ff8f9968 Mon Sep 17 00:00:00 2001 From: Sergio Vera Date: Tue, 24 Aug 2021 15:27:37 +0200 Subject: [PATCH 08/15] AC-659: Create phpcs static check for ModuleXMLTest --- Magento2/Sniffs/Legacy/ModuleXMLSniff.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Magento2/Sniffs/Legacy/ModuleXMLSniff.php b/Magento2/Sniffs/Legacy/ModuleXMLSniff.php index 1cfa6ef9..a3b9cbd9 100644 --- a/Magento2/Sniffs/Legacy/ModuleXMLSniff.php +++ b/Magento2/Sniffs/Legacy/ModuleXMLSniff.php @@ -17,10 +17,8 @@ class ModuleXMLSniff implements Sniff { /** * Error violation code. - * - * @var string */ - protected $warningCode = 'FoundObsoleteAttribute'; + const WARNING_CODE = 'FoundObsoleteAttribute'; /** * @inheritdoc @@ -43,6 +41,16 @@ public function process(File $phpcsFile, $stackPtr) } $xml = simplexml_load_string($phpcsFile->getTokensAsString(0, 999999)); + if ($xml === false) { + $phpcsFile->addError( + sprintf( + "Couldn't parse contents of '%s', check that they are in valid XML format", + basename($phpcsFile->getFilename()), + ), + $stackPtr, + self::WARNING_CODE + ); + } $foundElements = $xml->xpath('/config/module'); if ($foundElements === false) { @@ -58,7 +66,7 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->addWarning( 'The "version" attribute is obsolete. Use "setup_version" instead.', $stackPtr, - $this->warningCode + self::WARNING_CODE ); } @@ -67,7 +75,7 @@ public function process(File $phpcsFile, $stackPtr) 'The "active" attribute is obsolete. The list of active modules '. 'is defined in deployment configuration.', $stackPtr, - $this->warningCode + self::WARNING_CODE ); } } From c2786fe1b7ac6c7867ae8e7837a425d378d1b060 Mon Sep 17 00:00:00 2001 From: Sergio Vera Date: Tue, 24 Aug 2021 15:32:29 +0200 Subject: [PATCH 09/15] AC-659: Create phpcs static check for ModuleXMLTest --- Magento2/Sniffs/Legacy/ModuleXMLSniff.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Magento2/Sniffs/Legacy/ModuleXMLSniff.php b/Magento2/Sniffs/Legacy/ModuleXMLSniff.php index a3b9cbd9..ca1b3084 100644 --- a/Magento2/Sniffs/Legacy/ModuleXMLSniff.php +++ b/Magento2/Sniffs/Legacy/ModuleXMLSniff.php @@ -45,7 +45,7 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->addError( sprintf( "Couldn't parse contents of '%s', check that they are in valid XML format", - basename($phpcsFile->getFilename()), + $phpcsFile->getFilename(), ), $stackPtr, self::WARNING_CODE From aca6b41a8160ed603d856ba77dbaa79c025698f5 Mon Sep 17 00:00:00 2001 From: Sergio Vera Date: Tue, 24 Aug 2021 16:53:12 +0200 Subject: [PATCH 10/15] AC-659: Create phpcs static check for ModuleXMLTest --- Magento2/Sniffs/Legacy/ModuleXMLSniff.php | 27 +++++++++++++++------ Magento2/Tests/Legacy/ModuleXMLUnitTest.php | 3 ++- Magento2/Tests/Legacy/ModuleXMLUnitTest.xml | 5 ++++ 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/Magento2/Sniffs/Legacy/ModuleXMLSniff.php b/Magento2/Sniffs/Legacy/ModuleXMLSniff.php index ca1b3084..5a741156 100644 --- a/Magento2/Sniffs/Legacy/ModuleXMLSniff.php +++ b/Magento2/Sniffs/Legacy/ModuleXMLSniff.php @@ -6,6 +6,7 @@ namespace Magento2\Sniffs\Legacy; +use DOMDocument; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; use SimpleXMLElement; @@ -15,10 +16,8 @@ */ class ModuleXMLSniff implements Sniff { - /** - * Error violation code. - */ - const WARNING_CODE = 'FoundObsoleteAttribute'; + private const WARNING_CODE = 'FoundObsoleteAttribute'; + private const ERROR_CODE = 'WrongXML'; /** * @inheritdoc @@ -36,11 +35,11 @@ public function register(): array public function process(File $phpcsFile, $stackPtr) { $line = $phpcsFile->getTokens()[$stackPtr]['content']; - if (strpos(trim($line), 'getTokensAsString(0, 999999)); + + $xml = simplexml_load_string($this->getFormattedXML($phpcsFile)); if ($xml === false) { $phpcsFile->addError( sprintf( @@ -48,7 +47,7 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->getFilename(), ), $stackPtr, - self::WARNING_CODE + self::ERROR_CODE ); } @@ -96,4 +95,16 @@ private function elementIsCurrentlySniffedLine(SimpleXMLElement $element, int $s } return false; } + + /** + * @param File $phpcsFile + * @return false|string + */ + private function getFormattedXML(File $phpcsFile) + { + $doc = new DomDocument('1.0'); + $doc->formatOutput = true; + $doc->loadXML($phpcsFile->getTokensAsString(0, 999999)); + return $doc->saveXML(); + } } diff --git a/Magento2/Tests/Legacy/ModuleXMLUnitTest.php b/Magento2/Tests/Legacy/ModuleXMLUnitTest.php index 0220b1d8..f75673d8 100644 --- a/Magento2/Tests/Legacy/ModuleXMLUnitTest.php +++ b/Magento2/Tests/Legacy/ModuleXMLUnitTest.php @@ -23,7 +23,8 @@ public function getErrorList() public function getWarningList() { return [ - 9 => 2 + 9 => 2, + 10 => 2 ]; } } diff --git a/Magento2/Tests/Legacy/ModuleXMLUnitTest.xml b/Magento2/Tests/Legacy/ModuleXMLUnitTest.xml index 28c02b6f..9d545a65 100644 --- a/Magento2/Tests/Legacy/ModuleXMLUnitTest.xml +++ b/Magento2/Tests/Legacy/ModuleXMLUnitTest.xml @@ -7,4 +7,9 @@ --> + From 754e84c471e3c5749c399788a49c3f9184bc8b5c Mon Sep 17 00:00:00 2001 From: Sergio Vera Date: Tue, 24 Aug 2021 17:01:47 +0200 Subject: [PATCH 11/15] AC-659: Create phpcs static check for ModuleXMLTest --- Magento2/Sniffs/Legacy/ModuleXMLSniff.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Magento2/Sniffs/Legacy/ModuleXMLSniff.php b/Magento2/Sniffs/Legacy/ModuleXMLSniff.php index 5a741156..efb903c1 100644 --- a/Magento2/Sniffs/Legacy/ModuleXMLSniff.php +++ b/Magento2/Sniffs/Legacy/ModuleXMLSniff.php @@ -97,6 +97,9 @@ private function elementIsCurrentlySniffedLine(SimpleXMLElement $element, int $s } /** + * We need to format the incoming XML to avoid tags split into several lines. In that case, PHP's DOMElement + * returns the position of the closing /> as the position of the tag. + * * @param File $phpcsFile * @return false|string */ From 75f43afb48f407472659ab64fe66054d6deef1a2 Mon Sep 17 00:00:00 2001 From: Sergio Vera Date: Tue, 24 Aug 2021 17:04:59 +0200 Subject: [PATCH 12/15] AC-659: Create phpcs static check for ModuleXMLTest --- Magento2/Sniffs/Legacy/ModuleXMLSniff.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Magento2/Sniffs/Legacy/ModuleXMLSniff.php b/Magento2/Sniffs/Legacy/ModuleXMLSniff.php index efb903c1..5f016d5e 100644 --- a/Magento2/Sniffs/Legacy/ModuleXMLSniff.php +++ b/Magento2/Sniffs/Legacy/ModuleXMLSniff.php @@ -39,6 +39,8 @@ public function process(File $phpcsFile, $stackPtr) return; } + // We need to format the incoming XML to avoid tags split into several lines. In that case, PHP's DOMElement + // returns the position of the closing /> as the position of the tag. $xml = simplexml_load_string($this->getFormattedXML($phpcsFile)); if ($xml === false) { $phpcsFile->addError( @@ -97,8 +99,7 @@ private function elementIsCurrentlySniffedLine(SimpleXMLElement $element, int $s } /** - * We need to format the incoming XML to avoid tags split into several lines. In that case, PHP's DOMElement - * returns the position of the closing /> as the position of the tag. + * Format the incoming XML to avoid tags split into several lines. * * @param File $phpcsFile * @return false|string From d0fe1500e648f4dbf1164582ab22b0a0300a3541 Mon Sep 17 00:00:00 2001 From: Sergio Vera Date: Tue, 24 Aug 2021 17:09:23 +0200 Subject: [PATCH 13/15] AC-659: Create phpcs static check for ModuleXMLTest --- Magento2/Sniffs/Legacy/ModuleXMLSniff.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Magento2/Sniffs/Legacy/ModuleXMLSniff.php b/Magento2/Sniffs/Legacy/ModuleXMLSniff.php index 5f016d5e..da25de0d 100644 --- a/Magento2/Sniffs/Legacy/ModuleXMLSniff.php +++ b/Magento2/Sniffs/Legacy/ModuleXMLSniff.php @@ -40,7 +40,8 @@ public function process(File $phpcsFile, $stackPtr) } // We need to format the incoming XML to avoid tags split into several lines. In that case, PHP's DOMElement - // returns the position of the closing /> as the position of the tag. + // returns the position of the closing /> as the position of the tag, and we need the position of getFormattedXML($phpcsFile)); if ($xml === false) { $phpcsFile->addError( From 53e9d751141a1649caf53a8457de03cc2adc55a7 Mon Sep 17 00:00:00 2001 From: Sergio Vera Date: Thu, 2 Sep 2021 11:54:29 +0200 Subject: [PATCH 14/15] AC-659: Create phpcs static check for ModuleXMLTest --- Magento2/Tests/Legacy/ModuleXMLUnitTest.1.xml | 10 ++++++++++ ...eXMLUnitTest.xml => ModuleXMLUnitTest.2.xml} | 1 - Magento2/Tests/Legacy/ModuleXMLUnitTest.php | 17 ++++++++++++----- 3 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 Magento2/Tests/Legacy/ModuleXMLUnitTest.1.xml rename Magento2/Tests/Legacy/{ModuleXMLUnitTest.xml => ModuleXMLUnitTest.2.xml} (85%) diff --git a/Magento2/Tests/Legacy/ModuleXMLUnitTest.1.xml b/Magento2/Tests/Legacy/ModuleXMLUnitTest.1.xml new file mode 100644 index 00000000..28c02b6f --- /dev/null +++ b/Magento2/Tests/Legacy/ModuleXMLUnitTest.1.xml @@ -0,0 +1,10 @@ + + + + + diff --git a/Magento2/Tests/Legacy/ModuleXMLUnitTest.xml b/Magento2/Tests/Legacy/ModuleXMLUnitTest.2.xml similarity index 85% rename from Magento2/Tests/Legacy/ModuleXMLUnitTest.xml rename to Magento2/Tests/Legacy/ModuleXMLUnitTest.2.xml index 9d545a65..13fbd752 100644 --- a/Magento2/Tests/Legacy/ModuleXMLUnitTest.xml +++ b/Magento2/Tests/Legacy/ModuleXMLUnitTest.2.xml @@ -6,7 +6,6 @@ */ --> - 2, - 10 => 2 - ]; + if ($testFile === 'ModuleXMLUnitTest.1.xml') { + return [ + 9 => 2, + ]; + } + if ($testFile === 'ModuleXMLUnitTest.2.xml') { + return [ + 9 => 2, + ]; + } + return []; } } From 47a0536fe81a5d0a999542ada2773df59d9baa4a Mon Sep 17 00:00:00 2001 From: Sergio Vera Date: Thu, 2 Sep 2021 12:03:27 +0200 Subject: [PATCH 15/15] AC-659: Create phpcs static check for ModuleXMLTest --- Magento2/Tests/Legacy/ModuleXMLUnitTest.3.xml | 10 ++++++++++ Magento2/Tests/Legacy/ModuleXMLUnitTest.php | 3 +++ 2 files changed, 13 insertions(+) create mode 100644 Magento2/Tests/Legacy/ModuleXMLUnitTest.3.xml diff --git a/Magento2/Tests/Legacy/ModuleXMLUnitTest.3.xml b/Magento2/Tests/Legacy/ModuleXMLUnitTest.3.xml new file mode 100644 index 00000000..93312a82 --- /dev/null +++ b/Magento2/Tests/Legacy/ModuleXMLUnitTest.3.xml @@ -0,0 +1,10 @@ + + + + + diff --git a/Magento2/Tests/Legacy/ModuleXMLUnitTest.php b/Magento2/Tests/Legacy/ModuleXMLUnitTest.php index 62300103..eab099a4 100644 --- a/Magento2/Tests/Legacy/ModuleXMLUnitTest.php +++ b/Magento2/Tests/Legacy/ModuleXMLUnitTest.php @@ -32,6 +32,9 @@ public function getWarningList($testFile = '') 9 => 2, ]; } + if ($testFile === 'ModuleXMLUnitTest.3.xml') { + return []; + } return []; } }