From 9565c44b1ca474825731b4ed265724238540f6ad Mon Sep 17 00:00:00 2001 From: Franciszek Wawrzak Date: Fri, 27 Mar 2020 23:55:28 +0100 Subject: [PATCH 001/104] improve exception handling in Layout render --- lib/internal/Magento/Framework/View/Layout.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/View/Layout.php b/lib/internal/Magento/Framework/View/Layout.php index a622006f32a1e..02dbd5e005535 100644 --- a/lib/internal/Magento/Framework/View/Layout.php +++ b/lib/internal/Magento/Framework/View/Layout.php @@ -545,8 +545,7 @@ public function renderNonCachedElement($name) if ($this->appState->getMode() === AppState::MODE_DEVELOPER) { throw $e; } - $message = ($e instanceof LocalizedException) ? $e->getLogMessage() : $e->getMessage(); - $this->logger->critical($message); + $this->logger->critical($e); } return $result; } From e786d514ef72699bdedada6444665d882dd015c3 Mon Sep 17 00:00:00 2001 From: Will Wright Date: Tue, 28 Jul 2020 22:41:30 -0700 Subject: [PATCH 002/104] magento/magento2#29315: \Magento\Config\Model\Config\Source\Email\Template::toOptionArray throws error when setPath() is not called first - Guard against an edge case where toOptionArray is called without having set a path first --- .../Model/Config/Source/Email/Template.php | 10 ++-- .../Config/Source/Email/TemplateTest.php | 46 ++++++++++++++++++- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Config/Model/Config/Source/Email/Template.php b/app/code/Magento/Config/Model/Config/Source/Email/Template.php index ac168f16ca182..182faa53e5288 100644 --- a/app/code/Magento/Config/Model/Config/Source/Email/Template.php +++ b/app/code/Magento/Config/Model/Config/Source/Email/Template.php @@ -60,10 +60,12 @@ public function toOptionArray() $this->_coreRegistry->register('config_system_email_template', $collection); } $options = $collection->toOptionArray(); - $templateId = str_replace('/', '_', $this->getPath()); - $templateLabel = $this->_emailConfig->getTemplateLabel($templateId); - $templateLabel = __('%1 (Default)', $templateLabel); - array_unshift($options, ['value' => $templateId, 'label' => $templateLabel]); + if (!empty($this->getPath())) { + $templateId = str_replace('/', '_', $this->getPath()); + $templateLabel = $this->_emailConfig->getTemplateLabel($templateId); + $templateLabel = __('%1 (Default)', $templateLabel); + array_unshift($options, ['value' => $templateId, 'label' => $templateLabel]); + } return $options; } } diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php index 356d1133aca81..74ab4baa4e990 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php @@ -102,4 +102,48 @@ public function testToOptionArray() $this->_model->setPath('template/new'); $this->assertEquals($expectedResult, $this->_model->toOptionArray()); } -} + + public function testToOptionArrayWithoutPath() + { + $collection = $this->createMock(Collection::class); + $collection->expects( + $this->once() + )->method( + 'toOptionArray' + )->willReturn( + [ + ['value' => 'template_one', 'label' => 'Template One'], + ['value' => 'template_two', 'label' => 'Template Two'], + ] + ); + + $this->_coreRegistry->expects( + $this->once() + )->method( + 'registry' + )->with( + 'config_system_email_template' + )->willReturn( + $collection + ); + + $this->_emailConfig->expects( + $this->never() + )->method( + 'getTemplateLabel' + )->with('') + ->willThrowException(new \UnexpectedValueException("Email template '' is not defined.")); + + $expectedResult = [ + [ + 'value' => 'template_one', + 'label' => 'Template One', + ], + [ + 'value' => 'template_two', + 'label' => 'Template Two', + ], + ]; + + $this->assertEquals($expectedResult, $this->_model->toOptionArray()); + }} From e0972bf2ac019a1b4645f2aaa7ac2e6016859fe5 Mon Sep 17 00:00:00 2001 From: Will Wright Date: Wed, 29 Jul 2020 22:15:00 -0700 Subject: [PATCH 003/104] magento/magento2#29315: \Magento\Config\Model\Config\Source\Email\Template::toOptionArray throws error when setPath() is not called first - Fix formatting for static tests --- .../Unit/Model/Config/Source/Email/TemplateTest.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php index 74ab4baa4e990..9b531280f66c6 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php @@ -131,8 +131,12 @@ public function testToOptionArrayWithoutPath() $this->never() )->method( 'getTemplateLabel' - )->with('') - ->willThrowException(new \UnexpectedValueException("Email template '' is not defined.")); + )->with( + '' + ) + ->willThrowException( + new \UnexpectedValueException("Email template '' is not defined.") + ); $expectedResult = [ [ @@ -146,4 +150,5 @@ public function testToOptionArrayWithoutPath() ]; $this->assertEquals($expectedResult, $this->_model->toOptionArray()); - }} + } +} From 8f43c639da9fc2f8fbb4394fc38889f718b584b6 Mon Sep 17 00:00:00 2001 From: oleksandrkravchuk Date: Thu, 30 Jul 2020 23:01:54 +0300 Subject: [PATCH 004/104] community-features#252 Create static test for action controllers. Add Legacy test to check if newly created controllers do not extend AbstractAction. --- .../Magento/App/Action/AbstractActionTest.php | 160 ++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 dev/tests/static/testsuite/Magento/Test/Legacy/Magento/App/Action/AbstractActionTest.php diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/App/Action/AbstractActionTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/App/Action/AbstractActionTest.php new file mode 100644 index 0000000000000..472b557ab389f --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/App/Action/AbstractActionTest.php @@ -0,0 +1,160 @@ +classNameExtractor = new ClassNameExtractor(); + $this->fileUtilities = Files::init(); + } + + /** + * Test new + * + */ + public function testNewControllersDoNotExtendAbstractAction(): void + { + $files = $this->getTestFiles(); + $found = []; + + foreach ($files as $file) { + $class = $this->classNameExtractor->getNameWithNamespace(file_get_contents($file[0])); + + if ($class) { + try { + $classReflection = new ReflectionClass($class); + if ($classReflection->isSubclassOf(AbstractAction::class)) { + $found[] = $class; + } + } catch (Exception $exception) { + $this->addWarning('Skipped due to exception: ' . $class); + } + } + } + + $this->assertEmpty( + $found, + "The following new controller(s) extend " . AbstractAction::class . "\r\n" + . "All new controller classes must implement " . ActionInterface::class . " instead.\r\n" + . print_r($found, true) + ); + } + + /** + * Provide files for test. + * + * @return array + */ + private function getTestFiles(): array + { + $phpFiles = self::getAddedFilesList(self::getChangedFilesBaseDir()); + + $phpFiles = Files::composeDataSets($phpFiles); + $fileTypes = Files::INCLUDE_APP_CODE | Files::INCLUDE_LIBS | Files::AS_DATA_SET; + return array_intersect_key($phpFiles, $this->fileUtilities->getPhpFiles($fileTypes)); + } + + /** + * Provide list of new files. + * + * @param $changedFilesBaseDir + * + * @return string[] + */ + private static function getAddedFilesList($changedFilesBaseDir) + { + return self::getFilesFromListFile( + $changedFilesBaseDir, + 'changed_files*.added.*', + function () { + // if no list files, probably, this is the dev environment + // phpcs:ignore Generic.PHP.NoSilencedErrors,Magento2.Security.InsecureFunction + @exec('git diff --cached --name-only --diff-filter=A', $addedFiles); + return $addedFiles; + } + ); + } + + /** + * Read files from generated lists. + * + * @param string $listsBaseDir + * @param string $listFilePattern + * @param callable $noListCallback + * @return string[] + */ + private static function getFilesFromListFile( + string $listsBaseDir, + string $listFilePattern, + callable $noListCallback + ): array { + $filesDefinedInList = []; + + $listFiles = glob($listsBaseDir . '/_files/' . $listFilePattern); + if (!empty($listFiles)) { + foreach ($listFiles as $listFile) { + // phpcs:ignore Magento2.Performance.ForeachArrayMerge.ForeachArrayMerge + $filesDefinedInList = array_merge( + $filesDefinedInList, + file($listFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) + ); + } + } else { + $filesDefinedInList = call_user_func($noListCallback); + } + + array_walk( + $filesDefinedInList, + function (&$file) { + $file = BP . '/' . $file; + } + ); + + $filesDefinedInList = array_values(array_unique($filesDefinedInList)); + + return $filesDefinedInList; + } + + /** + * Returns base directory for generated lists. + * + * @return string + */ + private static function getChangedFilesBaseDir(): string + { + return BP . DIRECTORY_SEPARATOR . 'dev' . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'static' . + DIRECTORY_SEPARATOR . 'testsuite' . DIRECTORY_SEPARATOR . 'Magento' . DIRECTORY_SEPARATOR . 'Test'; + } +} From 602dc6894a0ba909d3b631a28155ab58459aa12d Mon Sep 17 00:00:00 2001 From: Oleksandr Kravchuk Date: Fri, 31 Jul 2020 09:26:31 +0300 Subject: [PATCH 005/104] Update dev/tests/static/testsuite/Magento/Test/Legacy/Magento/App/Action/AbstractActionTest.php Refactoring. Co-authored-by: Ihor Sviziev --- .../Test/Legacy/Magento/App/Action/AbstractActionTest.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/App/Action/AbstractActionTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/App/Action/AbstractActionTest.php index 472b557ab389f..ced06dcc4ada6 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/App/Action/AbstractActionTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/App/Action/AbstractActionTest.php @@ -125,12 +125,10 @@ private static function getFilesFromListFile( $listFiles = glob($listsBaseDir . '/_files/' . $listFilePattern); if (!empty($listFiles)) { foreach ($listFiles as $listFile) { - // phpcs:ignore Magento2.Performance.ForeachArrayMerge.ForeachArrayMerge - $filesDefinedInList = array_merge( - $filesDefinedInList, - file($listFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) - ); + $filesDefinedInList[] = file($listFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); } + + $filesDefinedInList = array_merge([], ...$filesDefinedInList); } else { $filesDefinedInList = call_user_func($noListCallback); } From 9342d4c0e01664a8e155160118ab70f49aeb9225 Mon Sep 17 00:00:00 2001 From: oleksandrkravchuk Date: Fri, 31 Jul 2020 10:03:52 +0200 Subject: [PATCH 006/104] community-features#252 Create static test for action controllers. Fix static tests. --- .../Magento/App/Action/AbstractActionTest.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/App/Action/AbstractActionTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/App/Action/AbstractActionTest.php index ced06dcc4ada6..d109b263b6b84 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/App/Action/AbstractActionTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/App/Action/AbstractActionTest.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\Test\Legacy\App\Action; +namespace Magento\Test\Legacy\Magento\App\Action; use Exception; use Magento\Framework\App\Action\AbstractAction; @@ -41,9 +41,8 @@ protected function setUp(): void } /** - * Test new - * - */ + * Test newly created controllers do not extend deprecated AbstractAction. + */ public function testNewControllersDoNotExtendAbstractAction(): void { $files = $this->getTestFiles(); @@ -121,25 +120,21 @@ private static function getFilesFromListFile( callable $noListCallback ): array { $filesDefinedInList = []; - $listFiles = glob($listsBaseDir . '/_files/' . $listFilePattern); if (!empty($listFiles)) { foreach ($listFiles as $listFile) { $filesDefinedInList[] = file($listFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); } - - $filesDefinedInList = array_merge([], ...$filesDefinedInList); + $filesDefinedInList = array_merge([], ...$filesDefinedInList); } else { $filesDefinedInList = call_user_func($noListCallback); } - array_walk( $filesDefinedInList, function (&$file) { $file = BP . '/' . $file; } ); - $filesDefinedInList = array_values(array_unique($filesDefinedInList)); return $filesDefinedInList; From 8195b0c1ff66189ad50f7b25c5724f2bff36d365 Mon Sep 17 00:00:00 2001 From: oleksandrkravchuk Date: Fri, 31 Jul 2020 12:04:40 +0200 Subject: [PATCH 007/104] community-features#252 Create static test for action controllers. Fix static tests. --- .../Magento/{ => Framework}/App/Action/AbstractActionTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename dev/tests/static/testsuite/Magento/Test/Legacy/Magento/{ => Framework}/App/Action/AbstractActionTest.php (98%) diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/App/Action/AbstractActionTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/Framework/App/Action/AbstractActionTest.php similarity index 98% rename from dev/tests/static/testsuite/Magento/Test/Legacy/Magento/App/Action/AbstractActionTest.php rename to dev/tests/static/testsuite/Magento/Test/Legacy/Magento/Framework/App/Action/AbstractActionTest.php index d109b263b6b84..d5427752004d9 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/App/Action/AbstractActionTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/Framework/App/Action/AbstractActionTest.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\Test\Legacy\Magento\App\Action; +namespace Magento\Test\Legacy\Magento\Framework\App\Action; use Exception; use Magento\Framework\App\Action\AbstractAction; From 308a5f46cf4378efff331d5ac3035310c009c4fd Mon Sep 17 00:00:00 2001 From: oleksandrkravchuk Date: Mon, 3 Aug 2020 21:44:10 +0200 Subject: [PATCH 008/104] community-features#252 Create static test for action controllers. Incapsulate logic in new class. Add test coverage. --- .../integration/etc/config-global.php.dist | 11 ---- .../Utility/ChildrenClassesSearch.php | 53 +++++++++++++++++++ .../Utility/ChildrenClassesSearchTest.php | 39 ++++++++++++++ .../Utility/PartialNamespace/Baz.php | 23 ++++++++ .../Utility/PartialNamespace/Foo.php | 34 ++++++++++++ .../App/Action/AbstractActionTest.php | 28 +++------- 6 files changed, 156 insertions(+), 32 deletions(-) delete mode 100644 dev/tests/integration/etc/config-global.php.dist create mode 100644 dev/tests/static/framework/Magento/TestFramework/Utility/ChildrenClassesSearch.php create mode 100644 dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearchTest.php create mode 100644 dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/PartialNamespace/Baz.php create mode 100644 dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/PartialNamespace/Foo.php diff --git a/dev/tests/integration/etc/config-global.php.dist b/dev/tests/integration/etc/config-global.php.dist deleted file mode 100644 index fbc6714859529..0000000000000 --- a/dev/tests/integration/etc/config-global.php.dist +++ /dev/null @@ -1,11 +0,0 @@ - 0, - 'admin/security/admin_account_sharing' => 1, - 'admin/security/limit_password_reset_requests_method' => 0, -]; diff --git a/dev/tests/static/framework/Magento/TestFramework/Utility/ChildrenClassesSearch.php b/dev/tests/static/framework/Magento/TestFramework/Utility/ChildrenClassesSearch.php new file mode 100644 index 0000000000000..6905e1b4f442c --- /dev/null +++ b/dev/tests/static/framework/Magento/TestFramework/Utility/ChildrenClassesSearch.php @@ -0,0 +1,53 @@ +classNameExtractor = new ClassNameExtractor(); + } + + /** + * Get list of classes name which are subclasses of mentioned class. + * + * @param array $fileList + * @param string $parent + * @param bool $asDataSet + * + * @return array + * @throws \ReflectionException + */ + public function getClassesWhichAreChildrenOf(array $fileList, string $parent, bool $asDataSet = true): array + { + $found = []; + + foreach ($fileList as $file) { + $name = $asDataSet ? $file[0] : $file; + $class = $this->classNameExtractor->getNameWithNamespace(file_get_contents($name)); + + if ($class) { + $classReflection = new \ReflectionClass($class); + if ($classReflection->isSubclassOf($parent)) { + $found[] = $class; + } + } + } + + return $found; + } +} diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearchTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearchTest.php new file mode 100644 index 0000000000000..9947414f7d364 --- /dev/null +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearchTest.php @@ -0,0 +1,39 @@ +childrenClassesSearch = new ChildrenClassesSearch(); + } + + public function testChildrenSearch(): void + { + $files = [ + __DIR__ . '/PartialNamespace/Foo.php', + __DIR__ . '/PartialNamespace/Bar.php', + __DIR__ . '/PartialNamespace/Baz.php', + ]; + + $found = $this->childrenClassesSearch->getClassesWhichAreChildrenOf( + $files, + AbstractAction::class, + false + ); + + $this->assertCount(1, $found); + $this->assertEquals(current($found), \Magento\TestFramework\Utility\PartialNamespace\Foo::class); + } +} diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/PartialNamespace/Baz.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/PartialNamespace/Baz.php new file mode 100644 index 0000000000000..1b54259b348ea --- /dev/null +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/PartialNamespace/Baz.php @@ -0,0 +1,23 @@ +classNameExtractor = new ClassNameExtractor(); + $this->childrenClassesSearch = new ChildrenClassesSearch(); $this->fileUtilities = Files::init(); } /** * Test newly created controllers do not extend deprecated AbstractAction. + * + * @throws \ReflectionException */ public function testNewControllersDoNotExtendAbstractAction(): void { $files = $this->getTestFiles(); - $found = []; - - foreach ($files as $file) { - $class = $this->classNameExtractor->getNameWithNamespace(file_get_contents($file[0])); - if ($class) { - try { - $classReflection = new ReflectionClass($class); - if ($classReflection->isSubclassOf(AbstractAction::class)) { - $found[] = $class; - } - } catch (Exception $exception) { - $this->addWarning('Skipped due to exception: ' . $class); - } - } - } + $found = $this->childrenClassesSearch->getClassesWhichAreChildrenOf($files, AbstractAction::class); $this->assertEmpty( $found, From 125a5d4f02ac12e9323e9f9ce0af01b9da21a62c Mon Sep 17 00:00:00 2001 From: oleksandrkravchuk Date: Tue, 4 Aug 2020 09:20:39 +0200 Subject: [PATCH 009/104] community-features#252 Create static test for action controllers. Recover accidentally removed file. --- dev/tests/integration/etc/config-global.php.dist | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 dev/tests/integration/etc/config-global.php.dist diff --git a/dev/tests/integration/etc/config-global.php.dist b/dev/tests/integration/etc/config-global.php.dist new file mode 100644 index 0000000000000..fbc6714859529 --- /dev/null +++ b/dev/tests/integration/etc/config-global.php.dist @@ -0,0 +1,11 @@ + 0, + 'admin/security/admin_account_sharing' => 1, + 'admin/security/limit_password_reset_requests_method' => 0, +]; From 87a70e92e3d60f087bf0fe6dd380f27ef300d351 Mon Sep 17 00:00:00 2001 From: oleksandrkravchuk Date: Tue, 4 Aug 2020 18:17:04 +0200 Subject: [PATCH 010/104] community-features#252 Create static test for action controllers. Apply code review changes. --- .../TestFramework/Utility/AddedFiles.php | 35 ++++++++++ .../TestFramework/Utility/FilesSearch.php | 48 +++++++++++++ .../Utility/ChildrenClassesSearch/A.php | 10 +++ .../Utility/ChildrenClassesSearch/B.php | 10 +++ .../Utility/ChildrenClassesSearch/C.php | 10 +++ .../Utility/ChildrenClassesSearch/D.php | 10 +++ .../Utility/ChildrenClassesSearch/E.php | 10 +++ .../Utility/ChildrenClassesSearch/F.php | 10 +++ .../Utility/ChildrenClassesSearch/Z.php | 10 +++ .../Utility/ChildrenClassesSearchTest.php | 31 ++++++--- .../TestFramework/Utility/FilesSearchTest.php | 54 +++++++++++++++ .../Utility/PartialNamespace/Baz.php | 23 ------- .../Utility/PartialNamespace/Foo.php | 34 ---------- .../_files/changed_files_some_name_test.txt | 3 + .../App/Action/AbstractActionTest.php | 60 +---------------- .../Magento/Test/Php/LiveCodeTest.php | 67 ++----------------- 16 files changed, 241 insertions(+), 184 deletions(-) create mode 100644 dev/tests/static/framework/Magento/TestFramework/Utility/AddedFiles.php create mode 100644 dev/tests/static/framework/Magento/TestFramework/Utility/FilesSearch.php create mode 100644 dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/A.php create mode 100644 dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/B.php create mode 100644 dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/C.php create mode 100644 dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/D.php create mode 100644 dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/E.php create mode 100644 dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/F.php create mode 100644 dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/Z.php create mode 100644 dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/FilesSearchTest.php delete mode 100644 dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/PartialNamespace/Baz.php delete mode 100644 dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/PartialNamespace/Foo.php create mode 100644 dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/_files/changed_files_some_name_test.txt diff --git a/dev/tests/static/framework/Magento/TestFramework/Utility/AddedFiles.php b/dev/tests/static/framework/Magento/TestFramework/Utility/AddedFiles.php new file mode 100644 index 0000000000000..6b1184418e16e --- /dev/null +++ b/dev/tests/static/framework/Magento/TestFramework/Utility/AddedFiles.php @@ -0,0 +1,35 @@ +childrenClassesSearch->getClassesWhichAreChildrenOf( $files, - AbstractAction::class, + A::class, false ); - $this->assertCount(1, $found); - $this->assertEquals(current($found), \Magento\TestFramework\Utility\PartialNamespace\Foo::class); + $expected = [ + B::class, + E::class, + F::class + ]; + + $this->assertSame($expected, $found); } } diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/FilesSearchTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/FilesSearchTest.php new file mode 100644 index 0000000000000..8c1206c56ce8e --- /dev/null +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/FilesSearchTest.php @@ -0,0 +1,54 @@ +assertSame($files, $expected); + } + + /** + * Test callblack function in case when files with lists did not found. + */ + public function testGetEmptyList(): void + { + $pattern = 'zzz.txt'; + + + $files = FilesSearch::getFilesFromListFile(__DIR__, $pattern, function () { + return ['1', '2', '3']; + }); + + $expected = [ + BP . '/1', + BP . '/2', + BP . '/3' + ]; + + $this->assertSame($files, $expected); + } +} diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/PartialNamespace/Baz.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/PartialNamespace/Baz.php deleted file mode 100644 index 1b54259b348ea..0000000000000 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/PartialNamespace/Baz.php +++ /dev/null @@ -1,23 +0,0 @@ -getChangedFilesBaseDir()); $phpFiles = Files::composeDataSets($phpFiles); $fileTypes = Files::INCLUDE_APP_CODE | Files::INCLUDE_LIBS | Files::AS_DATA_SET; return array_intersect_key($phpFiles, $this->fileUtilities->getPhpFiles($fileTypes)); } - /** - * Provide list of new files. - * - * @param $changedFilesBaseDir - * - * @return string[] - */ - private static function getAddedFilesList($changedFilesBaseDir) - { - return self::getFilesFromListFile( - $changedFilesBaseDir, - 'changed_files*.added.*', - function () { - // if no list files, probably, this is the dev environment - // phpcs:ignore Generic.PHP.NoSilencedErrors,Magento2.Security.InsecureFunction - @exec('git diff --cached --name-only --diff-filter=A', $addedFiles); - return $addedFiles; - } - ); - } - - /** - * Read files from generated lists. - * - * @param string $listsBaseDir - * @param string $listFilePattern - * @param callable $noListCallback - * @return string[] - */ - private static function getFilesFromListFile( - string $listsBaseDir, - string $listFilePattern, - callable $noListCallback - ): array { - $filesDefinedInList = []; - $listFiles = glob($listsBaseDir . '/_files/' . $listFilePattern); - if (!empty($listFiles)) { - foreach ($listFiles as $listFile) { - $filesDefinedInList[] = file($listFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); - } - $filesDefinedInList = array_merge([], ...$filesDefinedInList); - } else { - $filesDefinedInList = call_user_func($noListCallback); - } - array_walk( - $filesDefinedInList, - function (&$file) { - $file = BP . '/' . $file; - } - ); - $filesDefinedInList = array_values(array_unique($filesDefinedInList)); - - return $filesDefinedInList; - } - /** * Returns base directory for generated lists. * * @return string */ - private static function getChangedFilesBaseDir(): string + private function getChangedFilesBaseDir(): string { return BP . DIRECTORY_SEPARATOR . 'dev' . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'static' . DIRECTORY_SEPARATOR . 'testsuite' . DIRECTORY_SEPARATOR . 'Magento' . DIRECTORY_SEPARATOR . 'Test'; diff --git a/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php b/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php index 324753b4bd4ec..ad91025448579 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php @@ -14,6 +14,8 @@ use Magento\TestFramework\CodingStandard\Tool\CopyPasteDetector; use Magento\TestFramework\CodingStandard\Tool\PhpCompatibility; use Magento\TestFramework\CodingStandard\Tool\PhpStan; +use Magento\TestFramework\Utility\AddedFiles; +use Magento\TestFramework\Utility\FilesSearch; use PHPMD\TextUI\Command; /** @@ -113,8 +115,8 @@ public static function getWhitelist( */ private static function getChangedFilesList($changedFilesBaseDir) { - return self::getFilesFromListFile( - $changedFilesBaseDir, + return FilesSearch::getFilesFromListFile( + $changedFilesBaseDir ?: self::getChangedFilesBaseDir(), 'changed_files*', function () { // if no list files, probably, this is the dev environment @@ -128,65 +130,6 @@ function () { ); } - /** - * This method loads list of added files. - * - * @param string $changedFilesBaseDir - * @return string[] - */ - private static function getAddedFilesList($changedFilesBaseDir) - { - return self::getFilesFromListFile( - $changedFilesBaseDir, - 'changed_files*.added.*', - function () { - // if no list files, probably, this is the dev environment - // phpcs:ignore Generic.PHP.NoSilencedErrors,Magento2.Security.InsecureFunction - @exec('git diff --cached --name-only --diff-filter=A', $addedFiles); - return $addedFiles; - } - ); - } - - /** - * Read files from generated lists. - * - * @param string $listsBaseDir - * @param string $listFilePattern - * @param callable $noListCallback - * @return string[] - */ - private static function getFilesFromListFile($listsBaseDir, $listFilePattern, $noListCallback) - { - $filesDefinedInList = []; - - $globFilesListPattern = ($listsBaseDir ?: self::getChangedFilesBaseDir()) - . '/_files/' . $listFilePattern; - $listFiles = glob($globFilesListPattern); - if (!empty($listFiles)) { - foreach ($listFiles as $listFile) { - // phpcs:ignore Magento2.Performance.ForeachArrayMerge.ForeachArrayMerge - $filesDefinedInList = array_merge( - $filesDefinedInList, - file($listFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) - ); - } - } else { - $filesDefinedInList = call_user_func($noListCallback); - } - - array_walk( - $filesDefinedInList, - function (&$file) { - $file = BP . '/' . $file; - } - ); - - $filesDefinedInList = array_values(array_unique($filesDefinedInList)); - - return $filesDefinedInList; - } - /** * Filter list of files. * @@ -427,7 +370,7 @@ public function testCopyPaste() */ public function testStrictTypes() { - $changedFiles = self::getAddedFilesList(''); + $changedFiles = AddedFiles::getAddedFilesList(self::getChangedFilesBaseDir()); try { $blackList = Files::init()->readLists( From 0b92de976b8c57c241672608886f87e681bcd0bd Mon Sep 17 00:00:00 2001 From: oleksandrkravchuk Date: Tue, 4 Aug 2020 22:06:46 +0200 Subject: [PATCH 011/104] community-features#252 Create static test for action controllers. Fix static tests. --- .../framework/Magento/TestFramework/Utility/AddedFiles.php | 2 +- .../Magento/TestFramework/Utility/ChildrenClassesSearch.php | 3 +++ .../Magento/TestFramework/Utility/ChildrenClassesSearch/Z.php | 2 ++ .../Magento/TestFramework/Utility/FilesSearchTest.php | 1 - 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dev/tests/static/framework/Magento/TestFramework/Utility/AddedFiles.php b/dev/tests/static/framework/Magento/TestFramework/Utility/AddedFiles.php index 6b1184418e16e..4afeda3a035eb 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Utility/AddedFiles.php +++ b/dev/tests/static/framework/Magento/TestFramework/Utility/AddedFiles.php @@ -15,7 +15,7 @@ class AddedFiles /** * Provide list of new files. * - * @param $changedFilesBaseDir + * @param string $changedFilesBaseDir * * @return string[] */ diff --git a/dev/tests/static/framework/Magento/TestFramework/Utility/ChildrenClassesSearch.php b/dev/tests/static/framework/Magento/TestFramework/Utility/ChildrenClassesSearch.php index 6905e1b4f442c..53db8ca8d0b08 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Utility/ChildrenClassesSearch.php +++ b/dev/tests/static/framework/Magento/TestFramework/Utility/ChildrenClassesSearch.php @@ -17,6 +17,9 @@ class ChildrenClassesSearch */ private $classNameExtractor; + /** + * ChildrenClassesSearch constructor. + */ public function __construct() { $this->classNameExtractor = new ClassNameExtractor(); diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/Z.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/Z.php index 2ac48bda187b6..1ec713366dde8 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/Z.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/Z.php @@ -5,6 +5,8 @@ */ namespace Magento\TestFramework\Utility\ChildrenClassesSearch; +// @codingStandardsIgnoreStar interface Z { } +// @codingStandardsIgnoreEnd diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/FilesSearchTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/FilesSearchTest.php index 8c1206c56ce8e..7b27dde3b0bf4 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/FilesSearchTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/FilesSearchTest.php @@ -38,7 +38,6 @@ public function testGetEmptyList(): void { $pattern = 'zzz.txt'; - $files = FilesSearch::getFilesFromListFile(__DIR__, $pattern, function () { return ['1', '2', '3']; }); From b2b45e679b94cdf526f8a74834246e73c5de185e Mon Sep 17 00:00:00 2001 From: yolouiese Date: Wed, 5 Aug 2020 19:16:31 +0800 Subject: [PATCH 012/104] magento/magento2#1703: The deleted tags are not removed from Tags drop-down until the web page is refreshed - replaced outdated keywords after saving new details --- .../view/adminhtml/web/js/image/image-actions.js | 4 +++- .../view/adminhtml/web/js/image/image-edit.js | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/image/image-actions.js b/app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/image/image-actions.js index c7ca95bed863c..9eea75e8cab91 100644 --- a/app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/image/image-actions.js +++ b/app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/image/image-actions.js @@ -86,7 +86,8 @@ define([ form = modalElement.find('#image-edit-details-form'), imageId = this.imageModel().getSelected().id, keywords = this.mediaGalleryEditDetails().selectedKeywords(), - imageDetails = this.mediaGalleryImageDetails(); + imageDetails = this.mediaGalleryImageDetails(), + imageEditDetails = this.mediaGalleryEditDetails(); if (form.validation('isValid')) { saveDetails( @@ -98,6 +99,7 @@ define([ this.closeModal(); this.imageModel().reloadGrid(); imageDetails.removeCached(imageId); + imageEditDetails.removeCached(imageId, keywords); if (imageDetails.isActive()) { imageDetails.showImageDetailsById(imageId); diff --git a/app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/image/image-edit.js b/app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/image/image-edit.js index c31bc848bdc70..e142fb12aa96a 100644 --- a/app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/image/image-edit.js +++ b/app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/image/image-edit.js @@ -223,6 +223,16 @@ define([ } return true; + }, + + /** + * Remove cached image details in edit form + * + * @param {String} id + * @param {String} tags + */ + removeCached: function (id, tags) { + this.images[id].tags = tags; } }); }); From a493bc5769b59b4f2635a09382b379e44dec950a Mon Sep 17 00:00:00 2001 From: oleksandrkravchuk Date: Wed, 5 Aug 2020 14:41:32 +0300 Subject: [PATCH 013/104] community-features#252 Create static test for action controllers.. Fix static tests. --- .../Magento/TestFramework/Utility/ChildrenClassesSearch/C.php | 2 +- .../Magento/TestFramework/Utility/ChildrenClassesSearch/F.php | 2 +- .../Utility/ChildrenClassesSearch/{Z.php => ZInterface.php} | 4 +--- .../TestFramework/Utility/ChildrenClassesSearchTest.php | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) rename dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/{Z.php => ZInterface.php} (70%) diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/C.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/C.php index 1fe77df4a7f15..e50735fcbb46c 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/C.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/C.php @@ -5,6 +5,6 @@ */ namespace Magento\TestFramework\Utility\ChildrenClassesSearch; -class C implements Z +class C implements ZInterface { } diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/F.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/F.php index 5c7b8d8fb17af..6976ed26a0d84 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/F.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/F.php @@ -5,6 +5,6 @@ */ namespace Magento\TestFramework\Utility\ChildrenClassesSearch; -class F extends E implements Z +class F extends E implements ZInterface { } diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/Z.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/ZInterface.php similarity index 70% rename from dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/Z.php rename to dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/ZInterface.php index 1ec713366dde8..be1b6d222519c 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/Z.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearch/ZInterface.php @@ -5,8 +5,6 @@ */ namespace Magento\TestFramework\Utility\ChildrenClassesSearch; -// @codingStandardsIgnoreStar -interface Z +interface ZInterface { } -// @codingStandardsIgnoreEnd diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearchTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearchTest.php index efb073d93ed07..5b7fd47042347 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearchTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Utility/ChildrenClassesSearchTest.php @@ -34,7 +34,7 @@ public function testChildrenSearch(): void __DIR__ . '/ChildrenClassesSearch/D.php', __DIR__ . '/ChildrenClassesSearch/E.php', __DIR__ . '/ChildrenClassesSearch/F.php', - __DIR__ . '/ChildrenClassesSearch/Z.php', + __DIR__ . '/ChildrenClassesSearch/ZInterface.php', ]; $found = $this->childrenClassesSearch->getClassesWhichAreChildrenOf( From 209018c237afb975a05b9460701f215338a9013c Mon Sep 17 00:00:00 2001 From: Angelo Romano Date: Wed, 5 Aug 2020 18:00:34 +0200 Subject: [PATCH 014/104] Changed misunderstanding title In order failure page "We received your order!" is not appopriate. --- .../Checkout/view/frontend/layout/checkout_onepage_failure.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_failure.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_failure.xml index 3ab37c2ab6b9f..b815bf74c155a 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_failure.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_failure.xml @@ -9,7 +9,7 @@ - We received your order! + The order was not successful! From afdcc93028526e740594a146b252f5047a65ac07 Mon Sep 17 00:00:00 2001 From: Angelo Romano Date: Wed, 5 Aug 2020 18:31:16 +0200 Subject: [PATCH 015/104] Update en_US.csv --- app/code/Magento/Checkout/i18n/en_US.csv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Checkout/i18n/en_US.csv b/app/code/Magento/Checkout/i18n/en_US.csv index 4a78f8deae841..85ee4e1f03f0e 100644 --- a/app/code/Magento/Checkout/i18n/en_US.csv +++ b/app/code/Magento/Checkout/i18n/en_US.csv @@ -176,7 +176,7 @@ Summary,Summary "We'll send your order confirmation here.","We'll send your order confirmation here." Payment,Payment "Not yet calculated","Not yet calculated" -"We received your order!","We received your order!" +"The order was not successful!","The order was not successful!" "Thank you for your purchase!","Thank you for your purchase!" "Password", "Password" "Something went wrong while saving the page. Please refresh the page and try again.","Something went wrong while saving the page. Please refresh the page and try again." @@ -184,4 +184,4 @@ Payment,Payment "Items in Cart","Items in Cart" "Close","Close" "Show Cross-sell Items in the Shopping Cart","Show Cross-sell Items in the Shopping Cart" -"You added %1 to your shopping cart.","You added %1 to your shopping cart." \ No newline at end of file +"You added %1 to your shopping cart.","You added %1 to your shopping cart." From e2b6d338ed4c978fdc11daa1aca93872160e504b Mon Sep 17 00:00:00 2001 From: Angelo Romano Date: Wed, 5 Aug 2020 18:31:49 +0200 Subject: [PATCH 016/104] Update en_US.csv --- app/code/Magento/Multishipping/i18n/en_US.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Multishipping/i18n/en_US.csv b/app/code/Magento/Multishipping/i18n/en_US.csv index f9ab587c65fa3..0c248bdcc1af3 100644 --- a/app/code/Magento/Multishipping/i18n/en_US.csv +++ b/app/code/Magento/Multishipping/i18n/en_US.csv @@ -87,7 +87,7 @@ Options,Options "Maximum Qty Allowed for Shipping to Multiple Addresses","Maximum Qty Allowed for Shipping to Multiple Addresses" "Review Order","Review Order" "Select Shipping Method","Select Shipping Method" -"We received your order!","We received your order!" +"The order was not successful!","The order was not successful!" "Ship to:","Ship to:" "Error:","Error:" "We are unable to process your request. Please, try again later.","We are unable to process your request. Please, try again later." From 9f53f68bbb32188ff45735d011cb4f97da4a12e3 Mon Sep 17 00:00:00 2001 From: Dave Macaulay Date: Wed, 5 Aug 2020 14:54:24 -0500 Subject: [PATCH 017/104] PWA-806: Localize emails sent through GraphQL application --- .../Magento/GraphQl/Plugin/StoreResolver.php | 82 +++++++++++++++++++ .../GraphQl/Plugin/TranslationLoader.php | 46 +++++++++++ app/code/Magento/GraphQl/etc/graphql/di.xml | 6 ++ lib/internal/Magento/Framework/Phrase/__.php | 14 +++- 4 files changed, 146 insertions(+), 2 deletions(-) create mode 100644 app/code/Magento/GraphQl/Plugin/StoreResolver.php create mode 100644 app/code/Magento/GraphQl/Plugin/TranslationLoader.php diff --git a/app/code/Magento/GraphQl/Plugin/StoreResolver.php b/app/code/Magento/GraphQl/Plugin/StoreResolver.php new file mode 100644 index 0000000000000..a57a31a1f42e1 --- /dev/null +++ b/app/code/Magento/GraphQl/Plugin/StoreResolver.php @@ -0,0 +1,82 @@ +request = $request; + $this->storeRepository = $storeRepository; + } + + /** + * Use the 'Store' header to determine the current store + * + * @param \Magento\Store\Model\StoreResolver $subject + * @param callable $proceed + * @return mixed + */ + public function aroundGetCurrentStoreId(\Magento\Store\Model\StoreResolver $subject, callable $proceed) + { + $storeCode = $this->request->getHeader('Store'); + + if ($storeCode) { + try { + $store = $this->getRequestedStoreByCode($storeCode); + + if ($store) { + return $store; + } + } catch (NoSuchEntityException $e) { + return $proceed(); + } + } + + return $proceed(); + } + + /** + * Retrieve active store by code + * + * @param string $storeCode + * @return StoreInterface + * @throws NoSuchEntityException + */ + private function getRequestedStoreByCode($storeCode) : StoreInterface + { + try { + $store = $this->storeRepository->getActiveStoreByCode($storeCode); + } catch (StoreIsInactiveException $e) { + throw new NoSuchEntityException(__('Requested store is inactive')); + } + + return $store; + } +} diff --git a/app/code/Magento/GraphQl/Plugin/TranslationLoader.php b/app/code/Magento/GraphQl/Plugin/TranslationLoader.php new file mode 100644 index 0000000000000..62c23e454fdf2 --- /dev/null +++ b/app/code/Magento/GraphQl/Plugin/TranslationLoader.php @@ -0,0 +1,46 @@ +areaList = $areaList; + $this->appState = $appState; + } + + /** + * Before rendering any string ensure the translation aspect of area is loaded + */ + public function beforeRender(\Magento\Framework\Phrase $subject) + { + $area = $this->areaList->getArea($this->appState->getAreaCode()); + $area->load(AreaInterface::PART_TRANSLATE); + } +} diff --git a/app/code/Magento/GraphQl/etc/graphql/di.xml b/app/code/Magento/GraphQl/etc/graphql/di.xml index 23d49124d1a02..9ab86610f50f8 100644 --- a/app/code/Magento/GraphQl/etc/graphql/di.xml +++ b/app/code/Magento/GraphQl/etc/graphql/di.xml @@ -41,4 +41,10 @@ + + + + + + diff --git a/lib/internal/Magento/Framework/Phrase/__.php b/lib/internal/Magento/Framework/Phrase/__.php index 0f828acd828b5..9deff31021999 100644 --- a/lib/internal/Magento/Framework/Phrase/__.php +++ b/lib/internal/Magento/Framework/Phrase/__.php @@ -3,15 +3,19 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + declare(strict_types=1); +use Magento\Framework\App\ObjectManager; +use Magento\Framework\Phrase; + /** * Create value-object \Magento\Framework\Phrase * * @SuppressWarnings(PHPMD.ShortMethodName) * phpcs:disable Squiz.Functions.GlobalFunction * @param array $argc - * @return \Magento\Framework\Phrase + * @return Phrase */ function __(...$argc) { @@ -20,5 +24,11 @@ function __(...$argc) $argc = $argc[0]; } - return new \Magento\Framework\Phrase($text, $argc); + return ObjectManager::getInstance()->create( + Phrase::class, + [ + 'text' => $text, + 'arguments' => $argc + ] + ); } From 5a0680cd19ec70d110ba995996f6f2785258cfb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Szubert?= Date: Wed, 5 Aug 2020 22:42:51 +0200 Subject: [PATCH 018/104] Fix #24060 - Terms and Conditions label doesn't fit longer texts --- .../module/checkout/_checkout-agreements.less | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_checkout-agreements.less b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_checkout-agreements.less index ff4f07a983940..b8be2b33a4475 100644 --- a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_checkout-agreements.less +++ b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_checkout-agreements.less @@ -13,6 +13,30 @@ margin-bottom: @indent__base; } + .checkout-agreement.field { + .lib-vendor-prefix-display(); + + &.required { + label:after { + content: none; + } + + .action-show { + &:after { + content: '*'; + .lib-typography( + @_font-size: @form-field-label-asterisk__font-size, + @_color: @form-field-label-asterisk__color, + @_font-family: @form-field-label-asterisk__font-family, + @_font-weight: @form-field-label-asterisk__font-weight, + @_line-height: @form-field-label-asterisk__line-height, + @_font-style: @form-field-label-asterisk__font-style + ); + } + } + } + } + .action-show { &:extend(.abs-action-button-as-link all); vertical-align: baseline; From 4401d655ae5f061bfe57ebd85b726930042f025b Mon Sep 17 00:00:00 2001 From: Dave Macaulay Date: Thu, 6 Aug 2020 13:30:53 -0500 Subject: [PATCH 019/104] PWA-806: Localize emails sent through GraphQL application --- .../Magento/GraphQl/Plugin/StoreResolver.php | 82 ------------------- .../GraphQl/Plugin/TranslationLoader.php | 22 +++-- app/code/Magento/GraphQl/etc/graphql/di.xml | 3 - .../StoreGraphQl/Plugin/StoreResolver.php | 44 ++++++++++ .../Magento/StoreGraphQl/etc/graphql/di.xml | 3 + 5 files changed, 62 insertions(+), 92 deletions(-) delete mode 100644 app/code/Magento/GraphQl/Plugin/StoreResolver.php create mode 100644 app/code/Magento/StoreGraphQl/Plugin/StoreResolver.php diff --git a/app/code/Magento/GraphQl/Plugin/StoreResolver.php b/app/code/Magento/GraphQl/Plugin/StoreResolver.php deleted file mode 100644 index a57a31a1f42e1..0000000000000 --- a/app/code/Magento/GraphQl/Plugin/StoreResolver.php +++ /dev/null @@ -1,82 +0,0 @@ -request = $request; - $this->storeRepository = $storeRepository; - } - - /** - * Use the 'Store' header to determine the current store - * - * @param \Magento\Store\Model\StoreResolver $subject - * @param callable $proceed - * @return mixed - */ - public function aroundGetCurrentStoreId(\Magento\Store\Model\StoreResolver $subject, callable $proceed) - { - $storeCode = $this->request->getHeader('Store'); - - if ($storeCode) { - try { - $store = $this->getRequestedStoreByCode($storeCode); - - if ($store) { - return $store; - } - } catch (NoSuchEntityException $e) { - return $proceed(); - } - } - - return $proceed(); - } - - /** - * Retrieve active store by code - * - * @param string $storeCode - * @return StoreInterface - * @throws NoSuchEntityException - */ - private function getRequestedStoreByCode($storeCode) : StoreInterface - { - try { - $store = $this->storeRepository->getActiveStoreByCode($storeCode); - } catch (StoreIsInactiveException $e) { - throw new NoSuchEntityException(__('Requested store is inactive')); - } - - return $store; - } -} diff --git a/app/code/Magento/GraphQl/Plugin/TranslationLoader.php b/app/code/Magento/GraphQl/Plugin/TranslationLoader.php index 62c23e454fdf2..fec872c212eea 100644 --- a/app/code/Magento/GraphQl/Plugin/TranslationLoader.php +++ b/app/code/Magento/GraphQl/Plugin/TranslationLoader.php @@ -4,12 +4,10 @@ use Magento\Framework\App\AreaInterface; use Magento\Framework\App\AreaList; -use Magento\Framework\App\ObjectManager; use Magento\Framework\App\State; -use Magento\Store\Model\StoreManagerInterface; /** - * Load translations for GraphQL requests + * Load translations on the first instance of a translated string */ class TranslationLoader { @@ -23,6 +21,11 @@ class TranslationLoader */ private $appState; + /** + * @var bool + */ + private $translationsLoaded = false; + /** * @param AreaList $areaList * @param State $appState @@ -36,11 +39,16 @@ public function __construct( } /** - * Before rendering any string ensure the translation aspect of area is loaded + * Before render of any localized string ensure the translation data is loaded + * + * @throws \Magento\Framework\Exception\LocalizedException */ - public function beforeRender(\Magento\Framework\Phrase $subject) + public function beforeRender() { - $area = $this->areaList->getArea($this->appState->getAreaCode()); - $area->load(AreaInterface::PART_TRANSLATE); + if ($this->translationsLoaded === false) { + $area = $this->areaList->getArea($this->appState->getAreaCode()); + $area->load(AreaInterface::PART_TRANSLATE); + $this->translationsLoaded = true; + } } } diff --git a/app/code/Magento/GraphQl/etc/graphql/di.xml b/app/code/Magento/GraphQl/etc/graphql/di.xml index 9ab86610f50f8..f60bc730747f0 100644 --- a/app/code/Magento/GraphQl/etc/graphql/di.xml +++ b/app/code/Magento/GraphQl/etc/graphql/di.xml @@ -44,7 +44,4 @@ - - - diff --git a/app/code/Magento/StoreGraphQl/Plugin/StoreResolver.php b/app/code/Magento/StoreGraphQl/Plugin/StoreResolver.php new file mode 100644 index 0000000000000..65779f22f2758 --- /dev/null +++ b/app/code/Magento/StoreGraphQl/Plugin/StoreResolver.php @@ -0,0 +1,44 @@ +request = $request; + } + + /** + * If no scope is provided and there is a Store header, ensure the correct store code is used + * + * @param Store $subject + * @param null $scopeId + * @return array + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function beforeGetScope(Store $subject, $scopeId = null) + { + $storeCode = $this->request->getHeader('Store'); + + if ($scopeId === null && $storeCode) { + return [$storeCode]; + } + } +} diff --git a/app/code/Magento/StoreGraphQl/etc/graphql/di.xml b/app/code/Magento/StoreGraphQl/etc/graphql/di.xml index 3a0143821d8b9..93d6a1356e0d0 100644 --- a/app/code/Magento/StoreGraphQl/etc/graphql/di.xml +++ b/app/code/Magento/StoreGraphQl/etc/graphql/di.xml @@ -23,4 +23,7 @@ + + + From 8b51cf883131eae0d9b161698ac9c062e321d32b Mon Sep 17 00:00:00 2001 From: Dave Macaulay Date: Thu, 6 Aug 2020 14:50:48 -0500 Subject: [PATCH 020/104] PWA-806: Localize emails sent through GraphQL application --- .../GraphQl/Plugin/TranslationLoader.php | 54 ------------------- app/code/Magento/GraphQl/etc/graphql/di.xml | 3 -- .../HttpHeaderProcessor/StoreProcessor.php | 26 ++++++++- lib/internal/Magento/Framework/Phrase/__.php | 14 +---- 4 files changed, 27 insertions(+), 70 deletions(-) delete mode 100644 app/code/Magento/GraphQl/Plugin/TranslationLoader.php diff --git a/app/code/Magento/GraphQl/Plugin/TranslationLoader.php b/app/code/Magento/GraphQl/Plugin/TranslationLoader.php deleted file mode 100644 index fec872c212eea..0000000000000 --- a/app/code/Magento/GraphQl/Plugin/TranslationLoader.php +++ /dev/null @@ -1,54 +0,0 @@ -areaList = $areaList; - $this->appState = $appState; - } - - /** - * Before render of any localized string ensure the translation data is loaded - * - * @throws \Magento\Framework\Exception\LocalizedException - */ - public function beforeRender() - { - if ($this->translationsLoaded === false) { - $area = $this->areaList->getArea($this->appState->getAreaCode()); - $area->load(AreaInterface::PART_TRANSLATE); - $this->translationsLoaded = true; - } - } -} diff --git a/app/code/Magento/GraphQl/etc/graphql/di.xml b/app/code/Magento/GraphQl/etc/graphql/di.xml index f60bc730747f0..23d49124d1a02 100644 --- a/app/code/Magento/GraphQl/etc/graphql/di.xml +++ b/app/code/Magento/GraphQl/etc/graphql/di.xml @@ -41,7 +41,4 @@ - - - diff --git a/app/code/Magento/StoreGraphQl/Controller/HttpHeaderProcessor/StoreProcessor.php b/app/code/Magento/StoreGraphQl/Controller/HttpHeaderProcessor/StoreProcessor.php index 7999a96917cde..66800520eb4cb 100644 --- a/app/code/Magento/StoreGraphQl/Controller/HttpHeaderProcessor/StoreProcessor.php +++ b/app/code/Magento/StoreGraphQl/Controller/HttpHeaderProcessor/StoreProcessor.php @@ -7,6 +7,10 @@ namespace Magento\StoreGraphQl\Controller\HttpHeaderProcessor; +use Magento\Framework\App\AreaInterface; +use Magento\Framework\App\AreaList; +use Magento\Framework\App\ObjectManager; +use Magento\Framework\App\State; use Magento\GraphQl\Controller\HttpHeaderProcessorInterface; use Magento\Store\Model\StoreManagerInterface; use Magento\Framework\App\Http\Context as HttpContext; @@ -32,19 +36,35 @@ class StoreProcessor implements HttpHeaderProcessorInterface */ private $storeCookieManager; + /** + * @var AreaList + */ + private $areaList; + + /** + * @var State + */ + private $appState; + /** * @param StoreManagerInterface $storeManager * @param HttpContext $httpContext * @param StoreCookieManagerInterface $storeCookieManager + * @param AreaList $areaList + * @param State $appState */ public function __construct( StoreManagerInterface $storeManager, HttpContext $httpContext, - StoreCookieManagerInterface $storeCookieManager + StoreCookieManagerInterface $storeCookieManager, + AreaList $areaList = null, + State $appState = null ) { $this->storeManager = $storeManager; $this->httpContext = $httpContext; $this->storeCookieManager = $storeCookieManager; + $this->areaList = $areaList ?? ObjectManager::getInstance()->get(AreaList::class); + $this->appState = $appState ?? ObjectManager::getInstance()->get(State::class); } /** @@ -67,6 +87,10 @@ public function processHeaderValue(string $headerValue) : void $this->storeManager->setCurrentStore($storeCode); $this->updateContext($storeCode); } + + // Load translations for the app + $area = $this->areaList->getArea($this->appState->getAreaCode()); + $area->load(AreaInterface::PART_TRANSLATE); } /** diff --git a/lib/internal/Magento/Framework/Phrase/__.php b/lib/internal/Magento/Framework/Phrase/__.php index 9deff31021999..0f828acd828b5 100644 --- a/lib/internal/Magento/Framework/Phrase/__.php +++ b/lib/internal/Magento/Framework/Phrase/__.php @@ -3,19 +3,15 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - declare(strict_types=1); -use Magento\Framework\App\ObjectManager; -use Magento\Framework\Phrase; - /** * Create value-object \Magento\Framework\Phrase * * @SuppressWarnings(PHPMD.ShortMethodName) * phpcs:disable Squiz.Functions.GlobalFunction * @param array $argc - * @return Phrase + * @return \Magento\Framework\Phrase */ function __(...$argc) { @@ -24,11 +20,5 @@ function __(...$argc) $argc = $argc[0]; } - return ObjectManager::getInstance()->create( - Phrase::class, - [ - 'text' => $text, - 'arguments' => $argc - ] - ); + return new \Magento\Framework\Phrase($text, $argc); } From 6209cfbc52bc213f5a578c3fbdaaf6e5ddf3ad15 Mon Sep 17 00:00:00 2001 From: Ievgen Kolesov Date: Thu, 6 Aug 2020 16:15:00 -0500 Subject: [PATCH 021/104] PWA-805: Expose localization system / store config from GraphQL --- .../Store/Model/ResourceModel/StoreWebsiteRelation.php | 10 +++++++++- .../Model/Resolver/AvailableStoresResolver.php | 6 +++++- .../Model/Resolver/Store/StoreConfigDataProvider.php | 5 +++-- app/code/Magento/StoreGraphQl/etc/graphql/di.xml | 7 +++++++ app/code/Magento/StoreGraphQl/etc/schema.graphqls | 5 ++++- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Store/Model/ResourceModel/StoreWebsiteRelation.php b/app/code/Magento/Store/Model/ResourceModel/StoreWebsiteRelation.php index 19bb45de24d64..f0b021eefb999 100644 --- a/app/code/Magento/Store/Model/ResourceModel/StoreWebsiteRelation.php +++ b/app/code/Magento/Store/Model/ResourceModel/StoreWebsiteRelation.php @@ -48,10 +48,11 @@ public function getStoreByWebsiteId($websiteId) * Get website store data * * @param int $websiteId + * @param int $storeGroupId * @param bool $available * @return array */ - public function getWebsiteStores(int $websiteId, bool $available = false): array + public function getWebsiteStores(int $websiteId, int $storeGroupId = null, bool $available = false): array { $connection = $this->resource->getConnection(); $storeTable = $this->resource->getTableName('store'); @@ -60,6 +61,13 @@ public function getWebsiteStores(int $websiteId, bool $available = false): array $websiteId ); + if ($storeGroupId) { + $storeSelect = $storeSelect->where( + 'group_id = ?', + $storeGroupId + ); + } + if ($available) { $storeSelect = $storeSelect->where( 'is_active = 1' diff --git a/app/code/Magento/StoreGraphQl/Model/Resolver/AvailableStoresResolver.php b/app/code/Magento/StoreGraphQl/Model/Resolver/AvailableStoresResolver.php index eedd7e21fa058..ab1ba9f8a225f 100644 --- a/app/code/Magento/StoreGraphQl/Model/Resolver/AvailableStoresResolver.php +++ b/app/code/Magento/StoreGraphQl/Model/Resolver/AvailableStoresResolver.php @@ -41,8 +41,12 @@ public function resolve( array $value = null, array $args = null ) { + $storeGroupId = !empty($args['use_current_group']) ? + (int)$context->getExtensionAttributes()->getStore()->getStoreGroupId() : + null; return $this->storeConfigDataProvider->getAvailableStoreConfig( - (int)$context->getExtensionAttributes()->getStore()->getWebsiteId() + (int)$context->getExtensionAttributes()->getStore()->getWebsiteId(), + $storeGroupId ); } } diff --git a/app/code/Magento/StoreGraphQl/Model/Resolver/Store/StoreConfigDataProvider.php b/app/code/Magento/StoreGraphQl/Model/Resolver/Store/StoreConfigDataProvider.php index 6538d87de9780..928a99eb73714 100644 --- a/app/code/Magento/StoreGraphQl/Model/Resolver/Store/StoreConfigDataProvider.php +++ b/app/code/Magento/StoreGraphQl/Model/Resolver/Store/StoreConfigDataProvider.php @@ -73,11 +73,12 @@ public function getStoreConfigData(StoreInterface $store): array * Get available website stores * * @param int $websiteId + * @param int|null $storeGroupId * @return array */ - public function getAvailableStoreConfig(int $websiteId): array + public function getAvailableStoreConfig(int $websiteId, int $storeGroupId = null): array { - $websiteStores = $this->storeWebsiteRelation->getWebsiteStores($websiteId, true); + $websiteStores = $this->storeWebsiteRelation->getWebsiteStores($websiteId, $storeGroupId, true); $storeCodes = array_column($websiteStores, 'code'); $storeConfigs = $this->storeConfigManager->getStoreConfigs($storeCodes); diff --git a/app/code/Magento/StoreGraphQl/etc/graphql/di.xml b/app/code/Magento/StoreGraphQl/etc/graphql/di.xml index 3a0143821d8b9..7ba2264b650ee 100644 --- a/app/code/Magento/StoreGraphQl/etc/graphql/di.xml +++ b/app/code/Magento/StoreGraphQl/etc/graphql/di.xml @@ -23,4 +23,11 @@ + + + + web/url/use_store + + + diff --git a/app/code/Magento/StoreGraphQl/etc/schema.graphqls b/app/code/Magento/StoreGraphQl/etc/schema.graphqls index d85bac7801f39..6dcbf1aded4d8 100644 --- a/app/code/Magento/StoreGraphQl/etc/schema.graphqls +++ b/app/code/Magento/StoreGraphQl/etc/schema.graphqls @@ -2,7 +2,9 @@ # See COPYING.txt for license details. type Query { storeConfig : StoreConfig @resolver(class: "Magento\\StoreGraphQl\\Model\\Resolver\\StoreConfigResolver") @doc(description: "The store config query") @cache(cacheable: false) - availableStores: [StoreConfig] @resolver(class: "Magento\\StoreGraphQl\\Model\\Resolver\\AvailableStoresResolver") @doc(description: "Get a list of available store views and their config information.") + availableStores( + use_current_group : Boolean @doc(description: "Get only store views from the current store group") + ): [StoreConfig] @resolver(class: "Magento\\StoreGraphQl\\Model\\Resolver\\AvailableStoresResolver") @doc(description: "Get a list of available store views and their config information.") } type Website @doc(description: "Website is deprecated because it is should not be used on storefront. The type contains information about a website") { @@ -32,4 +34,5 @@ type StoreConfig @doc(description: "The type contains information about a store secure_base_static_url : String @doc(description: "Secure base static URL for the store") secure_base_media_url : String @doc(description: "Secure base media URL for the store") store_name : String @doc(description: "Name of the store") + use_store_in_url: Boolean @doc(description: "Indicates whether store code is used in url") } From 36335422453af4abf58859acba7224cabe0f5e43 Mon Sep 17 00:00:00 2001 From: Shankar Konar Date: Fri, 7 Aug 2020 11:09:39 +0530 Subject: [PATCH 022/104] Media Gallery configuration are reversed --- .../SaveBaseCategoryImageInformation.php | 2 +- .../Model/OpenDialogUrlProvider.php | 2 +- .../Plugin/SaveImageInformation.php | 2 +- .../Model/ImageComponentOpenDialogUrlTest.php | 4 ++-- .../Model/OpenDialogUrlProviderTest.php | 4 ++-- .../Model/TinyMceOpenDialogUrlTest.php | 4 ++-- .../WysiwygDefaultConfigOpenDialogUrlTest.php | 4 ++-- .../Plugin/MediaGallerySyncTrigger.php | 2 +- .../Test/Mftf/Data/AdobeStockConfigData.xml | 4 ++-- .../MediaGalleryUi/etc/adminhtml/menu.xml | 18 ++++++++++++++++-- .../MediaGalleryUi/etc/adminhtml/system.xml | 4 ++-- 11 files changed, 32 insertions(+), 18 deletions(-) diff --git a/app/code/Magento/MediaGalleryCatalogIntegration/Plugin/SaveBaseCategoryImageInformation.php b/app/code/Magento/MediaGalleryCatalogIntegration/Plugin/SaveBaseCategoryImageInformation.php index d439b53c120cb..67a99bfaa84c2 100644 --- a/app/code/Magento/MediaGalleryCatalogIntegration/Plugin/SaveBaseCategoryImageInformation.php +++ b/app/code/Magento/MediaGalleryCatalogIntegration/Plugin/SaveBaseCategoryImageInformation.php @@ -86,7 +86,7 @@ public function __construct( */ public function afterMoveFileFromTmp(ImageUploader $subject, string $imagePath): string { - if (!$this->config->isEnabled()) { + if ($this->config->isEnabled()) { return $imagePath; } diff --git a/app/code/Magento/MediaGalleryIntegration/Model/OpenDialogUrlProvider.php b/app/code/Magento/MediaGalleryIntegration/Model/OpenDialogUrlProvider.php index 317b811df5692..3834550f2703e 100644 --- a/app/code/Magento/MediaGalleryIntegration/Model/OpenDialogUrlProvider.php +++ b/app/code/Magento/MediaGalleryIntegration/Model/OpenDialogUrlProvider.php @@ -35,6 +35,6 @@ public function __construct(ConfigInterface $config) */ public function getUrl(): string { - return $this->config->isEnabled() ? 'media_gallery/index/index' : 'cms/wysiwyg_images/index'; + return $this->config->isEnabled() ? 'cms/wysiwyg_images/index' : 'media_gallery/index/index'; } } diff --git a/app/code/Magento/MediaGalleryIntegration/Plugin/SaveImageInformation.php b/app/code/Magento/MediaGalleryIntegration/Plugin/SaveImageInformation.php index fbe35db298b04..4d0e6200ddaad 100644 --- a/app/code/Magento/MediaGalleryIntegration/Plugin/SaveImageInformation.php +++ b/app/code/Magento/MediaGalleryIntegration/Plugin/SaveImageInformation.php @@ -78,7 +78,7 @@ public function __construct( */ public function afterSave(Uploader $subject, array $result): array { - if (!$this->config->isEnabled()) { + if ($this->config->isEnabled()) { return $result; } diff --git a/app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/ImageComponentOpenDialogUrlTest.php b/app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/ImageComponentOpenDialogUrlTest.php index dfeaa3eff56bd..0e5cd070a7eec 100644 --- a/app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/ImageComponentOpenDialogUrlTest.php +++ b/app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/ImageComponentOpenDialogUrlTest.php @@ -50,7 +50,7 @@ protected function setUp(): void /** * Test image open dialog url when enhanced media gallery not enabled. - * @magentoConfigFixture default/system/media_gallery/enabled 0 + * @magentoConfigFixture default/system/media_gallery/enabled 1 */ public function testWithEnhancedMediaGalleryDisabled(): void { @@ -61,7 +61,7 @@ public function testWithEnhancedMediaGalleryDisabled(): void /** * Test image open dialog url when enhanced media gallery enabled. - * @magentoConfigFixture default/system/media_gallery/enabled 1 + * @magentoConfigFixture default/system/media_gallery/enabled 0 */ public function testWithEnhancedMediaGalleryEnabled(): void { diff --git a/app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/OpenDialogUrlProviderTest.php b/app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/OpenDialogUrlProviderTest.php index 7a3316f293879..3973ed132b490 100644 --- a/app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/OpenDialogUrlProviderTest.php +++ b/app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/OpenDialogUrlProviderTest.php @@ -45,7 +45,7 @@ protected function setUp(): void /** * Test getting open dialog url with enhanced media gallery disabled. - * @magentoConfigFixture default/system/media_gallery/enabled 0 + * @magentoConfigFixture default/system/media_gallery/enabled 1 */ public function testWithEnhancedMediaGalleryDisabled(): void { @@ -54,7 +54,7 @@ public function testWithEnhancedMediaGalleryDisabled(): void /** * Test getting open dialog url when enhanced media gallery enabled. - * @magentoConfigFixture default/system/media_gallery/enabled 1 + * @magentoConfigFixture default/system/media_gallery/enabled 0 */ public function testWithEnhancedMediaGalleryEnabled(): void { diff --git a/app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/TinyMceOpenDialogUrlTest.php b/app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/TinyMceOpenDialogUrlTest.php index 81a4dc642cfa0..c15536f6af445 100644 --- a/app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/TinyMceOpenDialogUrlTest.php +++ b/app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/TinyMceOpenDialogUrlTest.php @@ -58,7 +58,7 @@ protected function setUp(): void /** * Test image open dialog url when enhanced media gallery not enabled. - * @magentoConfigFixture default/system/media_gallery/enabled 0 + * @magentoConfigFixture default/system/media_gallery/enabled 1 */ public function testWithEnhancedMediaGalleryDisabled(): void { @@ -68,7 +68,7 @@ public function testWithEnhancedMediaGalleryDisabled(): void /** * Test image open dialog url when enhanced media gallery enabled. - * @magentoConfigFixture default/system/media_gallery/enabled 1 + * @magentoConfigFixture default/system/media_gallery/enabled 0 */ public function testWithEnhancedMediaGalleryEnabled(): void { diff --git a/app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/WysiwygDefaultConfigOpenDialogUrlTest.php b/app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/WysiwygDefaultConfigOpenDialogUrlTest.php index aebf5927869d5..df6cbe4fc2c09 100644 --- a/app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/WysiwygDefaultConfigOpenDialogUrlTest.php +++ b/app/code/Magento/MediaGalleryIntegration/Test/Integration/Model/WysiwygDefaultConfigOpenDialogUrlTest.php @@ -58,7 +58,7 @@ protected function setUp(): void /** * Test update wysiwyg editor open dialog url when enhanced media gallery not enabled. - * @magentoConfigFixture default/system/media_gallery/enabled 0 + * @magentoConfigFixture default/system/media_gallery/enabled 1 */ public function testWithEnhancedMediaGalleryDisabled(): void { @@ -70,7 +70,7 @@ public function testWithEnhancedMediaGalleryDisabled(): void /** * Test update wysiwyg editor open dialog url when enhanced media gallery enabled. - * @magentoConfigFixture default/system/media_gallery/enabled 1 + * @magentoConfigFixture default/system/media_gallery/enabled 0 */ public function testWithEnhancedMediaGalleryEnabled(): void { diff --git a/app/code/Magento/MediaGallerySynchronization/Plugin/MediaGallerySyncTrigger.php b/app/code/Magento/MediaGallerySynchronization/Plugin/MediaGallerySyncTrigger.php index 9583c91184d1a..dfe007fa59add 100644 --- a/app/code/Magento/MediaGallerySynchronization/Plugin/MediaGallerySyncTrigger.php +++ b/app/code/Magento/MediaGallerySynchronization/Plugin/MediaGallerySyncTrigger.php @@ -43,7 +43,7 @@ public function afterSave(Value $config, Value $result): Value { if ($result->getPath() === self::MEDIA_GALLERY_CONFIG_VALUE && $result->isValueChanged() - && (int) $result->getValue() === self::MEDIA_GALLERY_ENABLED_VALUE + && (int) $result->getValue() !== self::MEDIA_GALLERY_ENABLED_VALUE ) { $this->publish->execute(); } diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/Data/AdobeStockConfigData.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/Data/AdobeStockConfigData.xml index e8f394a006104..5e02d81fb82ae 100644 --- a/app/code/Magento/MediaGalleryUi/Test/Mftf/Data/AdobeStockConfigData.xml +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/Data/AdobeStockConfigData.xml @@ -9,10 +9,10 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> system/media_gallery/enabled - 1 + 0 system/media_gallery/enabled - 0 + 1 diff --git a/app/code/Magento/MediaGalleryUi/etc/adminhtml/menu.xml b/app/code/Magento/MediaGalleryUi/etc/adminhtml/menu.xml index 92839aa75ac8b..e7486ccbf5a2f 100644 --- a/app/code/Magento/MediaGalleryUi/etc/adminhtml/menu.xml +++ b/app/code/Magento/MediaGalleryUi/etc/adminhtml/menu.xml @@ -7,7 +7,21 @@ --> - - + + diff --git a/app/code/Magento/MediaGalleryUi/etc/adminhtml/system.xml b/app/code/Magento/MediaGalleryUi/etc/adminhtml/system.xml index 77544b42e899a..1c303ab155dae 100644 --- a/app/code/Magento/MediaGalleryUi/etc/adminhtml/system.xml +++ b/app/code/Magento/MediaGalleryUi/etc/adminhtml/system.xml @@ -9,9 +9,9 @@
- + - + Magento\Config\Model\Config\Source\Yesno system/media_gallery/enabled From 651bd690cb0687565cc2a1e99a57d99be5e8f14c Mon Sep 17 00:00:00 2001 From: Shankar Konar Date: Fri, 7 Aug 2020 13:49:35 +0530 Subject: [PATCH 023/104] fixed MFTF test --- .../MediaGalleryUi/Test/Mftf/Suite/MediaGalleryUiSuite.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/Suite/MediaGalleryUiSuite.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/Suite/MediaGalleryUiSuite.xml index 4749fc4a885b0..14464cf36234c 100644 --- a/app/code/Magento/MediaGalleryUi/Test/Mftf/Suite/MediaGalleryUiSuite.xml +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/Suite/MediaGalleryUiSuite.xml @@ -13,7 +13,7 @@ - + From 11d0a351c4ad83637620c9b7ab00ef68b028b7fa Mon Sep 17 00:00:00 2001 From: janmonteros Date: Fri, 7 Aug 2020 16:26:30 +0800 Subject: [PATCH 024/104] magento/adobe-stock-integration#1711: Use product model instead of data object for catalog image helper init --- .../Ui/Component/Listing/Columns/Thumbnail.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/MediaGalleryCatalogUi/Ui/Component/Listing/Columns/Thumbnail.php b/app/code/Magento/MediaGalleryCatalogUi/Ui/Component/Listing/Columns/Thumbnail.php index efb2ad2f8dae5..7a2662b59d198 100644 --- a/app/code/Magento/MediaGalleryCatalogUi/Ui/Component/Listing/Columns/Thumbnail.php +++ b/app/code/Magento/MediaGalleryCatalogUi/Ui/Component/Listing/Columns/Thumbnail.php @@ -6,7 +6,7 @@ namespace Magento\MediaGalleryCatalogUi\Ui\Component\Listing\Columns; use Magento\Catalog\Helper\Image; -use Magento\Framework\DataObject; +use Magento\Catalog\Model\ProductFactory; use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Framework\View\Element\UiComponentFactory; use Magento\Store\Model\Store; @@ -29,11 +29,17 @@ class Thumbnail extends Column */ private $imageHelper; + /** + * @var ProductFactory + */ + private $productFactory; + /** * @param ContextInterface $context * @param UiComponentFactory $uiComponentFactory * @param StoreManagerInterface $storeManager * @param Image $image + * @param ProductFactory $productFactory * @param array $components * @param array $data */ @@ -42,12 +48,14 @@ public function __construct( UiComponentFactory $uiComponentFactory, StoreManagerInterface $storeManager, Image $image, + ProductFactory $productFactory, array $components = [], array $data = [] ) { parent::__construct($context, $uiComponentFactory, $components, $data); $this->imageHelper = $image; $this->storeManager = $storeManager; + $this->productFactory = $productFactory; } /** @@ -64,7 +72,7 @@ public function prepareDataSource(array $dataSource) if (isset($item[$fieldName])) { $item[$fieldName . '_src'] = $this->getUrl($item[$fieldName]); } else { - $category = new DataObject($item); + $category = $this->productFactory->create($item); $imageHelper = $this->imageHelper->init($category, 'product_listing_thumbnail'); $item[$fieldName . '_src'] = $imageHelper->getUrl(); } From 25133c56cf0e0390c11399b78cbe3fb426fdd1be Mon Sep 17 00:00:00 2001 From: janmonteros Date: Fri, 7 Aug 2020 18:36:39 +0800 Subject: [PATCH 025/104] magento/adobe-stock-integration#1711: Use product model instead of data object for catalog image helper init - Apply PR suggestion --- .../Ui/Component/Listing/Columns/Thumbnail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/MediaGalleryCatalogUi/Ui/Component/Listing/Columns/Thumbnail.php b/app/code/Magento/MediaGalleryCatalogUi/Ui/Component/Listing/Columns/Thumbnail.php index 7a2662b59d198..4cacaea0d99bf 100644 --- a/app/code/Magento/MediaGalleryCatalogUi/Ui/Component/Listing/Columns/Thumbnail.php +++ b/app/code/Magento/MediaGalleryCatalogUi/Ui/Component/Listing/Columns/Thumbnail.php @@ -72,7 +72,7 @@ public function prepareDataSource(array $dataSource) if (isset($item[$fieldName])) { $item[$fieldName . '_src'] = $this->getUrl($item[$fieldName]); } else { - $category = $this->productFactory->create($item); + $category = $this->productFactory->create(['data' => $item]); $imageHelper = $this->imageHelper->init($category, 'product_listing_thumbnail'); $item[$fieldName . '_src'] = $imageHelper->getUrl(); } From 8b592ee2005c4c324672b0b3f1f69307384c43c5 Mon Sep 17 00:00:00 2001 From: Shankar Konar Date: Fri, 7 Aug 2020 17:02:14 +0530 Subject: [PATCH 026/104] Enabled old media gallery by default --- app/code/Magento/MediaGalleryUi/etc/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/MediaGalleryUi/etc/config.xml b/app/code/Magento/MediaGalleryUi/etc/config.xml index fe8e73c406e59..593b1b8e58fd2 100644 --- a/app/code/Magento/MediaGalleryUi/etc/config.xml +++ b/app/code/Magento/MediaGalleryUi/etc/config.xml @@ -9,7 +9,7 @@ - 0 + 1 From d4417050c0eb265af0222ad5b844ebb1548ca421 Mon Sep 17 00:00:00 2001 From: Ievgen Kolesov Date: Fri, 7 Aug 2020 09:01:18 -0500 Subject: [PATCH 027/104] PWA-805: Expose localization system / store config from GraphQL --- .../StoreGraphQl/Model/Resolver/AvailableStoresResolver.php | 2 +- app/code/Magento/StoreGraphQl/etc/schema.graphqls | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/StoreGraphQl/Model/Resolver/AvailableStoresResolver.php b/app/code/Magento/StoreGraphQl/Model/Resolver/AvailableStoresResolver.php index ab1ba9f8a225f..5e49a8a0b7ff0 100644 --- a/app/code/Magento/StoreGraphQl/Model/Resolver/AvailableStoresResolver.php +++ b/app/code/Magento/StoreGraphQl/Model/Resolver/AvailableStoresResolver.php @@ -41,7 +41,7 @@ public function resolve( array $value = null, array $args = null ) { - $storeGroupId = !empty($args['use_current_group']) ? + $storeGroupId = !empty($args['useCurrentGroup']) ? (int)$context->getExtensionAttributes()->getStore()->getStoreGroupId() : null; return $this->storeConfigDataProvider->getAvailableStoreConfig( diff --git a/app/code/Magento/StoreGraphQl/etc/schema.graphqls b/app/code/Magento/StoreGraphQl/etc/schema.graphqls index 6dcbf1aded4d8..cf50041bb9bea 100644 --- a/app/code/Magento/StoreGraphQl/etc/schema.graphqls +++ b/app/code/Magento/StoreGraphQl/etc/schema.graphqls @@ -3,7 +3,7 @@ type Query { storeConfig : StoreConfig @resolver(class: "Magento\\StoreGraphQl\\Model\\Resolver\\StoreConfigResolver") @doc(description: "The store config query") @cache(cacheable: false) availableStores( - use_current_group : Boolean @doc(description: "Get only store views from the current store group") + useCurrentGroup: Boolean @doc(description: "Get only store views from the current store group") ): [StoreConfig] @resolver(class: "Magento\\StoreGraphQl\\Model\\Resolver\\AvailableStoresResolver") @doc(description: "Get a list of available store views and their config information.") } From c72447ff51cf095595bbe47b67afe0d45d5b0941 Mon Sep 17 00:00:00 2001 From: janmonteros Date: Fri, 7 Aug 2020 23:33:10 +0800 Subject: [PATCH 028/104] magento/adobe-stock-integration#1711: Use product model instead of data object for catalog image helper init - Revised approach based from pr suggestion --- .../Component/Listing/Columns/Thumbnail.php | 72 +++++++++++++----- .../etc/adminhtml/di.xml | 7 ++ .../web/images/category/placeholder/image.jpg | Bin 0 -> 820 bytes 3 files changed, 59 insertions(+), 20 deletions(-) create mode 100644 app/code/Magento/MediaGalleryCatalogUi/view/adminhtml/web/images/category/placeholder/image.jpg diff --git a/app/code/Magento/MediaGalleryCatalogUi/Ui/Component/Listing/Columns/Thumbnail.php b/app/code/Magento/MediaGalleryCatalogUi/Ui/Component/Listing/Columns/Thumbnail.php index 4cacaea0d99bf..dada8ee7acc19 100644 --- a/app/code/Magento/MediaGalleryCatalogUi/Ui/Component/Listing/Columns/Thumbnail.php +++ b/app/code/Magento/MediaGalleryCatalogUi/Ui/Component/Listing/Columns/Thumbnail.php @@ -5,8 +5,9 @@ */ namespace Magento\MediaGalleryCatalogUi\Ui\Component\Listing\Columns; -use Magento\Catalog\Helper\Image; -use Magento\Catalog\Model\ProductFactory; +use Magento\Catalog\Model\Category\Image; +use Magento\Catalog\Model\CategoryRepository; +use Magento\Framework\View\Asset\Repository as AssetRepository; use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Framework\View\Element\UiComponentFactory; use Magento\Store\Model\Store; @@ -27,19 +28,32 @@ class Thumbnail extends Column /** * @var Image */ - private $imageHelper; + private $categoryImage; /** - * @var ProductFactory + * @var CategoryRepository */ - private $productFactory; + private $categoryRepository; /** + * @var AssetRepository + */ + private $assetRepository; + + /** + * @var string[] + */ + private $defaultPlaceholder; + + /** + * Thumbnail constructor. * @param ContextInterface $context * @param UiComponentFactory $uiComponentFactory * @param StoreManagerInterface $storeManager - * @param Image $image - * @param ProductFactory $productFactory + * @param Image $categoryImage + * @param CategoryRepository $categoryRepository + * @param AssetRepository $assetRepository + * @param array $defaultPlaceholder * @param array $components * @param array $data */ @@ -47,15 +61,19 @@ public function __construct( ContextInterface $context, UiComponentFactory $uiComponentFactory, StoreManagerInterface $storeManager, - Image $image, - ProductFactory $productFactory, + Image $categoryImage, + CategoryRepository $categoryRepository, + AssetRepository $assetRepository, + array $defaultPlaceholder = [], array $components = [], array $data = [] ) { parent::__construct($context, $uiComponentFactory, $components, $data); - $this->imageHelper = $image; $this->storeManager = $storeManager; - $this->productFactory = $productFactory; + $this->categoryImage = $categoryImage; + $this->categoryRepository = $categoryRepository; + $this->assetRepository = $assetRepository; + $this->defaultPlaceholder = $defaultPlaceholder; } /** @@ -63,20 +81,34 @@ public function __construct( * * @param array $dataSource * @return array + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function prepareDataSource(array $dataSource) { - if (isset($dataSource['data']['items'])) { - $fieldName = $this->getData('name'); - foreach ($dataSource['data']['items'] as & $item) { - if (isset($item[$fieldName])) { - $item[$fieldName . '_src'] = $this->getUrl($item[$fieldName]); - } else { - $category = $this->productFactory->create(['data' => $item]); - $imageHelper = $this->imageHelper->init($category, 'product_listing_thumbnail'); - $item[$fieldName . '_src'] = $imageHelper->getUrl(); + if (!isset($dataSource['data']['items'])) { + return $dataSource; + } + + $fieldName = $this->getData('name'); + foreach ($dataSource['data']['items'] as & $item) { + if (isset($item[$fieldName])) { + $item[$fieldName . '_src'] = $this->getUrl($item[$fieldName]); + continue; + } + + if (isset($item['entity_id'])) { + $src = $this->categoryImage->getUrl( + $this->categoryRepository->get($item['entity_id']) + ); + + if (!empty($src)) { + $item[$fieldName . '_src'] = $src; + continue; } } + + $item[$fieldName . '_src'] = $this->assetRepository->getUrl($this->defaultPlaceholder['image']); } return $dataSource; diff --git a/app/code/Magento/MediaGalleryCatalogUi/etc/adminhtml/di.xml b/app/code/Magento/MediaGalleryCatalogUi/etc/adminhtml/di.xml index 500ac10f4745a..222cfde1385f7 100644 --- a/app/code/Magento/MediaGalleryCatalogUi/etc/adminhtml/di.xml +++ b/app/code/Magento/MediaGalleryCatalogUi/etc/adminhtml/di.xml @@ -38,4 +38,11 @@ + + + + Magento_MediaGalleryCatalogUi::images/category/placeholder/image.jpg + + + diff --git a/app/code/Magento/MediaGalleryCatalogUi/view/adminhtml/web/images/category/placeholder/image.jpg b/app/code/Magento/MediaGalleryCatalogUi/view/adminhtml/web/images/category/placeholder/image.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0d5ef7e1bd4127242b442957d4f543d7e9e0320e GIT binary patch literal 820 zcmex=pQC5bm;@P_1sVSzVJKr@0Gh?ffCN|=S(%vGxC9uO7+6>s*?5^*A(BA2D;WhQ78Z*r8=IIqIu(^PHgDXVyy;NW#7PG~Frt_R(kX}`^8XeC5715~L1sY) zdxr0g3=X=%;Yw4BeG99LQrGqzdlMh<+Dw2u=+Ts~DvEn%w%iO$l#E`i{lYlvxEG{;H!l`?)%OPo6%iU8eH#(dF3ujaFYBlKorG&bgCyJt3kg z^}fmV_wq5#tLsj%Wo@W5X3Q!+SYYB@towGmr<<)+2g}m1Yl-g;uam`m97&*YcxJH|Zkz=200rfsQ_l~IRY z7hT_YC+-5vsh^)$KlRwp7qV;V^oe>FGt-{#IkxxKx7!)KHDx#DQme%b zkKKY7-eWF}InQ~h=b07haGL$I{i^>A$C$1$i$62pbw8Q${DYcb z^ULDzJ`nWx;_tJcbHKc>va0Uoe}<|9M)z7|Z`GAH+;9Fl|7!hX#%xBG7=bdS`}dgk zbu}M&c3#`SW@V!h6G!Q(sE2ze?|a15Xscmo@voTSp5@b*znA}g&G2WXZeYvlNlUb? zG=H|KDmacaz&u*0r8XVY@oZkHX1ZV+Kupuuzim;|aCq&PSm6ja{T aU%Rit(V)P=#L#g1Pv!paUmfcI-vj^#YZ+<) literal 0 HcmV?d00001 From c30dd6029f88beada07e2a1f95ff74904eb8365b Mon Sep 17 00:00:00 2001 From: "vadim.malesh" Date: Mon, 10 Aug 2020 10:11:43 +0300 Subject: [PATCH 029/104] add unit test --- .../Framework/View/Test/Unit/LayoutTest.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php b/lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php index 23f35dfab7cc8..31606b55f6519 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php @@ -19,6 +19,7 @@ use Magento\Framework\View\Element\AbstractBlock; use Magento\Framework\View\Element\Template; use Magento\Framework\View\Layout; +use Magento\Framework\View\Layout\BuilderInterface; use Magento\Framework\View\Layout\Data\Structure as LayoutStructure; use Magento\Framework\View\Layout\Element; use Magento\Framework\View\Layout\Generator\Block; @@ -1169,4 +1170,27 @@ public function renderElementDisplayDataProvider(): array [null], ]; } + + /** + * Test render element with exception + * + * @return void + */ + public function testRenderNonCachedElementWithException(): void + { + $exception = new \Exception('Error message'); + + $builderMock = $this->createMock(BuilderInterface::class); + $builderMock->expects($this->once()) + ->method('build') + ->willThrowException($exception); + + $this->loggerMock->expects($this->once()) + ->method('critical') + ->with($exception); + + $model = clone $this->model; + $model->setBuilder($builderMock); + $model->renderNonCachedElement('test_container'); + } } From 2cbe0f065ffe13ff441f1346aee77a06683c644d Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Mon, 10 Aug 2020 12:58:32 +0300 Subject: [PATCH 030/104] Fix date timestamp typo --- app/code/Magento/MediaGalleryUi/Model/UpdateAsset.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/MediaGalleryUi/Model/UpdateAsset.php b/app/code/Magento/MediaGalleryUi/Model/UpdateAsset.php index ff82b990d2a01..7712bc088f518 100644 --- a/app/code/Magento/MediaGalleryUi/Model/UpdateAsset.php +++ b/app/code/Magento/MediaGalleryUi/Model/UpdateAsset.php @@ -86,8 +86,8 @@ public function execute(int $id, MetadataInterface $data): void 'description' => $data->getDescription() ?? $asset->getDescription(), 'source' => $asset->getSource(), 'hash' => $asset->getHash(), - 'created_at' => $asset->getCreatedAt(), - 'updated_at' => $asset->getUpdatedAt() + 'createdAt' => $asset->getCreatedAt(), + 'updatedAt' => $asset->getUpdatedAt() ] ); From 34b441d10a1a8cd6efe814a53cd05d64b8d614dc Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Mon, 10 Aug 2020 13:04:51 +0300 Subject: [PATCH 031/104] Apply correct sort order --- .../Magento/MediaGalleryUi/Model/UpdateAsset.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/MediaGalleryUi/Model/UpdateAsset.php b/app/code/Magento/MediaGalleryUi/Model/UpdateAsset.php index 7712bc088f518..f81c0449306da 100644 --- a/app/code/Magento/MediaGalleryUi/Model/UpdateAsset.php +++ b/app/code/Magento/MediaGalleryUi/Model/UpdateAsset.php @@ -76,18 +76,18 @@ public function execute(int $id, MetadataInterface $data): void $updatedAsset = $this->assetFactory->create( [ + 'id' => $asset->getId(), 'path' => $asset->getPath(), - 'contentType' => $asset->getContentType(), + 'title' => $data->getTitle() ?? $asset->getTitle(), + 'description' => $data->getDescription() ?? $asset->getDescription(), + 'createdAt' => $asset->getCreatedAt(), + 'updatedAt' => $asset->getUpdatedAt(), 'width' => $asset->getWidth(), 'height' => $asset->getHeight(), 'size' => $asset->getSize(), - 'id' => $asset->getId(), - 'title' => $data->getTitle() ?? $asset->getTitle(), - 'description' => $data->getDescription() ?? $asset->getDescription(), - 'source' => $asset->getSource(), 'hash' => $asset->getHash(), - 'createdAt' => $asset->getCreatedAt(), - 'updatedAt' => $asset->getUpdatedAt() + 'contentType' => $asset->getContentType(), + 'source' => $asset->getSource() ] ); From 088b9009553413398a9cf1e1c887a9988faf69fd Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Mon, 10 Aug 2020 13:38:02 +0300 Subject: [PATCH 032/104] represent the create/updated time of database record --- .../Model/CreateAssetFromFile.php | 16 ---------------- .../Magento/MediaGalleryUi/Model/UpdateAsset.php | 2 -- 2 files changed, 18 deletions(-) diff --git a/app/code/Magento/MediaGallerySynchronization/Model/CreateAssetFromFile.php b/app/code/Magento/MediaGallerySynchronization/Model/CreateAssetFromFile.php index 3305c5e54b861..a76cb8b3b9971 100644 --- a/app/code/Magento/MediaGallerySynchronization/Model/CreateAssetFromFile.php +++ b/app/code/Magento/MediaGallerySynchronization/Model/CreateAssetFromFile.php @@ -12,7 +12,6 @@ use Magento\Framework\Filesystem; use Magento\Framework\Filesystem\Directory\ReadInterface; use Magento\Framework\Filesystem\Driver\File; -use Magento\Framework\Stdlib\DateTime\TimezoneInterface; use Magento\MediaGalleryApi\Api\Data\AssetInterface; use Magento\MediaGalleryApi\Api\Data\AssetInterfaceFactory; use Magento\MediaGalleryMetadataApi\Api\ExtractMetadataInterface; @@ -24,11 +23,6 @@ */ class CreateAssetFromFile { - /** - * Date format - */ - private const DATE_FORMAT = 'Y-m-d H:i:s'; - /** * @var Filesystem */ @@ -39,11 +33,6 @@ class CreateAssetFromFile */ private $driver; - /** - * @var TimezoneInterface; - */ - private $date; - /** * @var AssetInterfaceFactory */ @@ -67,7 +56,6 @@ class CreateAssetFromFile /** * @param Filesystem $filesystem * @param File $driver - * @param TimezoneInterface $date * @param AssetInterfaceFactory $assetFactory * @param GetContentHashInterface $getContentHash * @param ExtractMetadataInterface $extractMetadata @@ -76,7 +64,6 @@ class CreateAssetFromFile public function __construct( Filesystem $filesystem, File $driver, - TimezoneInterface $date, AssetInterfaceFactory $assetFactory, GetContentHashInterface $getContentHash, ExtractMetadataInterface $extractMetadata, @@ -84,7 +71,6 @@ public function __construct( ) { $this->filesystem = $filesystem; $this->driver = $driver; - $this->date = $date; $this->assetFactory = $assetFactory; $this->getContentHash = $getContentHash; $this->extractMetadata = $extractMetadata; @@ -112,8 +98,6 @@ public function execute(string $path): AssetInterface 'path' => $path, 'title' => $metadata->getTitle() ?: $file->getBasename('.' . $file->getExtension()), 'description' => $metadata->getDescription(), - 'createdAt' => $this->date->date($file->getCTime())->format(self::DATE_FORMAT), - 'updatedAt' => $this->date->date($file->getMTime())->format(self::DATE_FORMAT), 'width' => $width, 'height' => $height, 'hash' => $this->getHash($path), diff --git a/app/code/Magento/MediaGalleryUi/Model/UpdateAsset.php b/app/code/Magento/MediaGalleryUi/Model/UpdateAsset.php index f81c0449306da..85522c6b07e00 100644 --- a/app/code/Magento/MediaGalleryUi/Model/UpdateAsset.php +++ b/app/code/Magento/MediaGalleryUi/Model/UpdateAsset.php @@ -80,8 +80,6 @@ public function execute(int $id, MetadataInterface $data): void 'path' => $asset->getPath(), 'title' => $data->getTitle() ?? $asset->getTitle(), 'description' => $data->getDescription() ?? $asset->getDescription(), - 'createdAt' => $asset->getCreatedAt(), - 'updatedAt' => $asset->getUpdatedAt(), 'width' => $asset->getWidth(), 'height' => $asset->getHeight(), 'size' => $asset->getSize(), From 24eae9db88feed2ff4f2cd32502ed0a71c3ed5da Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Mon, 10 Aug 2020 15:15:44 +0300 Subject: [PATCH 033/104] Cover changes with mftf tests --- ...tedAtNotEqualsUpdatedAtTimeActionGroup.xml | 24 +++++++++++++++++++ ...UploadedImageDateTimeEqualsActionGroup.xml | 24 +++++++++++++++++++ ...EnhancedMediaGalleryViewDetailsSection.xml | 2 ++ ...daloneMediaGalleryEditImageDetailsTest.xml | 5 ++++ 4 files changed, 55 insertions(+) create mode 100644 app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryVerifyImageCreatedAtNotEqualsUpdatedAtTimeActionGroup.xml create mode 100644 app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryVerifyUploadedImageDateTimeEqualsActionGroup.xml diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryVerifyImageCreatedAtNotEqualsUpdatedAtTimeActionGroup.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryVerifyImageCreatedAtNotEqualsUpdatedAtTimeActionGroup.xml new file mode 100644 index 0000000000000..248c6de468193 --- /dev/null +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryVerifyImageCreatedAtNotEqualsUpdatedAtTimeActionGroup.xml @@ -0,0 +1,24 @@ + + + + + + + Assert that created_at updated_at time NOT equals + + + + + + grabCreatedTime + grabModifietTime + + + + diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryVerifyUploadedImageDateTimeEqualsActionGroup.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryVerifyUploadedImageDateTimeEqualsActionGroup.xml new file mode 100644 index 0000000000000..f26931f08586f --- /dev/null +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryVerifyUploadedImageDateTimeEqualsActionGroup.xml @@ -0,0 +1,24 @@ + + + + + + + Assert that created_at updated_at time are the same for newly uploaded image + + + + + + grabCreatedTime + grabModifietTime + + + + diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/Section/AdminEnhancedMediaGalleryViewDetailsSection.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/Section/AdminEnhancedMediaGalleryViewDetailsSection.xml index 0bcbeb0d7a00f..c2bf6e8f29661 100644 --- a/app/code/Magento/MediaGalleryUi/Test/Mftf/Section/AdminEnhancedMediaGalleryViewDetailsSection.xml +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/Section/AdminEnhancedMediaGalleryViewDetailsSection.xml @@ -18,6 +18,8 @@ + +
diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminStandaloneMediaGalleryEditImageDetailsTest.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminStandaloneMediaGalleryEditImageDetailsTest.xml index ede3a452e4ca5..c5247dc21ec63 100644 --- a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminStandaloneMediaGalleryEditImageDetailsTest.xml +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminStandaloneMediaGalleryEditImageDetailsTest.xml @@ -29,6 +29,10 @@ + + + + @@ -40,6 +44,7 @@ + From 8d9d0a5ec0d16701c9fd391ce7c302d747e3d165 Mon Sep 17 00:00:00 2001 From: yolouiese Date: Mon, 10 Aug 2020 22:03:50 +0800 Subject: [PATCH 034/104] magento/magento2#1703: The deleted tags are not removed from Tags drop-down until the web page is refreshed - covered MFTF test --- ...ancedMediaGalleryVerifyUpdatedTagsTest.xml | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminEnhancedMediaGalleryVerifyUpdatedTagsTest.xml diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminEnhancedMediaGalleryVerifyUpdatedTagsTest.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminEnhancedMediaGalleryVerifyUpdatedTagsTest.xml new file mode 100644 index 0000000000000..3672f582b0877 --- /dev/null +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminEnhancedMediaGalleryVerifyUpdatedTagsTest.xml @@ -0,0 +1,45 @@ + + + + + + + + + + <stories value="User checks if the deleted tags are removed from Edit page, Tags field"/> + <testCaseId value="https://studio.cucumber.io/projects/131313/test-plan/folders/1337102/scenarios/5064888"/> + <description value="User checks if changes made on the tags are updated from Edit page, Tags field"/> + <severity value="CRITICAL"/> + <group value="media_gallery_ui"/> + </annotations> + <before> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openMediaGallery"/> + </before> + <after> + <actionGroup ref="AdminEnhancedMediaGalleryImageDetailsDeleteActionGroup" stepKey="deleteImage"/> + </after> + <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadImage"> + <argument name="image" value="ImageUpload"/> + </actionGroup> + <actionGroup ref="AdminEnhancedMediaGalleryImageDetailsEditActionGroup" stepKey="editImage"/> + <actionGroup ref="AdminMediaGalleryEditAssetAddKeywordActionGroup" stepKey="setKeywords"> + <argument name="keyword" value="UpdatedImageDetails.keyword"/> + </actionGroup> + <actionGroup ref="AdminEnhancedMediaGalleryImageDetailsSaveActionGroup" stepKey="saveImage"> + <argument name="image" value="UpdatedImageDetails"/> + </actionGroup> + <actionGroup ref="AdminEnhancedMediaGalleryVerifyImageKeywordsActionGroup" stepKey="verifyAddedKeywords"> + <argument name="keywords" value="UpdatedImageDetails.keyword"/> + </actionGroup> + <actionGroup ref="AdminEnhancedMediaGalleryVerifyImageKeywordsActionGroup" stepKey="verifyMetadataKeywords"> + <argument name="keywords" value="ImageMetadata.keywords"/> + </actionGroup> + </test> +</tests> From 9cf55e57f115486d44f448976ffabd8ee10cce5a Mon Sep 17 00:00:00 2001 From: jekabs <jekabs@developers-alliance.com> Date: Mon, 10 Aug 2020 18:09:48 +0300 Subject: [PATCH 035/104] magento/web-api-test-recursive-array-comparison -Added a function to WebApi Test framework for recursively comparing two arrays -Modified CategoryManagementTest to remove need for array_replace_recursive --- .../TestFramework/TestCase/WebapiAbstract.php | 56 +++++++++++++++++++ .../Catalog/Api/CategoryManagementTest.php | 4 +- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php index 7ccab097d7778..91be839aa56cb 100644 --- a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php +++ b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php @@ -766,4 +766,60 @@ protected function assertWebApiCallErrors(array $serviceInfo, array $data, array } } } + + /** + * Compare arrays recursively regardless of nesting. + * Can compare arrays that have both one level and n-level nesting. + * ``` + * [ + * 'products' => [ + * 'items' => [ + * [ + * 'sku' => 'bundle-product', + * 'type_id' => 'bundle', + * 'items' => [ + * [ + * 'title' => 'Bundle Product Items', + * 'sku' => 'bundle-product', + * 'options' => [ + * [ + * 'price' => 2.75, + * 'label' => 'Simple Product', + * 'product' => [ + * 'name' => 'Simple Product', + * 'sku' => 'simple', + * ] + * ] + * ] + * ] + * ]; + * ``` + * + * @param array $expected + * @param array $actual + * @return array + */ + public function compareArraysRecursively(array $expected, array $actual): array + { + $diffResult = []; + + foreach ($expected as $key => $value) { + if (array_key_exists($key, $actual)) { + if (is_array($value)) { + $recursiveDiff = $this->compareArraysRecursively($value, $actual[$key]); + if (!empty($recursiveDiff)) { + $diffResult[$key] = $recursiveDiff; + } + } else { + if (!in_array($value, $actual, true)) { + $diffResult[$key] = $value; + } + } + } else { + $diffResult[$key] = $value; + } + } + + return $diffResult; + } } diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryManagementTest.php index bc3869df6a65b..965b920319994 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryManagementTest.php @@ -40,8 +40,8 @@ public function testTree($rootCategoryId, $depth, $expected) ] ]; $result = $this->_webApiCall($serviceInfo, $requestData); - $expected = array_replace_recursive($result, $expected); - $this->assertEquals($expected, $result); + $diff = $this->compareArraysRecursively($expected, $result); + self::assertEquals([], $diff, "Actual categories response doesn't equal expected data"); } /** From 8e011b65f9b969a70bb2d75428f81117ebf36247 Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Mon, 10 Aug 2020 20:16:47 +0300 Subject: [PATCH 036/104] created new action group for click button --- ...stCheckoutUsingFreeShippingAndTaxesTest.xml | 3 +-- .../AdminClickButtonAddTaxRuleActionGroup.xml | 18 ++++++++++++++++++ .../Test/AdminCreateDefaultsTaxRuleTest.xml | 3 +-- .../Test/AdminCreateTaxRateLargeRateTest.xml | 2 +- .../AdminCreateTaxRateSpecificPostcodeTest.xml | 2 +- ...AdminCreateTaxRateWiderZipCodeRangeTest.xml | 2 +- .../AdminCreateTaxRateZipCodeRangeTest.xml | 2 +- ...xRuleWithCustomerAndProductTaxClassTest.xml | 3 +-- ...axRateAndCustomerAndProductTaxClassTest.xml | 3 +-- ...eTaxRuleWithNewTaxClassesAndTaxRateTest.xml | 3 +-- .../AdminCreateTaxRuleWithZipRangeTest.xml | 3 +-- .../Test/Mftf/Test/DeleteTaxRateEntityTest.xml | 3 +-- 12 files changed, 29 insertions(+), 18 deletions(-) create mode 100644 app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminClickButtonAddTaxRuleActionGroup.xml diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml index 1ce48bd8bf408..7ace592b7ae73 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml @@ -120,8 +120,7 @@ <!-- Create a Tax Rule --> <actionGroup ref="AdminTaxRuleGridOpenPageActionGroup" stepKey="goToTaxRuleIndex1"/> - <click selector="{{AdminTaxRuleGridSection.add}}" stepKey="clickAddNewTaxRuleButton"/> - <waitForPageLoad stepKey="waitForTaxRuleIndex2"/> + <actionGroup ref="AdminClickButtonAddTaxRuleActionGroup" stepKey="clickAddNewTaxRuleButton"/> <!-- Create a tax rule with defaults --> <fillField selector="{{AdminTaxRuleFormSection.code}}" userInput="{{SimpleTaxRule.code}}" stepKey="fillTaxRuleCode1"/> diff --git a/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminClickButtonAddTaxRuleActionGroup.xml b/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminClickButtonAddTaxRuleActionGroup.xml new file mode 100644 index 0000000000000..313c4c5e84af0 --- /dev/null +++ b/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminClickButtonAddTaxRuleActionGroup.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminClickButtonAddTaxRuleActionGroup"> + <annotations> + <description>Click button for creating new tax rule.</description> + </annotations> + <click selector="{{AdminTaxRuleGridSection.add}}" stepKey="clickAddNewTaxRuleButton"/> + <waitForPageLoad stepKey="waitForTaxRuleGridLoad"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateDefaultsTaxRuleTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateDefaultsTaxRuleTest.xml index 07968c281c68b..9629740f1cd20 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateDefaultsTaxRuleTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateDefaultsTaxRuleTest.xml @@ -30,8 +30,7 @@ </after> <actionGroup ref="AdminTaxRuleGridOpenPageActionGroup" stepKey="goToTaxRuleIndex1"/> - <click selector="{{AdminTaxRuleGridSection.add}}" stepKey="clickAddNewTaxRuleButton"/> - <waitForPageLoad stepKey="waitForTaxRuleIndex2"/> + <actionGroup ref="AdminClickButtonAddTaxRuleActionGroup" stepKey="clickAddNewTaxRuleButton"/> <!-- Create a tax rule with defaults --> <fillField selector="{{AdminTaxRuleFormSection.code}}" userInput="{{SimpleTaxRule.code}}" stepKey="fillTaxRuleCode1"/> <fillField selector="{{AdminTaxRuleFormSection.taxRateSearch}}" userInput="$$initialTaxRate.code$$" stepKey="fillTaxRateSearch"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateLargeRateTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateLargeRateTest.xml index c8e4defc40c9f..641278d02e726 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateLargeRateTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateLargeRateTest.xml @@ -59,7 +59,7 @@ <!-- Verify we see expected values on the tax rule form page --> <actionGroup ref="AdminTaxRuleGridOpenPageActionGroup" stepKey="goToTaxRuleIndex1"/> - <click selector="{{AdminTaxRuleGridSection.add}}" stepKey="clickAdd"/> + <actionGroup ref="AdminClickButtonAddTaxRuleActionGroup" stepKey="clickAdd"/> <see selector="{{AdminTaxRulesSection.taxRateMultiSelectItems}}" userInput="{{SimpleTaxRate.code}}" stepKey="seeTaxRateOnNewTaxRulePage"/> </test> </tests> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateSpecificPostcodeTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateSpecificPostcodeTest.xml index c6a5a6c69e788..f454ceced7a3d 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateSpecificPostcodeTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateSpecificPostcodeTest.xml @@ -58,7 +58,7 @@ <!-- Verify we see expected values on the tax rule form page --> <actionGroup ref="AdminTaxRuleGridOpenPageActionGroup" stepKey="goToTaxRuleIndex1"/> - <click selector="{{AdminTaxRuleGridSection.add}}" stepKey="clickAdd"/> + <actionGroup ref="AdminClickButtonAddTaxRuleActionGroup" stepKey="clickAdd"/> <see selector="{{AdminTaxRulesSection.taxRateMultiSelectItems}}" userInput="{{SimpleTaxRate.code}}" stepKey="seeTaxRateOnNewTaxRulePage"/> </test> </tests> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateWiderZipCodeRangeTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateWiderZipCodeRangeTest.xml index ef9b66041893d..9712a605a5bf4 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateWiderZipCodeRangeTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateWiderZipCodeRangeTest.xml @@ -60,7 +60,7 @@ <!-- Verify we see expected values on the tax rule form page --> <actionGroup ref="AdminTaxRuleGridOpenPageActionGroup" stepKey="goToTaxRuleIndex1"/> - <click selector="{{AdminTaxRuleGridSection.add}}" stepKey="clickAdd"/> + <actionGroup ref="AdminClickButtonAddTaxRuleActionGroup" stepKey="clickAdd"/> <see selector="{{AdminTaxRulesSection.taxRateMultiSelectItems}}" userInput="{{SimpleTaxRate.code}}" stepKey="seeTaxRateOnNewTaxRulePage"/> </test> </tests> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml index 23c4ffd78a88d..2734a57aa312c 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml @@ -62,7 +62,7 @@ <!-- Verify we see expected values on the tax rule form page --> <actionGroup ref="AdminTaxRuleGridOpenPageActionGroup" stepKey="goToTaxRuleIndex1"/> - <click selector="{{AdminTaxRuleGridSection.add}}" stepKey="clickAdd"/> + <actionGroup ref="AdminClickButtonAddTaxRuleActionGroup" stepKey="clickAdd"/> <see selector="{{AdminTaxRulesSection.taxRateMultiSelectItems}}" userInput="{{SimpleTaxRate.code}}" stepKey="seeTaxRateOnNewTaxRulePage"/> </test> </tests> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithCustomerAndProductTaxClassTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithCustomerAndProductTaxClassTest.xml index ba0834da7c0e7..c309db52cb194 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithCustomerAndProductTaxClassTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithCustomerAndProductTaxClassTest.xml @@ -40,8 +40,7 @@ </after> <actionGroup ref="AdminTaxRuleGridOpenPageActionGroup" stepKey="goToTaxRuleIndex1"/> - <click selector="{{AdminTaxRuleGridSection.add}}" stepKey="clickAddNewTaxRuleButton"/> - <waitForPageLoad stepKey="waitForTaxRuleIndex2"/> + <actionGroup ref="AdminClickButtonAddTaxRuleActionGroup" stepKey="clickAddNewTaxRuleButton"/> <!-- Create a tax rule with customer and product class --> <fillField selector="{{AdminTaxRuleFormSection.code}}" userInput="{{SimpleTaxRule.code}}" stepKey="fillTaxRuleCode1"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithNewAndExistingTaxRateAndCustomerAndProductTaxClassTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithNewAndExistingTaxRateAndCustomerAndProductTaxClassTest.xml index ae37bc8a8930a..2aaebb0ca5c3e 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithNewAndExistingTaxRateAndCustomerAndProductTaxClassTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithNewAndExistingTaxRateAndCustomerAndProductTaxClassTest.xml @@ -41,8 +41,7 @@ </after> <actionGroup ref="AdminTaxRuleGridOpenPageActionGroup" stepKey="goToTaxRuleIndex1"/> - <click selector="{{AdminTaxRuleGridSection.add}}" stepKey="clickAddNewTaxRuleButton"/> - <waitForPageLoad stepKey="waitForTaxRuleIndex2"/> + <actionGroup ref="AdminClickButtonAddTaxRuleActionGroup" stepKey="clickAddNewTaxRuleButton"/> <!-- Create a tax rule with new and existing tax rate, customer tax class, product tax class --> <fillField selector="{{AdminTaxRuleFormSection.code}}" userInput="{{SimpleTaxRule.code}}" stepKey="fillTaxRuleCode1"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithNewTaxClassesAndTaxRateTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithNewTaxClassesAndTaxRateTest.xml index 2a008991c2dc8..d0e9242f3618b 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithNewTaxClassesAndTaxRateTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithNewTaxClassesAndTaxRateTest.xml @@ -41,8 +41,7 @@ </after> <actionGroup ref="AdminTaxRuleGridOpenPageActionGroup" stepKey="goToTaxRuleIndex1"/> - <click selector="{{AdminTaxRuleGridSection.add}}" stepKey="clickAddNewTaxRuleButton"/> - <waitForPageLoad stepKey="waitForTaxRuleIndex2"/> + <actionGroup ref="AdminClickButtonAddTaxRuleActionGroup" stepKey="clickAddNewTaxRuleButton"/> <!-- Create a tax rule with new tax classes and tax rate --> <fillField selector="{{AdminTaxRuleFormSection.code}}" userInput="{{SimpleTaxRule.code}}" stepKey="fillTaxRuleCode1"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithZipRangeTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithZipRangeTest.xml index de55453fcabc4..0c324f137b84f 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithZipRangeTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithZipRangeTest.xml @@ -41,8 +41,7 @@ </after> <actionGroup ref="AdminTaxRuleGridOpenPageActionGroup" stepKey="goToTaxRuleIndex1"/> - <click selector="{{AdminTaxRuleGridSection.add}}" stepKey="clickAddNewTaxRuleButton"/> - <waitForPageLoad stepKey="waitForTaxRuleIndex2"/> + <actionGroup ref="AdminClickButtonAddTaxRuleActionGroup" stepKey="clickAddNewTaxRuleButton"/> <!-- Create a tax rule with new tax classes and tax rate --> <fillField selector="{{AdminTaxRuleFormSection.code}}" userInput="{{SimpleTaxRule.code}}" stepKey="fillTaxRuleCode1"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/DeleteTaxRateEntityTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/DeleteTaxRateEntityTest.xml index 881e09e5e35f4..99d9d12d7d182 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/DeleteTaxRateEntityTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/DeleteTaxRateEntityTest.xml @@ -44,8 +44,7 @@ <!-- Confirm Deleted TaxIdentifier on the tax rule grid page --> <actionGroup ref="AdminTaxRuleGridOpenPageActionGroup" stepKey="goToTaxRuleIndex3"/> - <click selector="{{AdminTaxRuleGridSection.add}}" stepKey="clickAddNewTaxRuleButton"/> - <waitForPageLoad stepKey="waitForTaxRuleIndex1"/> + <actionGroup ref="AdminClickButtonAddTaxRuleActionGroup" stepKey="clickAddNewTaxRuleButton"/> <fillField selector="{{AdminTaxRuleFormSection.taxRateSearch}}" userInput="$$initialTaxRate.code$$" stepKey="fillTaxRateSearch"/> <wait stepKey="waitForSearch" time="5" /> <dontSee selector="{{AdminTaxRuleFormSection.fieldTaxRate}}" userInput="$$initialTaxRate.code$$" stepKey="dontSeeInTaxRuleForm"/> From 5a500f352734a22f8c0464d400130a8250a633e9 Mon Sep 17 00:00:00 2001 From: joweecaquicla <joie@abovethefray.io> Date: Tue, 11 Aug 2020 01:59:52 +0800 Subject: [PATCH 037/104] magento/adobe-stock-integration#1727: Introduce internal class wrapping SplFileInfo - implement class wrapping SplFileInfo and modified the files to use the newly added classes --- .../Model/CreateAssetFromFile.php | 14 +- .../Model/Filesystem/FileInfo.php | 296 ++++++++++++++++++ .../Model/Filesystem/GetFileInfo.php | 63 ++++ .../Model/GetAssetFromPath.php | 11 +- .../Model/SynchronizeFiles.php | 14 +- 5 files changed, 374 insertions(+), 24 deletions(-) create mode 100644 app/code/Magento/MediaGallerySynchronization/Model/Filesystem/FileInfo.php create mode 100644 app/code/Magento/MediaGallerySynchronization/Model/Filesystem/GetFileInfo.php diff --git a/app/code/Magento/MediaGallerySynchronization/Model/CreateAssetFromFile.php b/app/code/Magento/MediaGallerySynchronization/Model/CreateAssetFromFile.php index 87d477507b680..6f1f05a750085 100644 --- a/app/code/Magento/MediaGallerySynchronization/Model/CreateAssetFromFile.php +++ b/app/code/Magento/MediaGallerySynchronization/Model/CreateAssetFromFile.php @@ -16,7 +16,7 @@ use Magento\MediaGalleryApi\Api\Data\AssetInterface; use Magento\MediaGalleryApi\Api\Data\AssetInterfaceFactory; use Magento\MediaGalleryMetadataApi\Api\ExtractMetadataInterface; -use Magento\MediaGallerySynchronization\Model\Filesystem\SplFileInfoFactory; +use Magento\MediaGallerySynchronization\Model\Filesystem\GetFileInfo; use Magento\MediaGallerySynchronization\Model\GetContentHash; /** @@ -60,9 +60,9 @@ class CreateAssetFromFile private $extractMetadata; /** - * @var SplFileInfoFactory + * @var GetFileInfo */ - private $splFileInfoFactory; + private $getFileInfo; /** * @param Filesystem $filesystem @@ -71,7 +71,7 @@ class CreateAssetFromFile * @param AssetInterfaceFactory $assetFactory * @param GetContentHash $getContentHash * @param ExtractMetadataInterface $extractMetadata - * @param SplFileInfoFactory $splFileInfoFactory + * @param GetFileInfo $getFileInfo */ public function __construct( Filesystem $filesystem, @@ -80,7 +80,7 @@ public function __construct( AssetInterfaceFactory $assetFactory, GetContentHash $getContentHash, ExtractMetadataInterface $extractMetadata, - SplFileInfoFactory $splFileInfoFactory + GetFileInfo $getFileInfo ) { $this->filesystem = $filesystem; $this->driver = $driver; @@ -88,7 +88,7 @@ public function __construct( $this->assetFactory = $assetFactory; $this->getContentHash = $getContentHash; $this->extractMetadata = $extractMetadata; - $this->splFileInfoFactory = $splFileInfoFactory; + $this->getFileInfo = $getFileInfo; } /** @@ -101,7 +101,7 @@ public function __construct( public function execute(string $path): AssetInterface { $absolutePath = $this->getMediaDirectory()->getAbsolutePath($path); - $file = $this->splFileInfoFactory->create($absolutePath); + $file = $this->getFileInfo->execute($absolutePath); [$width, $height] = getimagesize($absolutePath); $metadata = $this->extractMetadata->execute($absolutePath); diff --git a/app/code/Magento/MediaGallerySynchronization/Model/Filesystem/FileInfo.php b/app/code/Magento/MediaGallerySynchronization/Model/Filesystem/FileInfo.php new file mode 100644 index 0000000000000..20acefe4ab034 --- /dev/null +++ b/app/code/Magento/MediaGallerySynchronization/Model/Filesystem/FileInfo.php @@ -0,0 +1,296 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallerySynchronization\Model\Filesystem; + +/** + * Class FileInfo + */ +class FileInfo extends \SplFileInfo +{ + /** + * @var string + */ + private $path; + + /** + * @var string + */ + private $filename; + + /** + * @var string + */ + private $extension; + + /** + * @var $basename + */ + private $basename; + + /** + * @var string + */ + private $pathname; + + /** + * @var int + */ + private $perms; + + /** + * @var int + */ + private $inode; + + /** + * @var int + */ + private $size; + + /** + * @var int + */ + private $owner; + + /** + * @var int + */ + private $group; + + /** + * @var int + */ + private $aTime; + + /** + * @var int + */ + private $mTime; + + /** + * @var int + */ + private $cTime; + + /** + * @var string + */ + private $type; + + /** + * @var false|string + */ + private $realPath; + + /** + * @var \SplFileInfo + */ + private $fileInfo; + + /** + * @var \SplFileInfo + */ + private $pathInfo; + + /** + * FileInfo constructor. + * @param string $file_name + * @param string $path + * @param string $filename + * @param string $extension + * @param string $basename + * @param string $pathname + * @param int $perms + * @param int $inode + * @param int $size + * @param int $owner + * @param int $group + * @param int $aTime + * @param int $mTime + * @param int $cTime + * @param string $type + * @param false|string $realPath + * @param \SplFileInfo $fileInfo + * @param \SplFileInfo $pathInfo + */ + public function __construct( + string $file_name, + string $path, + string $filename, + string $extension, + string $basename, + string $pathname, + int $perms, + int $inode, + int $size, + int $owner, + int $group, + int $aTime, + int $mTime, + int $cTime, + string $type, + $realPath, + \SplFileInfo $fileInfo, + \SplFileInfo $pathInfo + ) { + parent::__construct($file_name); + $this->path = $path; + $this->filename = $filename; + $this->extension = $extension; + $this->basename = $basename; + $this->pathname = $pathname; + $this->perms = $perms; + $this->inode = $inode; + $this->size = $size; + $this->owner = $owner; + $this->group = $group; + $this->aTime = $aTime; + $this->mTime = $mTime; + $this->cTime = $cTime; + $this->type = $type; + $this->realPath = $realPath; + $this->fileInfo = $fileInfo; + $this->pathInfo = $pathInfo; + } + + /** + * @inheritDoc + */ + public function getPath(): string + { + return $this->path; + } + + /** + * @inheritDoc + */ + public function getFilename(): string + { + return $this->filename; + } + + /** + * @inheritDoc + */ + public function getExtension(): string + { + return $this->extension; + } + + /** + * @inheritDoc + */ + public function getBasename($suffix = null): string + { + return $this->basename; + } + + /** + * @inheritDoc + */ + public function getPathname(): string + { + return $this->pathname; + } + + /** + * @inheritDoc + */ + public function getPerms(): int + { + return $this->perms; + } + + /** + * @inheritDoc + */ + public function getInode(): int + { + return $this->inode; + } + + /** + * @inheritDoc + */ + public function getSize(): int + { + return $this->size; + } + + /** + * @inheritDoc + */ + public function getOwner(): int + { + return $this->owner; + } + + /** + * @inheritDoc + */ + public function getGroup(): int + { + return $this->group; + } + + /** + * @inheritDoc + */ + public function getATime(): int + { + return $this->aTime; + } + + /** + * @inheritDoc + */ + public function getMTime(): int + { + return $this->mTime; + } + + /** + * @inheritDoc + */ + public function getCTime(): int + { + return $this->cTime; + } + + /** + * @inheritDoc + */ + public function getType(): string + { + return $this->type; + } + + /** + * @inheritDoc + */ + public function getRealPath() + { + return $this->realPath; + } + + /** + * @inheritDoc + */ + public function getFileInfo($class_name = null): \SplFileInfo + { + return $this->fileInfo; + } + + /** + * @inheritDoc + */ + public function getPathInfo($class_name = null): \SplFileInfo + { + return $this->pathInfo; + } +} diff --git a/app/code/Magento/MediaGallerySynchronization/Model/Filesystem/GetFileInfo.php b/app/code/Magento/MediaGallerySynchronization/Model/Filesystem/GetFileInfo.php new file mode 100644 index 0000000000000..ef382732275bd --- /dev/null +++ b/app/code/Magento/MediaGallerySynchronization/Model/Filesystem/GetFileInfo.php @@ -0,0 +1,63 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallerySynchronization\Model\Filesystem; + +use Magento\MediaGallerySynchronization\Model\Filesystem\FileInfoFactory; + +/** + * Get file information + */ +class GetFileInfo +{ + /** + * @var FileInfoFactory + */ + private $fileInfoFactory; + + /** + * GetFileInfo constructor. + * @param FileInfoFactory $fileInfoFactory + */ + public function __construct( + FileInfoFactory $fileInfoFactory + ) { + $this->fileInfoFactory = $fileInfoFactory; + } + + /** + * Get file information based on path provided. + * + * @param string $path + * @return FileInfo + */ + public function execute(string $path): FileInfo + { + $splFileInfo = new \SplFileInfo($path); + + return $this->fileInfoFactory->create([ + 'file_name' => $path, + 'path' => $splFileInfo->getPath(), + 'filename' => $splFileInfo->getFilename(), + 'extension' => $splFileInfo->getExtension(), + 'basename' => $splFileInfo->getBasename(), + 'pathname' => $splFileInfo->getPathname(), + 'perms' => $splFileInfo->getPerms(), + 'inode' => $splFileInfo->getInode(), + 'size' => $splFileInfo->getSize(), + 'owner' => $splFileInfo->getOwner(), + 'group' => $splFileInfo->getGroup(), + 'aTime' => $splFileInfo->getATime(), + 'mTime' => $splFileInfo->getMTime(), + 'cTime' => $splFileInfo->getCTime(), + 'type' => $splFileInfo->getType(), + 'realPath' => $splFileInfo->getRealPath(), + 'fileInfo' => $splFileInfo->getFileInfo(), + 'pathInfo' => $splFileInfo->getPathInfo() + ]); + } +} diff --git a/app/code/Magento/MediaGallerySynchronization/Model/GetAssetFromPath.php b/app/code/Magento/MediaGallerySynchronization/Model/GetAssetFromPath.php index 5e825d57c5ce7..533d814c9f1d0 100644 --- a/app/code/Magento/MediaGallerySynchronization/Model/GetAssetFromPath.php +++ b/app/code/Magento/MediaGallerySynchronization/Model/GetAssetFromPath.php @@ -12,7 +12,6 @@ use Magento\MediaGalleryApi\Api\Data\AssetInterface; use Magento\MediaGalleryApi\Api\Data\AssetInterfaceFactory; use Magento\MediaGalleryApi\Api\GetAssetsByPathsInterface; -use Magento\MediaGallerySynchronization\Model\Filesystem\SplFileInfoFactory; /** * Create media asset object based on the file information @@ -34,27 +33,19 @@ class GetAssetFromPath */ private $createAssetFromFile; - /** - * @var SplFileInfoFactory - */ - private $splFileInfoFactory; - /** * @param AssetInterfaceFactory $assetFactory * @param GetAssetsByPathsInterface $getMediaGalleryAssetByPath * @param CreateAssetFromFile $createAssetFromFile - * @param SplFileInfoFactory $splFileInfoFactory */ public function __construct( AssetInterfaceFactory $assetFactory, GetAssetsByPathsInterface $getMediaGalleryAssetByPath, - CreateAssetFromFile $createAssetFromFile, - SplFileInfoFactory $splFileInfoFactory + CreateAssetFromFile $createAssetFromFile ) { $this->assetFactory = $assetFactory; $this->getAssetsByPaths = $getMediaGalleryAssetByPath; $this->createAssetFromFile = $createAssetFromFile; - $this->splFileInfoFactory= $splFileInfoFactory; } /** diff --git a/app/code/Magento/MediaGallerySynchronization/Model/SynchronizeFiles.php b/app/code/Magento/MediaGallerySynchronization/Model/SynchronizeFiles.php index 81e9629f703f3..eebb172e48202 100644 --- a/app/code/Magento/MediaGallerySynchronization/Model/SynchronizeFiles.php +++ b/app/code/Magento/MediaGallerySynchronization/Model/SynchronizeFiles.php @@ -16,7 +16,7 @@ use Magento\MediaGalleryApi\Api\GetAssetsByPathsInterface; use Magento\MediaGallerySynchronizationApi\Model\ImportFilesInterface; use Magento\MediaGallerySynchronizationApi\Api\SynchronizeFilesInterface; -use Magento\MediaGallerySynchronization\Model\Filesystem\SplFileInfoFactory; +use Magento\MediaGallerySynchronization\Model\Filesystem\GetFileInfo; use Psr\Log\LoggerInterface; /** @@ -50,9 +50,9 @@ class SynchronizeFiles implements SynchronizeFilesInterface private $driver; /** - * @var SplFileInfoFactory + * @var GetFileInfo */ - private $splFileInfoFactory; + private $getFileInfo; /** * @var ImportFilesInterface @@ -69,7 +69,7 @@ class SynchronizeFiles implements SynchronizeFilesInterface * @param Filesystem $filesystem * @param DateTime $date * @param LoggerInterface $log - * @param SplFileInfoFactory $splFileInfoFactory + * @param GetFileInfo $getFileInfo * @param GetAssetsByPathsInterface $getAssetsByPaths * @param ImportFilesInterface $importFiles */ @@ -78,7 +78,7 @@ public function __construct( Filesystem $filesystem, DateTime $date, LoggerInterface $log, - SplFileInfoFactory $splFileInfoFactory, + GetFileInfo $getFileInfo, GetAssetsByPathsInterface $getAssetsByPaths, ImportFilesInterface $importFiles ) { @@ -86,7 +86,7 @@ public function __construct( $this->filesystem = $filesystem; $this->date = $date; $this->log = $log; - $this->splFileInfoFactory = $splFileInfoFactory; + $this->getFileInfo = $getFileInfo; $this->getAssetsByPaths = $getAssetsByPaths; $this->importFiles = $importFiles; } @@ -150,7 +150,7 @@ private function getFileModificationTime(string $path): string { return $this->date->gmtDate( self::DATE_FORMAT, - $this->splFileInfoFactory->create($this->getMediaDirectory()->getAbsolutePath($path))->getMTime() + $this->getFileInfo->execute($this->getMediaDirectory()->getAbsolutePath($path))->getMTime() ); } From ef2b9c48f0586d435e5dcc9cb18ef630eec84b4f Mon Sep 17 00:00:00 2001 From: Ievgen Kolesov <ikolesov@adobe.com> Date: Mon, 10 Aug 2020 13:17:12 -0500 Subject: [PATCH 038/104] PWA-805: Expose localization system / store config from GraphQL --- app/code/Magento/StoreGraphQl/etc/schema.graphqls | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/StoreGraphQl/etc/schema.graphqls b/app/code/Magento/StoreGraphQl/etc/schema.graphqls index cf50041bb9bea..1106987cc72c1 100644 --- a/app/code/Magento/StoreGraphQl/etc/schema.graphqls +++ b/app/code/Magento/StoreGraphQl/etc/schema.graphqls @@ -3,7 +3,7 @@ type Query { storeConfig : StoreConfig @resolver(class: "Magento\\StoreGraphQl\\Model\\Resolver\\StoreConfigResolver") @doc(description: "The store config query") @cache(cacheable: false) availableStores( - useCurrentGroup: Boolean @doc(description: "Get only store views from the current store group") + useCurrentGroup: Boolean @doc(description: "Filter store views by current store group") ): [StoreConfig] @resolver(class: "Magento\\StoreGraphQl\\Model\\Resolver\\AvailableStoresResolver") @doc(description: "Get a list of available store views and their config information.") } @@ -34,5 +34,5 @@ type StoreConfig @doc(description: "The type contains information about a store secure_base_static_url : String @doc(description: "Secure base static URL for the store") secure_base_media_url : String @doc(description: "Secure base media URL for the store") store_name : String @doc(description: "Name of the store") - use_store_in_url: Boolean @doc(description: "Indicates whether store code is used in url") + use_store_in_url: Boolean @doc(description: "The configuration determines if the store code should be used in the URL") } From 0f6e4350d777127ccbf3e423e81d7bcefa4debe6 Mon Sep 17 00:00:00 2001 From: Dave Macaulay <macaulay@adobe.com> Date: Mon, 10 Aug 2020 16:25:52 -0500 Subject: [PATCH 039/104] PWA-806: Localize emails sent through GraphQL application - Emulate correct store around email sends through GraphQL --- .../HttpHeaderProcessor/StoreProcessor.php | 26 +------ .../StoreGraphQl/Plugin/LocalizeEmail.php | 78 +++++++++++++++++++ .../StoreGraphQl/Plugin/StoreResolver.php | 44 ----------- .../Magento/StoreGraphQl/etc/graphql/di.xml | 4 +- 4 files changed, 81 insertions(+), 71 deletions(-) create mode 100644 app/code/Magento/StoreGraphQl/Plugin/LocalizeEmail.php delete mode 100644 app/code/Magento/StoreGraphQl/Plugin/StoreResolver.php diff --git a/app/code/Magento/StoreGraphQl/Controller/HttpHeaderProcessor/StoreProcessor.php b/app/code/Magento/StoreGraphQl/Controller/HttpHeaderProcessor/StoreProcessor.php index 66800520eb4cb..7999a96917cde 100644 --- a/app/code/Magento/StoreGraphQl/Controller/HttpHeaderProcessor/StoreProcessor.php +++ b/app/code/Magento/StoreGraphQl/Controller/HttpHeaderProcessor/StoreProcessor.php @@ -7,10 +7,6 @@ namespace Magento\StoreGraphQl\Controller\HttpHeaderProcessor; -use Magento\Framework\App\AreaInterface; -use Magento\Framework\App\AreaList; -use Magento\Framework\App\ObjectManager; -use Magento\Framework\App\State; use Magento\GraphQl\Controller\HttpHeaderProcessorInterface; use Magento\Store\Model\StoreManagerInterface; use Magento\Framework\App\Http\Context as HttpContext; @@ -36,35 +32,19 @@ class StoreProcessor implements HttpHeaderProcessorInterface */ private $storeCookieManager; - /** - * @var AreaList - */ - private $areaList; - - /** - * @var State - */ - private $appState; - /** * @param StoreManagerInterface $storeManager * @param HttpContext $httpContext * @param StoreCookieManagerInterface $storeCookieManager - * @param AreaList $areaList - * @param State $appState */ public function __construct( StoreManagerInterface $storeManager, HttpContext $httpContext, - StoreCookieManagerInterface $storeCookieManager, - AreaList $areaList = null, - State $appState = null + StoreCookieManagerInterface $storeCookieManager ) { $this->storeManager = $storeManager; $this->httpContext = $httpContext; $this->storeCookieManager = $storeCookieManager; - $this->areaList = $areaList ?? ObjectManager::getInstance()->get(AreaList::class); - $this->appState = $appState ?? ObjectManager::getInstance()->get(State::class); } /** @@ -87,10 +67,6 @@ public function processHeaderValue(string $headerValue) : void $this->storeManager->setCurrentStore($storeCode); $this->updateContext($storeCode); } - - // Load translations for the app - $area = $this->areaList->getArea($this->appState->getAreaCode()); - $area->load(AreaInterface::PART_TRANSLATE); } /** diff --git a/app/code/Magento/StoreGraphQl/Plugin/LocalizeEmail.php b/app/code/Magento/StoreGraphQl/Plugin/LocalizeEmail.php new file mode 100644 index 0000000000000..70f1762933e99 --- /dev/null +++ b/app/code/Magento/StoreGraphQl/Plugin/LocalizeEmail.php @@ -0,0 +1,78 @@ +<?php + +namespace Magento\StoreGraphQl\Plugin; + +use Magento\Framework\App\AreaInterface; +use Magento\Framework\App\AreaList; +use Magento\Framework\App\State; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Mail\Template\TransportBuilder; +use Magento\Store\Model\App\Emulation; +use Magento\Store\Model\StoreManagerInterface; + +/** + * Emulate the correct store when GraphQL is sending an email + */ +class LocalizeEmail +{ + /** + * @var StoreManagerInterface + */ + private $storeManager; + + /** + * @var Emulation + */ + private $emulation; + + /** + * @var AreaList + */ + private $areaList; + + /** + * @var State + */ + private $appState; + + /** + * @param StoreManagerInterface $storeManager + * @param Emulation $emulation + * @param AreaList $areaList + * @param State $appState + */ + public function __construct( + StoreManagerInterface $storeManager, + Emulation $emulation, + AreaList $areaList, + State $appState + ) { + $this->storeManager = $storeManager; + $this->emulation = $emulation; + $this->areaList = $areaList; + $this->appState = $appState; + } + + /** + * Emulate the correct store during email preparation + * + * @param TransportBuilder $subject + * @param \Closure $proceed + * @return mixed + * @throws NoSuchEntityException|LocalizedException + */ + public function aroundGetTransport(TransportBuilder $subject, \Closure $proceed) + { + // Load translations for the app + $area = $this->areaList->getArea($this->appState->getAreaCode()); + $area->load(AreaInterface::PART_TRANSLATE); + + $currentStore = $this->storeManager->getStore(); + $this->emulation->startEnvironmentEmulation($currentStore->getId()); + $output = $proceed(); + $this->emulation->stopEnvironmentEmulation(); + + return $output; + } +} diff --git a/app/code/Magento/StoreGraphQl/Plugin/StoreResolver.php b/app/code/Magento/StoreGraphQl/Plugin/StoreResolver.php deleted file mode 100644 index 65779f22f2758..0000000000000 --- a/app/code/Magento/StoreGraphQl/Plugin/StoreResolver.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php - -namespace Magento\StoreGraphQl\Plugin; - -use Magento\Framework\App\Request\Http as HttpRequest; -use Magento\Framework\App\RequestInterface; -use Magento\Store\Model\Resolver\Store; - -/** - * Ensure the store resolver gets the correct scope based on the GraphQl header - */ -class StoreResolver -{ - /** - * @var RequestInterface|HttpRequest - */ - private $request; - - /** - * @param RequestInterface $request - */ - public function __construct( - RequestInterface $request - ) { - $this->request = $request; - } - - /** - * If no scope is provided and there is a Store header, ensure the correct store code is used - * - * @param Store $subject - * @param null $scopeId - * @return array - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function beforeGetScope(Store $subject, $scopeId = null) - { - $storeCode = $this->request->getHeader('Store'); - - if ($scopeId === null && $storeCode) { - return [$storeCode]; - } - } -} diff --git a/app/code/Magento/StoreGraphQl/etc/graphql/di.xml b/app/code/Magento/StoreGraphQl/etc/graphql/di.xml index 93d6a1356e0d0..b28f7261737f5 100644 --- a/app/code/Magento/StoreGraphQl/etc/graphql/di.xml +++ b/app/code/Magento/StoreGraphQl/etc/graphql/di.xml @@ -23,7 +23,7 @@ </argument> </arguments> </type> - <type name="Magento\Store\Model\Resolver\Store"> - <plugin name="graphQlLocalizationStoreResolver" type="Magento\StoreGraphQl\Plugin\StoreResolver" /> + <type name="Magento\Framework\Mail\Template\TransportBuilder"> + <plugin name="graphQlEmulateEmail" type="Magento\StoreGraphQl\Plugin\LocalizeEmail" /> </type> </config> From 36427dc5802f140edc0d6bdbaa1d78534ff3d7ad Mon Sep 17 00:00:00 2001 From: janmonteros <janraymonteros@gmail.com> Date: Tue, 11 Aug 2020 10:15:06 +0800 Subject: [PATCH 040/104] magento/adobe-stock-integration#1711: Use product model instead of data object for catalog image helper init - Update MFTF for image placeholder verification, update branch --- .../AdminAssertCategoryGridPageDetailsActionGroup.xml | 1 + .../Section/AdminMediaGalleryCatalogUiCategoryGridSection.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AdminAssertCategoryGridPageDetailsActionGroup.xml b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AdminAssertCategoryGridPageDetailsActionGroup.xml index 0788bbd60291a..7507b96cde407 100644 --- a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AdminAssertCategoryGridPageDetailsActionGroup.xml +++ b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AdminAssertCategoryGridPageDetailsActionGroup.xml @@ -12,6 +12,7 @@ <description>Assert category grid page basic columns values for default category</description> </annotations> + <seeElement selector="{{AdminMediaGalleryCatalogUiCategoryGridSection.image('1','image')}}" stepKey="assertImageColumn"/> <seeElement selector="{{AdminMediaGalleryCatalogUiCategoryGridSection.path('1')}}" stepKey="assertPathColumn"/> <seeElement selector="{{AdminMediaGalleryCatalogUiCategoryGridSection.name('1', 'Default Category')}}" stepKey="assertNameColumn"/> <seeElement selector="{{AdminMediaGalleryCatalogUiCategoryGridSection.displayMode('1', 'PRODUCTS')}}" stepKey="assertDisplayModeColumn"/> diff --git a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Section/AdminMediaGalleryCatalogUiCategoryGridSection.xml b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Section/AdminMediaGalleryCatalogUiCategoryGridSection.xml index 5267a215c8edd..88e44b1cbd556 100644 --- a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Section/AdminMediaGalleryCatalogUiCategoryGridSection.xml +++ b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Section/AdminMediaGalleryCatalogUiCategoryGridSection.xml @@ -9,6 +9,7 @@ <sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminMediaGalleryCatalogUiCategoryGridSection"> + <element name="image" type="text" selector="//tr[{{row}}]//td[count(//div[@data-role='grid-wrapper']//tr//th[contains(., 'Image')]/preceding-sibling::th) +1]//img[contains(@src, '{{imageName}}')]" parameterized="true"/> <element name="path" type="text" selector="//tr[{{row}}]//td[count(//div[@data-role='grid-wrapper']//tr//th[contains(., 'Path')]/preceding-sibling::th)]" parameterized="true"/> <element name="name" type="text" selector="//tr[{{row}}]//td[count(//div[@data-role='grid-wrapper']//tr//th[contains(., 'Name')]/preceding-sibling::th) +1 ]//*[text()='{{categoryName}}']" parameterized="true"/> <element name="displayMode" type="text" selector="//tr[{{row}}]//td[count(//div[@data-role='grid-wrapper']//tr//th[contains(., 'Display Mode')]/preceding-sibling::th) +1 ]//*[text()='{{productsText}}']" parameterized="true"/> From 50aae09ebbf141fa643b476f39bbfb7791ab1296 Mon Sep 17 00:00:00 2001 From: Nazar Klovanych <nazarn96@gmail.com> Date: Tue, 11 Aug 2020 10:23:50 +0300 Subject: [PATCH 041/104] CodeReview suggestions --- ...erifyImageCreatedAtNotEqualsUpdatedAtTimeActionGroup.xml | 2 +- ...dMediaGalleryUploadedImageDateTimeEqualsActionGroup.xml} | 2 +- .../AdminStandaloneMediaGalleryEditImageDetailsTest.xml | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) rename app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/{AdminEnhancedMediaGalleryVerifyUploadedImageDateTimeEqualsActionGroup.xml => AssertAdminEnhancedMediaGalleryUploadedImageDateTimeEqualsActionGroup.xml} (94%) diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryVerifyImageCreatedAtNotEqualsUpdatedAtTimeActionGroup.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryVerifyImageCreatedAtNotEqualsUpdatedAtTimeActionGroup.xml index 248c6de468193..9460d0b339ca4 100644 --- a/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryVerifyImageCreatedAtNotEqualsUpdatedAtTimeActionGroup.xml +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryVerifyImageCreatedAtNotEqualsUpdatedAtTimeActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AdminEnhancedMediaGalleryVerifyImageCreatedAtNotEqualsUpdatedAtTimeActionGroup"> + <actionGroup name="AssertAdminEnhancedMediaGalleryImageCreatedAtNotEqualsUpdatedAtTimeActionGroup"> <annotations> <description>Assert that created_at updated_at time NOT equals</description> </annotations> diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryVerifyUploadedImageDateTimeEqualsActionGroup.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AssertAdminEnhancedMediaGalleryUploadedImageDateTimeEqualsActionGroup.xml similarity index 94% rename from app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryVerifyUploadedImageDateTimeEqualsActionGroup.xml rename to app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AssertAdminEnhancedMediaGalleryUploadedImageDateTimeEqualsActionGroup.xml index f26931f08586f..076885ddaf8b6 100644 --- a/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryVerifyUploadedImageDateTimeEqualsActionGroup.xml +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AssertAdminEnhancedMediaGalleryUploadedImageDateTimeEqualsActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AdminEnhancedMediaGalleryVerifyUploadedImageDateTimeEqualsActionGroup"> + <actionGroup name="AssertAdminEnhancedMediaGalleryUploadedImageDateTimeEqualsActionGroup"> <annotations> <description>Assert that created_at updated_at time are the same for newly uploaded image </description> </annotations> diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminStandaloneMediaGalleryEditImageDetailsTest.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminStandaloneMediaGalleryEditImageDetailsTest.xml index c5247dc21ec63..3fd1eacbf3504 100644 --- a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminStandaloneMediaGalleryEditImageDetailsTest.xml +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminStandaloneMediaGalleryEditImageDetailsTest.xml @@ -30,8 +30,8 @@ <argument name="image" value="ImageUpload"/> </actionGroup> <actionGroup ref="AdminEnhancedMediaGalleryViewImageDetails" stepKey="clickViewDetails"/> - <actionGroup ref="AdminEnhancedMediaGalleryVerifyUploadedImageDateTimeEqualsActionGroup" stepKey="verifyCreatedAndUpdatedAtDate" /> - <wait time="10" stepKey="waitForUpdateTimeToBeGreater"/> + <actionGroup ref="AssertAdminEnhancedMediaGalleryUploadedImageDateTimeEqualsActionGroup" stepKey="verifyCreatedAndUpdatedAtDate" /> + <wait time="20" stepKey="waitForUpdateTimeToBeGreater"/> <actionGroup ref="AdminEnhancedMediaGalleryCloseViewDetailsActionGroup" stepKey="closeViewDetails"/> <actionGroup ref="AdminEnhancedMediaGalleryEditImageDetailsActionGroup" stepKey="editImageDetails"/> <actionGroup ref="AdminEnhancedMediaGalleryImageDetailsSaveActionGroup" stepKey="saveImage"> @@ -44,7 +44,7 @@ <actionGroup ref="AdminEnhancedMediaGalleryVerifyImageDetailsActionGroup" stepKey="verifyImageDetails"> <argument name="image" value="UpdatedImageDetails"/> </actionGroup> - <actionGroup ref="AdminEnhancedMediaGalleryVerifyImageCreatedAtNotEqualsUpdatedAtTimeActionGroup" stepKey="assertUpdatedAtTimeChanged" /> + <actionGroup ref="AssertAdminEnhancedMediaGalleryImageCreatedAtNotEqualsUpdatedAtTimeActionGroup" stepKey="assertUpdatedAtTimeChanged" /> <actionGroup ref="AdminEnhancedMediaGalleryVerifyImageDescriptionActionGroup" stepKey="verifyImageDescription"> <argument name="description" value="UpdatedImageDetails.description"/> </actionGroup> From fe0081707fcede404ca852e51f99d4b2018c72fa Mon Sep 17 00:00:00 2001 From: Nazar Klovanych <nazarn96@gmail.com> Date: Tue, 11 Aug 2020 10:25:30 +0300 Subject: [PATCH 042/104] Rename file --- ...diaGalleryImageCreatedAtNotEqualsUpdatedAtTimeActionGroup.xml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/{AdminEnhancedMediaGalleryVerifyImageCreatedAtNotEqualsUpdatedAtTimeActionGroup.xml => AssertAdminEnhancedMediaGalleryImageCreatedAtNotEqualsUpdatedAtTimeActionGroup.xml} (100%) diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryVerifyImageCreatedAtNotEqualsUpdatedAtTimeActionGroup.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AssertAdminEnhancedMediaGalleryImageCreatedAtNotEqualsUpdatedAtTimeActionGroup.xml similarity index 100% rename from app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryVerifyImageCreatedAtNotEqualsUpdatedAtTimeActionGroup.xml rename to app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AssertAdminEnhancedMediaGalleryImageCreatedAtNotEqualsUpdatedAtTimeActionGroup.xml From d4e27fbcd7aff610ff2ce0735944c1b21b54bd31 Mon Sep 17 00:00:00 2001 From: Nazar Klovanych <nazarn96@gmail.com> Date: Tue, 11 Aug 2020 10:34:12 +0300 Subject: [PATCH 043/104] Fix flaky bahavior --- .../Test/AdminStandaloneMediaGalleryEditImageDetailsTest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminStandaloneMediaGalleryEditImageDetailsTest.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminStandaloneMediaGalleryEditImageDetailsTest.xml index 3fd1eacbf3504..58c6f32b8d72f 100644 --- a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminStandaloneMediaGalleryEditImageDetailsTest.xml +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminStandaloneMediaGalleryEditImageDetailsTest.xml @@ -31,7 +31,7 @@ </actionGroup> <actionGroup ref="AdminEnhancedMediaGalleryViewImageDetails" stepKey="clickViewDetails"/> <actionGroup ref="AssertAdminEnhancedMediaGalleryUploadedImageDateTimeEqualsActionGroup" stepKey="verifyCreatedAndUpdatedAtDate" /> - <wait time="20" stepKey="waitForUpdateTimeToBeGreater"/> + <wait time="100" stepKey="waitForUpdateTimeToBeGreater"/> <actionGroup ref="AdminEnhancedMediaGalleryCloseViewDetailsActionGroup" stepKey="closeViewDetails"/> <actionGroup ref="AdminEnhancedMediaGalleryEditImageDetailsActionGroup" stepKey="editImageDetails"/> <actionGroup ref="AdminEnhancedMediaGalleryImageDetailsSaveActionGroup" stepKey="saveImage"> From 7e34bc97092166109f2fbadda8d187a86ca7105e Mon Sep 17 00:00:00 2001 From: yolouiese <honeymay@abovethefray.io> Date: Tue, 11 Aug 2020 21:19:45 +0800 Subject: [PATCH 044/104] magento/magento2#1703: The deleted tags are not removed from Tags drop-down until the web page is refreshed - covered MFTF test --- .../AdminEnhancedMediaGalleryVerifyUpdatedTagsTest.xml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminEnhancedMediaGalleryVerifyUpdatedTagsTest.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminEnhancedMediaGalleryVerifyUpdatedTagsTest.xml index 3672f582b0877..db59369638da9 100644 --- a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminEnhancedMediaGalleryVerifyUpdatedTagsTest.xml +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminEnhancedMediaGalleryVerifyUpdatedTagsTest.xml @@ -5,7 +5,6 @@ * See COPYING.txt for license details. */ --> - <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminEnhancedMediaGalleryVerifyUpdatedTagsTest"> <annotations> @@ -26,8 +25,9 @@ <actionGroup ref="AdminEnhancedMediaGalleryImageDetailsDeleteActionGroup" stepKey="deleteImage"/> </after> <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadImage"> - <argument name="image" value="ImageUpload"/> + <argument name="image" value="ImageUpload3"/> </actionGroup> + <actionGroup ref="AdminEnhancedMediaGalleryViewImageDetails" stepKey="viewImageDetails"/> <actionGroup ref="AdminEnhancedMediaGalleryImageDetailsEditActionGroup" stepKey="editImage"/> <actionGroup ref="AdminMediaGalleryEditAssetAddKeywordActionGroup" stepKey="setKeywords"> <argument name="keyword" value="UpdatedImageDetails.keyword"/> @@ -35,6 +35,12 @@ <actionGroup ref="AdminEnhancedMediaGalleryImageDetailsSaveActionGroup" stepKey="saveImage"> <argument name="image" value="UpdatedImageDetails"/> </actionGroup> + <actionGroup ref="AssertImageAttributesOnEnhancedMediaGalleryActionGroup" stepKey="verifyUpdateImageOnTheGrid"> + <argument name="image" value="UpdatedImageDetails"/> + </actionGroup> + <actionGroup ref="AdminEnhancedMediaGalleryVerifyImageDetailsActionGroup" stepKey="verifyImageDetails"> + <argument name="image" value="UpdatedImageDetails"/> + </actionGroup> <actionGroup ref="AdminEnhancedMediaGalleryVerifyImageKeywordsActionGroup" stepKey="verifyAddedKeywords"> <argument name="keywords" value="UpdatedImageDetails.keyword"/> </actionGroup> From 8b8e496fa243b7fc3f92906cbbfbc1505298adf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Kos?= <kosrafal@gmail.com> Date: Tue, 11 Aug 2020 18:31:12 +0200 Subject: [PATCH 045/104] fix fatal error when exception was thrown --- .../Framework/Stdlib/DateTime/Timezone.php | 2 +- .../Test/Unit/DateTime/TimezoneTest.php | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php b/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php index 0791c89ab793a..42ffeae2aa883 100644 --- a/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php +++ b/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php @@ -319,7 +319,7 @@ public function convertConfigTimeToUtc($date, $format = 'Y-m-d H:i:s') throw new LocalizedException( new Phrase( 'The DateTime object timezone needs to be the same as the "%1" timezone in config.', - $this->getConfigTimezone() + [$this->getConfigTimezone()] ) ); } diff --git a/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/TimezoneTest.php b/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/TimezoneTest.php index b72995bb39855..09f85567e4c0d 100644 --- a/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/TimezoneTest.php +++ b/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/TimezoneTest.php @@ -9,6 +9,7 @@ use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\ScopeResolverInterface; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Locale\ResolverInterface; use Magento\Framework\Stdlib\DateTime; use Magento\Framework\Stdlib\DateTime\Timezone; @@ -208,6 +209,30 @@ public function testDate($expectedResult, $timezone, $date) ); } + /** + * Data provider for testException + * + * @return array + */ + public function getConvertConfigTimeToUTCDataFixtures() + { + return [ + 'datetime' => [ + new \DateTime('2016-10-10 10:00:00', new \DateTimeZone('UTC')) + ] + ]; + } + + /** + * @dataProvider getConvertConfigTimeToUTCDataFixtures + */ + public function testConvertConfigTimeToUtcException($date) + { + $this->expectException(LocalizedException::class); + + $this->getTimezone()->convertConfigTimeToUtc($date); + } + /** * DataProvider for testDate * From 0f9189efd2f6b7341c90225d577966f875dbbd83 Mon Sep 17 00:00:00 2001 From: yolouiese <honeymay@abovethefray.io> Date: Wed, 12 Aug 2020 01:06:45 +0800 Subject: [PATCH 046/104] magento/magento2#1703: The deleted tags are not removed from Tags drop-down until the web page is refreshed - covered MFTF test --- .../Test/AdminEnhancedMediaGalleryVerifyUpdatedTagsTest.xml | 6 ------ .../view/adminhtml/web/js/image/image-actions.js | 2 +- .../view/adminhtml/web/js/image/image-edit.js | 5 ++--- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminEnhancedMediaGalleryVerifyUpdatedTagsTest.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminEnhancedMediaGalleryVerifyUpdatedTagsTest.xml index db59369638da9..4abb819bed215 100644 --- a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminEnhancedMediaGalleryVerifyUpdatedTagsTest.xml +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminEnhancedMediaGalleryVerifyUpdatedTagsTest.xml @@ -35,12 +35,6 @@ <actionGroup ref="AdminEnhancedMediaGalleryImageDetailsSaveActionGroup" stepKey="saveImage"> <argument name="image" value="UpdatedImageDetails"/> </actionGroup> - <actionGroup ref="AssertImageAttributesOnEnhancedMediaGalleryActionGroup" stepKey="verifyUpdateImageOnTheGrid"> - <argument name="image" value="UpdatedImageDetails"/> - </actionGroup> - <actionGroup ref="AdminEnhancedMediaGalleryVerifyImageDetailsActionGroup" stepKey="verifyImageDetails"> - <argument name="image" value="UpdatedImageDetails"/> - </actionGroup> <actionGroup ref="AdminEnhancedMediaGalleryVerifyImageKeywordsActionGroup" stepKey="verifyAddedKeywords"> <argument name="keywords" value="UpdatedImageDetails.keyword"/> </actionGroup> diff --git a/app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/image/image-actions.js b/app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/image/image-actions.js index 9eea75e8cab91..977ffcd0255ff 100644 --- a/app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/image/image-actions.js +++ b/app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/image/image-actions.js @@ -99,7 +99,7 @@ define([ this.closeModal(); this.imageModel().reloadGrid(); imageDetails.removeCached(imageId); - imageEditDetails.removeCached(imageId, keywords); + imageEditDetails.removeCached(imageId); if (imageDetails.isActive()) { imageDetails.showImageDetailsById(imageId); diff --git a/app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/image/image-edit.js b/app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/image/image-edit.js index e142fb12aa96a..e1404a16d7125 100644 --- a/app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/image/image-edit.js +++ b/app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/image/image-edit.js @@ -229,10 +229,9 @@ define([ * Remove cached image details in edit form * * @param {String} id - * @param {String} tags */ - removeCached: function (id, tags) { - this.images[id].tags = tags; + removeCached: function (id) { + delete this.images[id]; } }); }); From 9f02257226d4ac946c572ff4d23ce88ef5265fae Mon Sep 17 00:00:00 2001 From: joweecaquicla <joie@abovethefray.io> Date: Wed, 12 Aug 2020 01:37:46 +0800 Subject: [PATCH 047/104] magento/adobe-stock-integration#1727: Introduce internal class wrapping SplFileInfo - fix static and mftf fails, added integration tets --- .../Model/Filesystem/FileInfo.php | 55 +---------- .../Model/Filesystem/GetFileInfo.php | 6 +- .../Model/Filesystem/GetFileInfoTest.php | 94 +++++++++++++++++++ 3 files changed, 101 insertions(+), 54 deletions(-) create mode 100644 app/code/Magento/MediaGallerySynchronization/Test/Integration/Model/Filesystem/GetFileInfoTest.php diff --git a/app/code/Magento/MediaGallerySynchronization/Model/Filesystem/FileInfo.php b/app/code/Magento/MediaGallerySynchronization/Model/Filesystem/FileInfo.php index 20acefe4ab034..034ae7c0bff5a 100644 --- a/app/code/Magento/MediaGallerySynchronization/Model/Filesystem/FileInfo.php +++ b/app/code/Magento/MediaGallerySynchronization/Model/Filesystem/FileInfo.php @@ -8,7 +8,9 @@ namespace Magento\MediaGallerySynchronization\Model\Filesystem; /** - * Class FileInfo + * Internal class wrapping \SplFileInfo + * + * @SuppressWarnings(PHPMD.TooManyFields) */ class FileInfo extends \SplFileInfo { @@ -37,11 +39,6 @@ class FileInfo extends \SplFileInfo */ private $pathname; - /** - * @var int - */ - private $perms; - /** * @var int */ @@ -87,16 +84,6 @@ class FileInfo extends \SplFileInfo */ private $realPath; - /** - * @var \SplFileInfo - */ - private $fileInfo; - - /** - * @var \SplFileInfo - */ - private $pathInfo; - /** * FileInfo constructor. * @param string $file_name @@ -105,7 +92,6 @@ class FileInfo extends \SplFileInfo * @param string $extension * @param string $basename * @param string $pathname - * @param int $perms * @param int $inode * @param int $size * @param int $owner @@ -115,8 +101,7 @@ class FileInfo extends \SplFileInfo * @param int $cTime * @param string $type * @param false|string $realPath - * @param \SplFileInfo $fileInfo - * @param \SplFileInfo $pathInfo + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( string $file_name, @@ -125,7 +110,6 @@ public function __construct( string $extension, string $basename, string $pathname, - int $perms, int $inode, int $size, int $owner, @@ -134,9 +118,7 @@ public function __construct( int $mTime, int $cTime, string $type, - $realPath, - \SplFileInfo $fileInfo, - \SplFileInfo $pathInfo + $realPath ) { parent::__construct($file_name); $this->path = $path; @@ -144,7 +126,6 @@ public function __construct( $this->extension = $extension; $this->basename = $basename; $this->pathname = $pathname; - $this->perms = $perms; $this->inode = $inode; $this->size = $size; $this->owner = $owner; @@ -154,8 +135,6 @@ public function __construct( $this->cTime = $cTime; $this->type = $type; $this->realPath = $realPath; - $this->fileInfo = $fileInfo; - $this->pathInfo = $pathInfo; } /** @@ -198,14 +177,6 @@ public function getPathname(): string return $this->pathname; } - /** - * @inheritDoc - */ - public function getPerms(): int - { - return $this->perms; - } - /** * @inheritDoc */ @@ -277,20 +248,4 @@ public function getRealPath() { return $this->realPath; } - - /** - * @inheritDoc - */ - public function getFileInfo($class_name = null): \SplFileInfo - { - return $this->fileInfo; - } - - /** - * @inheritDoc - */ - public function getPathInfo($class_name = null): \SplFileInfo - { - return $this->pathInfo; - } } diff --git a/app/code/Magento/MediaGallerySynchronization/Model/Filesystem/GetFileInfo.php b/app/code/Magento/MediaGallerySynchronization/Model/Filesystem/GetFileInfo.php index ef382732275bd..e2ffa39d0aba9 100644 --- a/app/code/Magento/MediaGallerySynchronization/Model/Filesystem/GetFileInfo.php +++ b/app/code/Magento/MediaGallerySynchronization/Model/Filesystem/GetFileInfo.php @@ -44,7 +44,7 @@ public function execute(string $path): FileInfo 'path' => $splFileInfo->getPath(), 'filename' => $splFileInfo->getFilename(), 'extension' => $splFileInfo->getExtension(), - 'basename' => $splFileInfo->getBasename(), + 'basename' => $splFileInfo->getBasename('.' . $splFileInfo->getExtension()), 'pathname' => $splFileInfo->getPathname(), 'perms' => $splFileInfo->getPerms(), 'inode' => $splFileInfo->getInode(), @@ -55,9 +55,7 @@ public function execute(string $path): FileInfo 'mTime' => $splFileInfo->getMTime(), 'cTime' => $splFileInfo->getCTime(), 'type' => $splFileInfo->getType(), - 'realPath' => $splFileInfo->getRealPath(), - 'fileInfo' => $splFileInfo->getFileInfo(), - 'pathInfo' => $splFileInfo->getPathInfo() + 'realPath' => $splFileInfo->getRealPath() ]); } } diff --git a/app/code/Magento/MediaGallerySynchronization/Test/Integration/Model/Filesystem/GetFileInfoTest.php b/app/code/Magento/MediaGallerySynchronization/Test/Integration/Model/Filesystem/GetFileInfoTest.php new file mode 100644 index 0000000000000..c88a6fe7d39d7 --- /dev/null +++ b/app/code/Magento/MediaGallerySynchronization/Test/Integration/Model/Filesystem/GetFileInfoTest.php @@ -0,0 +1,94 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallerySynchronization\Test\Integration\Model\Filesystem; + +use Magento\MediaGallerySynchronization\Model\Filesystem\GetFileInfo; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Integration test for GetFileInfo + */ +class GetFileInfoTest extends TestCase +{ + /** + * @var GetFileInfo + */ + private $getFileInfo; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + $this->getFileInfo = Bootstrap::getObjectManager()->get(GetFileInfo::class); + } + + /** + * @dataProvider filesProvider + * @param string $file + */ + public function testExecute( + string $file + ): void { + + $path = $this->getImageFilePath($file); + + $fileInfo = $this->getFileInfo->execute($path); + $this->assertNotEmpty($fileInfo->getPath()); + $this->assertNotEmpty($fileInfo->getFilename()); + $this->assertNotEmpty($fileInfo->getExtension()); + $this->assertNotEmpty($fileInfo->getBasename()); + $this->assertNotEmpty($fileInfo->getPathname()); + $this->assertNotEmpty($fileInfo->getPerms()); + $this->assertNotEmpty($fileInfo->getInode()); + $this->assertNotEmpty($fileInfo->getSize()); + $this->assertNotEmpty($fileInfo->getOwner()); + $this->assertNotEmpty($fileInfo->getGroup()); + $this->assertNotEmpty($fileInfo->getATime()); + $this->assertNotEmpty($fileInfo->getMTime()); + $this->assertNotEmpty($fileInfo->getCTime()); + $this->assertNotEmpty($fileInfo->getType()); + $this->assertNotEmpty($fileInfo->getRealPath()); + + } + + /** + * Data provider for testExecute + * + * @return array[] + */ + public function filesProvider(): array + { + return [ + [ + 'magento.jpg', + 'magento_2.jpg' + ] + ]; + } + + /** + * Return image file path + * + * @param string $filename + * @return string + */ + private function getImageFilePath(string $filename): string + { + return dirname(__DIR__, 2) + . DIRECTORY_SEPARATOR + . implode( + DIRECTORY_SEPARATOR, + [ + '_files', + $filename + ] + ); + } +} From 0b6ba916edc17c9e6a231b7fb3598086c1c365c8 Mon Sep 17 00:00:00 2001 From: joweecaquicla <joie@abovethefray.io> Date: Wed, 12 Aug 2020 03:35:25 +0800 Subject: [PATCH 048/104] magento/adobe-stock-integration#1727: Introduce internal class wrapping SplFileInfo - fix static test --- .../Test/Integration/Model/Filesystem/GetFileInfoTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/MediaGallerySynchronization/Test/Integration/Model/Filesystem/GetFileInfoTest.php b/app/code/Magento/MediaGallerySynchronization/Test/Integration/Model/Filesystem/GetFileInfoTest.php index c88a6fe7d39d7..4031de4226105 100644 --- a/app/code/Magento/MediaGallerySynchronization/Test/Integration/Model/Filesystem/GetFileInfoTest.php +++ b/app/code/Magento/MediaGallerySynchronization/Test/Integration/Model/Filesystem/GetFileInfoTest.php @@ -55,7 +55,6 @@ public function testExecute( $this->assertNotEmpty($fileInfo->getCTime()); $this->assertNotEmpty($fileInfo->getType()); $this->assertNotEmpty($fileInfo->getRealPath()); - } /** From 7d7de12c335c4a24846405985ed2781103e482ba Mon Sep 17 00:00:00 2001 From: Ievgen Kolesov <ikolesov@adobe.com> Date: Tue, 11 Aug 2020 15:33:43 -0500 Subject: [PATCH 049/104] PWA-805: Expose localization system / store config from GraphQL --- .../Store/Model/ResourceModel/StoreWebsiteRelation.php | 4 ++-- .../Model/Resolver/Store/StoreConfigDataProvider.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Store/Model/ResourceModel/StoreWebsiteRelation.php b/app/code/Magento/Store/Model/ResourceModel/StoreWebsiteRelation.php index f0b021eefb999..875c0e6cb3b05 100644 --- a/app/code/Magento/Store/Model/ResourceModel/StoreWebsiteRelation.php +++ b/app/code/Magento/Store/Model/ResourceModel/StoreWebsiteRelation.php @@ -48,11 +48,11 @@ public function getStoreByWebsiteId($websiteId) * Get website store data * * @param int $websiteId - * @param int $storeGroupId * @param bool $available + * @param int|null $storeGroupId * @return array */ - public function getWebsiteStores(int $websiteId, int $storeGroupId = null, bool $available = false): array + public function getWebsiteStores(int $websiteId, bool $available = false, int $storeGroupId = null): array { $connection = $this->resource->getConnection(); $storeTable = $this->resource->getTableName('store'); diff --git a/app/code/Magento/StoreGraphQl/Model/Resolver/Store/StoreConfigDataProvider.php b/app/code/Magento/StoreGraphQl/Model/Resolver/Store/StoreConfigDataProvider.php index 928a99eb73714..8378b3bc7a4be 100644 --- a/app/code/Magento/StoreGraphQl/Model/Resolver/Store/StoreConfigDataProvider.php +++ b/app/code/Magento/StoreGraphQl/Model/Resolver/Store/StoreConfigDataProvider.php @@ -78,7 +78,7 @@ public function getStoreConfigData(StoreInterface $store): array */ public function getAvailableStoreConfig(int $websiteId, int $storeGroupId = null): array { - $websiteStores = $this->storeWebsiteRelation->getWebsiteStores($websiteId, $storeGroupId, true); + $websiteStores = $this->storeWebsiteRelation->getWebsiteStores($websiteId, true, $storeGroupId); $storeCodes = array_column($websiteStores, 'code'); $storeConfigs = $this->storeConfigManager->getStoreConfigs($storeCodes); From 3b350fd86cfa89a147a736d96e7c59ab2ac40b68 Mon Sep 17 00:00:00 2001 From: yolouiese <honeymay@abovethefray.io> Date: Wed, 12 Aug 2020 18:10:46 +0800 Subject: [PATCH 050/104] magento/magento2#1703: The deleted tags are not removed from Tags drop-down until the web page is refreshed - added verify removal of keyword MFTF test --- ...yVerifyRemovedImageKeywordsActionGroup.xml | 25 +++++++++++++++++++ ...lleryEditAssetRemoveKeywordActionGroup.xml | 21 ++++++++++++++++ ...EnhancedMediaGalleryEditDetailsSection.xml | 1 + ...ancedMediaGalleryVerifyUpdatedTagsTest.xml | 11 ++++++-- 4 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryVerifyRemovedImageKeywordsActionGroup.xml create mode 100644 app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminMediaGalleryEditAssetRemoveKeywordActionGroup.xml diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryVerifyRemovedImageKeywordsActionGroup.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryVerifyRemovedImageKeywordsActionGroup.xml new file mode 100644 index 0000000000000..b94fbf369ef01 --- /dev/null +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryVerifyRemovedImageKeywordsActionGroup.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminEnhancedMediaGalleryVerifyRemovedImageKeywordsActionGroup"> + <annotations> + <description>Verifies removed image keywords on the View Details panel</description> + </annotations> + <arguments> + <argument name="keywords"/> + </arguments> + + <grabTextFrom selector="{{AdminEnhancedMediaGalleryViewDetailsSection.keywords}}" stepKey="grabKeywords"/> + <assertStringNotContainsString stepKey="verifyKeywords"> + <actualResult type="variable">grabKeywords</actualResult> + <expectedResult type="string">{{keywords}}</expectedResult> + </assertStringNotContainsString> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminMediaGalleryEditAssetRemoveKeywordActionGroup.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminMediaGalleryEditAssetRemoveKeywordActionGroup.xml new file mode 100644 index 0000000000000..7bba4fd637189 --- /dev/null +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminMediaGalleryEditAssetRemoveKeywordActionGroup.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminMediaGalleryEditAssetRemoveKeywordActionGroup"> + <annotations> + <description>Remove Keywords on the Edit Details panel</description> + </annotations> + <arguments> + <argument name="selectedKeywords"/> + </arguments> + + <click selector="{{AdminEnhancedMediaGalleryEditDetailsSection.removeSelectedKeyword(selectedKeywords)}}" stepKey="removeKeyword"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/Section/AdminEnhancedMediaGalleryEditDetailsSection.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/Section/AdminEnhancedMediaGalleryEditDetailsSection.xml index b8e2f698ccfe8..7456db0b4d988 100644 --- a/app/code/Magento/MediaGalleryUi/Test/Mftf/Section/AdminEnhancedMediaGalleryEditDetailsSection.xml +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/Section/AdminEnhancedMediaGalleryEditDetailsSection.xml @@ -14,6 +14,7 @@ <element name="description" type="textarea" selector="#description"/> <element name="newKeyword" type="input" selector="[data-ui-id='keyword']"/> <element name="addNewKeyword" type="input" selector="[data-ui-id='add-keyword']"/> + <element name="removeSelectedKeyword" type="button" selector="//span[contains(text(), '{{selectedKeywords}}')]/following-sibling::button[@data-action='remove-selected-item']" parameterized="true"/> <element name="cancel" type="button" selector="#image-details-action-cancel"/> <element name="save" type="button" selector="#image-details-action-save"/> </section> diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminEnhancedMediaGalleryVerifyUpdatedTagsTest.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminEnhancedMediaGalleryVerifyUpdatedTagsTest.xml index 4abb819bed215..9571d49a88130 100644 --- a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminEnhancedMediaGalleryVerifyUpdatedTagsTest.xml +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminEnhancedMediaGalleryVerifyUpdatedTagsTest.xml @@ -38,8 +38,15 @@ <actionGroup ref="AdminEnhancedMediaGalleryVerifyImageKeywordsActionGroup" stepKey="verifyAddedKeywords"> <argument name="keywords" value="UpdatedImageDetails.keyword"/> </actionGroup> - <actionGroup ref="AdminEnhancedMediaGalleryVerifyImageKeywordsActionGroup" stepKey="verifyMetadataKeywords"> - <argument name="keywords" value="ImageMetadata.keywords"/> + <actionGroup ref="AdminEnhancedMediaGalleryImageDetailsEditActionGroup" stepKey="updateImageDetails"/> + <actionGroup ref="AdminMediaGalleryEditAssetRemoveKeywordActionGroup" stepKey="removeKeywords"> + <argument name="selectedKeywords" value="UpdatedImageDetails.keyword"/> + </actionGroup> + <actionGroup ref="AdminEnhancedMediaGalleryImageDetailsSaveActionGroup" stepKey="saveUpdatedImage"> + <argument name="image" value="UpdatedImageDetails"/> + </actionGroup> + <actionGroup ref="AdminEnhancedMediaGalleryVerifyRemovedImageKeywordsActionGroup" stepKey="verifyRemovedKeywords"> + <argument name="keywords" value="UpdatedImageDetails.keyword"/> </actionGroup> </test> </tests> From 4d65656fafe9c132bc8cd441ac2d1f7571b5a0da Mon Sep 17 00:00:00 2001 From: Vasya Tsviklinskyi <tsviklinskyi@gmail.com> Date: Wed, 12 Aug 2020 14:07:58 +0300 Subject: [PATCH 051/104] MC-35699: [Magento Cloud] HTML minification strips triple slashes from html string in phtml --- .../Magento/Framework/View/Template/Html/Minifier.php | 3 ++- .../Framework/View/Test/Unit/Template/Html/MinifierTest.php | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/View/Template/Html/Minifier.php b/lib/internal/Magento/Framework/View/Template/Html/Minifier.php index 0a8db80cae349..cdbce9d102a89 100644 --- a/lib/internal/Magento/Framework/View/Template/Html/Minifier.php +++ b/lib/internal/Magento/Framework/View/Template/Html/Minifier.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\Framework\View\Template\Html; @@ -140,7 +141,7 @@ function ($match) use (&$heredocs) { . '(?:<(?>textarea|pre|script)\b|\z))#', ' ', preg_replace( - '#(?<!:|\\\\|\'|")//(?!\s*\<\!\[)(?!\s*]]\>)[^\n\r]*#', + '#(?<!:|\\\\|\'|"|/)//(?!/)(?!\s*\<\!\[)(?!\s*]]\>)[^\n\r]*#', '', preg_replace( '#(?<!:|\'|")//[^\n\r]*(\?\>)#', diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Template/Html/MinifierTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Template/Html/MinifierTest.php index 6aafa5a46cf63..3b13a2f723617 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Template/Html/MinifierTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Template/Html/MinifierTest.php @@ -3,6 +3,8 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Framework\View\Test\Unit\Template\Html; use PHPUnit\Framework\TestCase; @@ -139,6 +141,7 @@ public function testMinify() <img src="test.png" alt="some text" /> <?php echo \$block->someMethod(); ?> <div style="width: 800px" class="<?php echo \$block->getClass() ?>" /> + <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-component="main-image"> <script> var i = 1;// comment var j = 1;// <?php echo 'hi' ?> @@ -179,7 +182,7 @@ public function testMinify() TEXT; $expectedContent = <<<TEXT -<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ ?> <?php ?> <html><head><title>Test titleText Link some textsomeMethod(); ?>