diff --git a/dev/phpunit/unit/Ampersand/PatchHelper/Checks/WebTemplateHtmlTest.php b/dev/phpunit/unit/Ampersand/PatchHelper/Checks/WebTemplateHtmlTest.php index 452e35b7..e36d975a 100644 --- a/dev/phpunit/unit/Ampersand/PatchHelper/Checks/WebTemplateHtmlTest.php +++ b/dev/phpunit/unit/Ampersand/PatchHelper/Checks/WebTemplateHtmlTest.php @@ -188,4 +188,51 @@ public function testWebTemplateHtmlVendorFileNonMeaningfulChange() ]; $this->assertEquals($expected, $ignored); } + + /** + * + */ + public function testWebTemplateHtmlKnockout() + { + $this->m2->expects($this->any()) + ->method('getListOfHtmlFiles') + ->willReturn( + [ + 'app/design/frontend/Ampersand/theme/Magento_Ui/web/templates/grid/knockout.html', + 'vendor/magento/module-ui/view/base/web/templates/grid/knockout.html', + ] + ); + + $reader = new Reader( + $this->testResourcesDir . 'vendor.patch' + ); + + $entries = $reader->getFiles(); + $this->assertNotEmpty($entries, 'We should have a patch file to read'); + + $entry = $entries[3]; + + $appCodeGetter = new GetAppCodePathFromVendorPath($this->m2, $entry); + $appCodeFilePath = $appCodeGetter->getAppCodePathFromVendorPath(); + $this->assertEquals( + 'app/code/Magento/Ui/view/base/web/templates/grid/knockout.html', + $appCodeFilePath + ); + + $warnings = $infos = $ignored = []; + + $check = new WebTemplateHtml($this->m2, $entry, $appCodeFilePath, $warnings, $infos, $ignored); + $this->assertTrue($check->canCheck(), 'Check should be checkable'); + $check->check(); + + $this->assertEmpty($ignored, 'We should have no ignore level items'); + $this->assertEmpty($infos, 'We should have no info level items'); + $this->assertNotEmpty($warnings, 'We should have a warning'); + $expectedWarnings = [ + 'Override (phtml/js/html)' => [ + 'app/design/frontend/Ampersand/theme/Magento_Ui/web/templates/grid/knockout.html' + ] + ]; + $this->assertEquals($expectedWarnings, $warnings); + } } diff --git a/dev/phpunit/unit/resources/checks/WebTemplateHtml/app/design/frontend/Ampersand/theme/Magento_Ui/web/templates/grid/knockout.html b/dev/phpunit/unit/resources/checks/WebTemplateHtml/app/design/frontend/Ampersand/theme/Magento_Ui/web/templates/grid/knockout.html new file mode 100644 index 00000000..62bc0511 --- /dev/null +++ b/dev/phpunit/unit/resources/checks/WebTemplateHtml/app/design/frontend/Ampersand/theme/Magento_Ui/web/templates/grid/knockout.html @@ -0,0 +1 @@ +

some override

\ No newline at end of file diff --git a/dev/phpunit/unit/resources/checks/WebTemplateHtml/vendor.patch b/dev/phpunit/unit/resources/checks/WebTemplateHtml/vendor.patch index 9ee5fdaf..e35e6dcb 100644 --- a/dev/phpunit/unit/resources/checks/WebTemplateHtml/vendor.patch +++ b/dev/phpunit/unit/resources/checks/WebTemplateHtml/vendor.patch @@ -70,3 +70,13 @@ diff -ur -N vendor_orig/magento/module-ui/view/base/web/templates/grid/some_noop - \ No newline at end of file + +diff -ur -N vendor_orig/magento/module-ui/view/base/web/templates/grid/knockout.html vendor/magento/module-ui/view/base/web/templates/grid/knockout.html +--- vendor_orig/magento/module-ui/view/base/web/templates/grid/knockout.html 2024-02-08 20:13:23.000000000 +0000 ++++ vendor/magento/module-ui/view/base/web/templates/grid/knockout.html 2024-02-08 20:13:23.000000000 +0000 +@@ -1,5 +1,5 @@ +

hello

+

goodbye

+- ++ + + diff --git a/dev/phpunit/unit/resources/checks/WebTemplateHtml/vendor/magento/module-ui/view/base/web/templates/grid/knockout.html b/dev/phpunit/unit/resources/checks/WebTemplateHtml/vendor/magento/module-ui/view/base/web/templates/grid/knockout.html new file mode 100644 index 00000000..6761478d --- /dev/null +++ b/dev/phpunit/unit/resources/checks/WebTemplateHtml/vendor/magento/module-ui/view/base/web/templates/grid/knockout.html @@ -0,0 +1,5 @@ +

hello

+

goodbye

+ + + diff --git a/dev/phpunit/unit/resources/checks/WebTemplateHtml/vendor_orig/magento/module-ui/view/base/web/templates/grid/knockout.html b/dev/phpunit/unit/resources/checks/WebTemplateHtml/vendor_orig/magento/module-ui/view/base/web/templates/grid/knockout.html new file mode 100644 index 00000000..1884e00f --- /dev/null +++ b/dev/phpunit/unit/resources/checks/WebTemplateHtml/vendor_orig/magento/module-ui/view/base/web/templates/grid/knockout.html @@ -0,0 +1,5 @@ +

hello

+

goodbye

+ + + diff --git a/src/Ampersand/PatchHelper/Patchfile/Sanitiser.php b/src/Ampersand/PatchHelper/Patchfile/Sanitiser.php index cc607a77..a6ae9ee5 100644 --- a/src/Ampersand/PatchHelper/Patchfile/Sanitiser.php +++ b/src/Ampersand/PatchHelper/Patchfile/Sanitiser.php @@ -178,6 +178,6 @@ public static function stripCommentsFromHtml($contents) { // This regular expression will match and remove both single-line comments and multi-line comments // spanning multiple lines. The s flag is used to make the dot (.) match any character, including newlines. - return preg_replace('//s', '', $contents); + return preg_replace('//s', '', $contents); } }