From bedbb377740644f236e93b2e34fc8fd70530aaa6 Mon Sep 17 00:00:00 2001 From: Anton Kaplia Date: Tue, 5 Nov 2019 11:13:10 -0600 Subject: [PATCH 01/39] JSON fields support --- app/etc/di.xml | 3 + .../Db/MySQL/Definition/Columns/Json.php | 73 +++++++++++++++++++ .../Declaration/Schema/Dto/Columns/Json.php | 68 +++++++++++++++++ .../Declaration/Schema/Dto/Factories/Json.php | 47 ++++++++++++ .../Setup/Declaration/Schema/etc/schema.xsd | 1 + .../Schema/etc/types/texts/json.xsd | 23 ++++++ .../JsonDefinition.php | 25 +++++++ 7 files changed, 240 insertions(+) create mode 100644 lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/MySQL/Definition/Columns/Json.php create mode 100644 lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Columns/Json.php create mode 100644 lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Json.php create mode 100644 lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/types/texts/json.xsd create mode 100644 lib/internal/Magento/Framework/Setup/SchemaListenerDefinition/JsonDefinition.php diff --git a/app/etc/di.xml b/app/etc/di.xml index f8818de2af842..167471dbd0397 100644 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -1453,6 +1453,7 @@ \Magento\Framework\Setup\Declaration\Schema\Dto\Factories\Primary \Magento\Framework\Setup\Declaration\Schema\Dto\Factories\Foreign \Magento\Framework\Setup\Declaration\Schema\Dto\Factories\Index + \Magento\Framework\Setup\Declaration\Schema\Dto\Factories\Json @@ -1480,6 +1481,7 @@ \Magento\Framework\Setup\Declaration\Schema\Db\MySQL\Definition\Columns\StringBinary \Magento\Framework\Setup\Declaration\Schema\Db\MySQL\Definition\Columns\StringBinary \Magento\Framework\Setup\Declaration\Schema\Db\MySQL\Definition\Columns\StringBinary + \Magento\Framework\Setup\Declaration\Schema\Db\MySQL\Definition\Columns\Json \Magento\Framework\Setup\Declaration\Schema\Db\MySQL\Definition\Index \Magento\Framework\Setup\Declaration\Schema\Db\MySQL\Definition\Constraints\Internal \Magento\Framework\Setup\Declaration\Schema\Db\MySQL\Definition\Constraints\Internal @@ -1593,6 +1595,7 @@ Magento\Framework\Setup\SchemaListenerDefinition\TimestampDefinition Magento\Framework\Setup\SchemaListenerDefinition\DateDefinition Magento\Framework\Setup\SchemaListenerDefinition\BooleanDefinition + Magento\Framework\Setup\SchemaListenerDefinition\JsonDefinition diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/MySQL/Definition/Columns/Json.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/MySQL/Definition/Columns/Json.php new file mode 100644 index 0000000000000..2ed65a9ff9d03 --- /dev/null +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/MySQL/Definition/Columns/Json.php @@ -0,0 +1,73 @@ +nullable = $nullable; + $this->resourceConnection = $resourceConnection; + $this->comment = $comment; + } + + /** + * @inheritdoc + */ + public function toDefinition(ElementInterface $column) + { + return sprintf( + '%s %s %s %s', + $this->resourceConnection->getConnection()->quoteIdentifier($column->getName()), + $column->getType(), + $this->nullable->toDefinition($column), + $this->comment->toDefinition($column) + ); + } + + /** + * @inheritdoc + */ + public function fromDefinition(array $data) + { + return $data; + } +} diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Columns/Json.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Columns/Json.php new file mode 100644 index 0000000000000..8b8de071068a1 --- /dev/null +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Columns/Json.php @@ -0,0 +1,68 @@ +nullable = $nullable; + } + + /** + * Check whether column can be nullable. + * + * @return bool + */ + public function isNullable() + { + return $this->nullable; + } + + /** + * @inheritdoc + */ + public function getDiffSensitiveParams() + { + return [ + 'type' => $this->getType(), + 'nullable' => $this->isNullable(), + 'comment' => $this->getComment() + ]; + } +} diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Json.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Json.php new file mode 100644 index 0000000000000..f778b048413de --- /dev/null +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Json.php @@ -0,0 +1,47 @@ +objectManager = $objectManager; + $this->className = $className; + } + + /** + * {@inheritdoc} + */ + public function create(array $data) + { + return $this->objectManager->create($this->className, $data); + } +} diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/schema.xsd b/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/schema.xsd index e3c54413f810b..bb9136d8a9ae6 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/schema.xsd +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/schema.xsd @@ -20,6 +20,7 @@ + diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/types/texts/json.xsd b/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/types/texts/json.xsd new file mode 100644 index 0000000000000..690f84a5ef43f --- /dev/null +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/types/texts/json.xsd @@ -0,0 +1,23 @@ + + + + + + + + + + + Well formatted Json object + + + + + + + diff --git a/lib/internal/Magento/Framework/Setup/SchemaListenerDefinition/JsonDefinition.php b/lib/internal/Magento/Framework/Setup/SchemaListenerDefinition/JsonDefinition.php new file mode 100644 index 0000000000000..04866dde943f4 --- /dev/null +++ b/lib/internal/Magento/Framework/Setup/SchemaListenerDefinition/JsonDefinition.php @@ -0,0 +1,25 @@ + $definition['type'], + 'name' => $definition['name'], + 'nullable' => $definition['nullable'] ?? true + ]; + } +} From ba5ee6edc002d2462c5bb784bd13b53dc4b87e60 Mon Sep 17 00:00:00 2001 From: Anton Kaplia Date: Tue, 5 Nov 2019 12:32:02 -0600 Subject: [PATCH 02/39] Fix static tests --- .../Schema/Db/MySQL/Definition/Columns/Json.php | 7 ++++--- .../Setup/Declaration/Schema/Dto/Columns/Json.php | 9 +++++---- .../Setup/Declaration/Schema/Dto/Factories/Json.php | 9 ++++++--- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/MySQL/Definition/Columns/Json.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/MySQL/Definition/Columns/Json.php index 2ed65a9ff9d03..b25b70674e0d0 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/MySQL/Definition/Columns/Json.php +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/MySQL/Definition/Columns/Json.php @@ -12,8 +12,6 @@ /** * Process json data type. - * - * @inheritdoc */ class Json implements DbDefinitionProcessorInterface { @@ -64,7 +62,10 @@ public function toDefinition(ElementInterface $column) } /** - * @inheritdoc + * Returns an array of column definitions + * + * @param array $data + * @return array */ public function fromDefinition(array $data) { diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Columns/Json.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Columns/Json.php index 8b8de071068a1..0f1e785730d38 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Columns/Json.php +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Columns/Json.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Framework\Setup\Declaration\Schema\Dto\Columns; use Magento\Framework\Setup\Declaration\Schema\Dto\Column; @@ -10,14 +11,14 @@ use Magento\Framework\Setup\Declaration\Schema\Dto\Table; /** + * Json + * * Text column. * Declared in SQL, like: JSON */ -class Json extends Column implements - ElementDiffAwareInterface, - ColumnNullableAwareInterface +class Json extends Column implements ElementDiffAwareInterface, ColumnNullableAwareInterface { - /**Json + /** * @var bool */ private $nullable; diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Json.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Json.php index f778b048413de..ec20e4a9438f3 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Json.php +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Json.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Framework\Setup\Declaration\Schema\Dto\Factories; use Magento\Framework\ObjectManagerInterface; @@ -12,7 +13,6 @@ */ class Json implements FactoryInterface { - /** * @var ObjectManagerInterface */ @@ -27,7 +27,7 @@ class Json implements FactoryInterface * Constructor. * * @param ObjectManagerInterface $objectManager - * @param string $className + * @param string $className */ public function __construct( ObjectManagerInterface $objectManager, @@ -38,7 +38,10 @@ public function __construct( } /** - * {@inheritdoc} + * Create element using definition data array. + * + * @param array $data + * @return \Magento\Framework\Setup\Declaration\Schema\Dto\ElementInterface|mixed */ public function create(array $data) { From 0693cc2a75a1646080501176e24d3fd41a72a6b5 Mon Sep 17 00:00:00 2001 From: Alexey Arendarenko Date: Thu, 14 Nov 2019 15:08:45 +0200 Subject: [PATCH 03/39] UrlRewrite module fixes add ability to save query param from request during redirect to target path --- app/code/Magento/UrlRewrite/Controller/Router.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/UrlRewrite/Controller/Router.php b/app/code/Magento/UrlRewrite/Controller/Router.php index dd26f49b8efa4..0525621b6a20e 100644 --- a/app/code/Magento/UrlRewrite/Controller/Router.php +++ b/app/code/Magento/UrlRewrite/Controller/Router.php @@ -118,7 +118,7 @@ protected function processRedirect($request, $rewrite) if ($rewrite->getEntityType() !== Rewrite::ENTITY_TYPE_CUSTOM || ($prefix = substr($target, 0, 6)) !== 'http:/' && $prefix !== 'https:' ) { - $target = $this->url->getUrl('', ['_direct' => $target]); + $target = $this->url->getUrl('', ['_direct' => $target, '_query' => $request->getParams()]); } return $this->redirect($request, $target, $rewrite->getRedirectType()); } From 19b7bdac3a33eb12395b9f362a7c03e013228cc8 Mon Sep 17 00:00:00 2001 From: Alexey Arendarenko Date: Thu, 14 Nov 2019 15:08:55 +0200 Subject: [PATCH 04/39] UrlRewrite module fixes update unit test --- .../Test/Unit/Controller/RouterTest.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/UrlRewrite/Test/Unit/Controller/RouterTest.php b/app/code/Magento/UrlRewrite/Test/Unit/Controller/RouterTest.php index c935b3c7ec4cb..c67f3f400b007 100644 --- a/app/code/Magento/UrlRewrite/Test/Unit/Controller/RouterTest.php +++ b/app/code/Magento/UrlRewrite/Test/Unit/Controller/RouterTest.php @@ -260,6 +260,7 @@ public function testNoRewriteAfterStoreSwitcherWhenOldRewriteEqualsToNewOne() */ public function testMatchWithRedirect() { + $queryParams = []; $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store)); $urlRewrite = $this->getMockBuilder(UrlRewrite::class) ->disableOriginalConstructor()->getMock(); @@ -268,7 +269,11 @@ public function testMatchWithRedirect() $this->urlFinder->expects($this->any())->method('findOneByData')->will($this->returnValue($urlRewrite)); $this->response->expects($this->once())->method('setRedirect') ->with('new-target-path', 'redirect-code'); - $this->url->expects($this->once())->method('getUrl')->with('', ['_direct' => 'target-path']) + $this->request->expects($this->once())->method('getParams')->willReturn($queryParams); + $this->url->expects($this->once())->method('getUrl')->with( + '', + ['_direct' => 'target-path', '_query' => $queryParams] + ) ->will($this->returnValue('new-target-path')); $this->request->expects($this->once())->method('setDispatched')->with(true); $this->actionFactory->expects($this->once())->method('create') @@ -282,6 +287,7 @@ public function testMatchWithRedirect() */ public function testMatchWithCustomInternalRedirect() { + $queryParams = []; $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store)); $urlRewrite = $this->getMockBuilder(UrlRewrite::class) ->disableOriginalConstructor()->getMock(); @@ -289,8 +295,12 @@ public function testMatchWithCustomInternalRedirect() $urlRewrite->expects($this->any())->method('getRedirectType')->will($this->returnValue('redirect-code')); $urlRewrite->expects($this->any())->method('getTargetPath')->will($this->returnValue('target-path')); $this->urlFinder->expects($this->any())->method('findOneByData')->will($this->returnValue($urlRewrite)); + $this->request->expects($this->any())->method('getParams')->willReturn($queryParams); $this->response->expects($this->once())->method('setRedirect')->with('a', 'redirect-code'); - $this->url->expects($this->once())->method('getUrl')->with('', ['_direct' => 'target-path'])->willReturn('a'); + $this->url->expects($this->once())->method('getUrl')->with( + '', + ['_direct' => 'target-path', '_query' => $queryParams] + )->willReturn('a'); $this->request->expects($this->once())->method('setDispatched')->with(true); $this->actionFactory->expects($this->once())->method('create') ->with(\Magento\Framework\App\Action\Redirect::class); @@ -312,6 +322,7 @@ public function testMatchWithCustomExternalRedirect($targetPath) $urlRewrite->expects($this->any())->method('getTargetPath')->will($this->returnValue($targetPath)); $this->urlFinder->expects($this->any())->method('findOneByData')->will($this->returnValue($urlRewrite)); $this->response->expects($this->once())->method('setRedirect')->with($targetPath, 'redirect-code'); + $this->request->expects($this->never())->method('getParams'); $this->url->expects($this->never())->method('getUrl'); $this->request->expects($this->once())->method('setDispatched')->with(true); $this->actionFactory->expects($this->once())->method('create') From f63475c37e37dde8eef9f404f518eb415c7557b0 Mon Sep 17 00:00:00 2001 From: Alexey Arendarenko Date: Thu, 14 Nov 2019 15:10:37 +0200 Subject: [PATCH 05/39] UrlRewrite module fixes update fixture update integration test --- .../UrlRewrite/Controller/UrlRewriteTest.php | 30 +++++++++++++ .../Magento/UrlRewrite/_files/url_rewrite.php | 42 ++++++++++++++++++- .../_files/url_rewrite_rollback.php | 4 +- 3 files changed, 73 insertions(+), 3 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php index 5f8adc5d65113..b6a551cc6ad50 100644 --- a/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php +++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php @@ -80,6 +80,36 @@ public function requestDataProvider(): array 'request' => '/page-similar/', 'redirect' => '/page-b', ], + 'Use Case #7: Rewrite: page-similar --(301)--> page-a; ' + . 'Request: page-similar?param=1 --(301)--> page-a?param=1' => [ + 'request' => '/page-similar?param=1', + 'redirect' => '/page-a?param=1', + ], + 'Use Case #8: Rewrite: page-similar/ --(301)--> page-b; ' + . 'Request: page-similar/?param=1 --(301)--> page-b?param=1' => [ + 'request' => '/page-similar/?param=1', + 'redirect' => '/page-b?param=1', + ], + 'Use Case #9: Rewrite: page-similar-query-param --(301)--> page-d?param1=1;' + . 'Request: page-similar-query-param --(301)--> page-d?param1=1' => [ + 'request' => '/page-similar-query-param', + 'redirect' => '/page-d?param1=1', + ], + 'Use Case #10: Rewrite: page-similar-query-param --(301)--> page-d?param1=1; ' + . 'Request: page-similar-query-param?param2=1 --(301)--> page-d?param1=1¶m2=1' => [ + 'request' => '/page-similar-query-param?param2=1', + 'redirect' => '/page-d?param1=1¶m2=1', + ], + 'Use Case #11: Rewrite: page-similar-query-param/ --(301)--> page-e?param1=1; ' + . 'Request: page-similar-query-param/ --(301)--> page-e?param1=1' => [ + 'request' => '/page-similar-query-param/', + 'redirect' => '/page-e?param1=1', + ], + 'Use Case #12: Rewrite: page-similar-query-param/ --(301)--> page-e?param1=1;' + . 'Request: page-similar-query-param/?param2=1 --(301)--> page-e?param1=1¶m2=1' => [ + 'request' => '/page-similar-query-param/?param2=1', + 'redirect' => '/page-e?param1=1¶m2=1', + ], ]; } } diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/_files/url_rewrite.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/_files/url_rewrite.php index 8e82aa853d4a4..dc3f5490f5a53 100644 --- a/dev/tests/integration/testsuite/Magento/UrlRewrite/_files/url_rewrite.php +++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/_files/url_rewrite.php @@ -64,6 +64,26 @@ ->setStores([$storeID, $secondStoreId]); $pageResource->save($page); +$page = $objectManager->create(Page::class); +$page->setTitle('Cms D') + ->setIdentifier('page-d') + ->setIsActive(1) + ->setContent('

Cms Page D

') + ->setPageLayout('1column') + ->setCustomTheme('Magento/blank') + ->setStores([$storeID, $secondStoreId]); +$pageResource->save($page); + +$page = $objectManager->create(Page::class); +$page->setTitle('Cms E') + ->setIdentifier('page-e') + ->setIsActive(1) + ->setContent('

Cms Page E

') + ->setPageLayout('1column') + ->setCustomTheme('Magento/blank') + ->setStores([$storeID, $secondStoreId]); +$pageResource->save($page); + $rewrite = $objectManager->create(UrlRewrite::class); $rewrite->setEntityType('custom') ->setRequestPath('page-one/') @@ -88,7 +108,7 @@ ->setTargetPath('page-a') ->setRedirectType(OptionProvider::PERMANENT) ->setStoreId($storeID) - ->setDescription('From age-similar without trailing slash to page-a'); + ->setDescription('From page-similar without trailing slash to page-a'); $rewriteResource->save($rewrite); $rewrite = $objectManager->create(UrlRewrite::class); @@ -97,7 +117,7 @@ ->setTargetPath('page-b') ->setRedirectType(OptionProvider::PERMANENT) ->setStoreId($storeID) - ->setDescription('From age-similar with trailing slash to page-b'); + ->setDescription('From page-similar with trailing slash to page-b'); $rewriteResource->save($rewrite); //Emulating auto-generated aliases (like the ones used for categories). @@ -117,3 +137,21 @@ ->setRedirectType(0) ->setStoreId($secondStoreId); $rewriteResource->save($rewrite); + +$rewrite = $objectManager->create(UrlRewrite::class); +$rewrite->setEntityType('custom') + ->setRequestPath('page-similar-query-param') + ->setTargetPath('page-d?param1=1') + ->setRedirectType(OptionProvider::PERMANENT) + ->setStoreId($storeID) + ->setDescription('From page-similar-query-param to page-d with query param'); +$rewriteResource->save($rewrite); + +$rewrite = $objectManager->create(UrlRewrite::class); +$rewrite->setEntityType('custom') + ->setRequestPath('page-similar-query-param/') + ->setTargetPath('page-e?param1=1') + ->setRedirectType(OptionProvider::PERMANENT) + ->setStoreId($storeID) + ->setDescription('From page-similar-query-param with trailing slash to page-e with query param'); +$rewriteResource->save($rewrite); diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/_files/url_rewrite_rollback.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/_files/url_rewrite_rollback.php index 22d95751fbf26..76b84810ac433 100644 --- a/dev/tests/integration/testsuite/Magento/UrlRewrite/_files/url_rewrite_rollback.php +++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/_files/url_rewrite_rollback.php @@ -19,6 +19,8 @@ $pageRepository->deleteById('page-a'); $pageRepository->deleteById('page-b'); $pageRepository->deleteById('page-c'); +$pageRepository->deleteById('page-d'); +$pageRepository->deleteById('page-e'); /** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ $productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() @@ -29,7 +31,7 @@ ->create(\Magento\UrlRewrite\Model\ResourceModel\UrlRewriteCollection::class); $collection = $urlRewriteCollection ->addFieldToFilter('entity_type', 'custom') - ->addFieldToFilter('target_path', ['page-a/', 'page-a', 'page-b', 'page-c']) + ->addFieldToFilter('target_path', ['page-a/', 'page-a', 'page-b', 'page-c', 'page-d?param1=1', 'page-e?param1=1']) ->load() ->walk('delete'); From b1a2a29671de32d90dbc10a3b0ced6a3d71b2b72 Mon Sep 17 00:00:00 2001 From: Ihor Sviziev Date: Tue, 3 Dec 2019 21:45:36 +0200 Subject: [PATCH 06/39] magento/magento2#25603 Fix removing query string from url after redirect Cover with integration tests cases with external URLs as target path --- .../UrlRewrite/Controller/UrlRewriteTest.php | 27 ++++++++++++-- .../Magento/UrlRewrite/_files/url_rewrite.php | 36 +++++++++++++++++++ .../_files/url_rewrite_rollback.php | 16 ++++++++- 3 files changed, 76 insertions(+), 3 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php index b6a551cc6ad50..cea44226f6192 100644 --- a/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php +++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php @@ -44,8 +44,7 @@ public function testMatchUrlRewrite( $location = $response->getHeader('Location')->getFieldValue(); $this->assertStringEndsWith( $redirect, - $location, - 'Invalid location header' + $location ); } } @@ -110,6 +109,30 @@ public function requestDataProvider(): array 'request' => '/page-similar-query-param/?param2=1', 'redirect' => '/page-e?param1=1¶m2=1', ], + 'Use Case #13: Rewrite: page-external1 --(301)--> http://example.com/external;' + . 'Request: page-external1?param1=1 --(301)--> http://example.com/external (not fills get params)' => [ + 'request' => '/page-external1?param1=1', + 'redirect' => 'http://example.com/external', + ], + 'Use Case #14: Rewrite: page-external2/ --(301)--> https://example.com/external2/;' + . 'Request: page-external2?param2=1 --(301)--> https://example.com/external2/ (not fills get params)' => [ + 'request' => '/page-external2?param2=1', + 'redirect' => 'https://example.com/external2/', + ], + 'Use Case #15: Rewrite: page-external3 --(301)--> http://example.com/external?param1=value1;' + . 'Request: page-external3?param1=custom1¶m2=custom2 --(301)--> ' + . 'http://example.com/external?param1=value1' + . ' (fills get param from target path)' => [ + 'request' => '/page-external3?param1=custom1¶m2=custom2', + 'redirect' => 'http://example.com/external?param1=value1', + ], + 'Use Case #16: Rewrite: page-external4/ --(301)--> https://example.com/external2/?param2=value2;' + . 'Request: page-external4?param1=custom1¶m2=custom2 --(301)--> ' + . 'https://example.com/external2/?param2=value2 ' + . ' (fills get param from target path)' => [ + 'request' => '/page-external4?param1=custom1¶m2=custom2', + 'redirect' => 'https://example.com/external2/?param2=value2', + ], ]; } } diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/_files/url_rewrite.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/_files/url_rewrite.php index dc3f5490f5a53..68d1212539c6d 100644 --- a/dev/tests/integration/testsuite/Magento/UrlRewrite/_files/url_rewrite.php +++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/_files/url_rewrite.php @@ -155,3 +155,39 @@ ->setStoreId($storeID) ->setDescription('From page-similar-query-param with trailing slash to page-e with query param'); $rewriteResource->save($rewrite); + +$rewrite = $objectManager->create(UrlRewrite::class); +$rewrite->setEntityType('custom') + ->setRequestPath('page-external1') + ->setTargetPath('http://example.com/external') + ->setRedirectType(OptionProvider::PERMANENT) + ->setStoreId($storeID) + ->setDescription('From page-external to external URL'); +$rewriteResource->save($rewrite); + +$rewrite = $objectManager->create(UrlRewrite::class); +$rewrite->setEntityType('custom') + ->setRequestPath('page-external2/') + ->setTargetPath('https://example.com/external2/') + ->setRedirectType(OptionProvider::PERMANENT) + ->setStoreId($storeID) + ->setDescription('From page-external with trailing slash to external URL'); +$rewriteResource->save($rewrite); + +$rewrite = $objectManager->create(UrlRewrite::class); +$rewrite->setEntityType('custom') + ->setRequestPath('page-external3') + ->setTargetPath('http://example.com/external?param1=value1') + ->setRedirectType(OptionProvider::PERMANENT) + ->setStoreId($storeID) + ->setDescription('From page-external to external URL'); +$rewriteResource->save($rewrite); + +$rewrite = $objectManager->create(UrlRewrite::class); +$rewrite->setEntityType('custom') + ->setRequestPath('page-external4/') + ->setTargetPath('https://example.com/external2/?param2=value2') + ->setRedirectType(OptionProvider::PERMANENT) + ->setStoreId($storeID) + ->setDescription('From page-external with trailing slash to external URL'); +$rewriteResource->save($rewrite); diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/_files/url_rewrite_rollback.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/_files/url_rewrite_rollback.php index 76b84810ac433..a5c21f7a00e48 100644 --- a/dev/tests/integration/testsuite/Magento/UrlRewrite/_files/url_rewrite_rollback.php +++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/_files/url_rewrite_rollback.php @@ -31,7 +31,21 @@ ->create(\Magento\UrlRewrite\Model\ResourceModel\UrlRewriteCollection::class); $collection = $urlRewriteCollection ->addFieldToFilter('entity_type', 'custom') - ->addFieldToFilter('target_path', ['page-a/', 'page-a', 'page-b', 'page-c', 'page-d?param1=1', 'page-e?param1=1']) + ->addFieldToFilter( + 'target_path', + [ + 'page-a/', + 'page-a', + 'page-b', + 'page-c', + 'page-d?param1=1', + 'page-e?param1=1', + 'http://example.com/external', + 'https://example.com/external2/', + 'http://example.com/external?param1=value1', + 'https://example.com/external2/?param2=value2' + ] + ) ->load() ->walk('delete'); From 232e80880ac92153109032a5f5409aad6d5ae38d Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Mon, 9 Dec 2019 13:11:50 +0200 Subject: [PATCH 07/39] 14663-customer-group-rest-api-fix --- .../Model/ResourceModel/CustomerRepository.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php b/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php index 03cf4b1bdddec..1f2d3726b8fa7 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php +++ b/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php @@ -214,6 +214,7 @@ public function save(CustomerInterface $customer, $passwordHash = null) $prevCustomerData ? $prevCustomerData->getStoreId() : $this->storeManager->getStore()->getId() ); } + $this->setCustomerGroupId($customerModel, $customerArr, $prevCustomerDataArr); // Need to use attribute set or future updates can cause data loss if (!$customerModel->getAttributeSetId()) { $customerModel->setAttributeSetId(CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER); @@ -452,4 +453,18 @@ private function setValidationFlag($customerArray, $customerModel) $customerModel->setData('ignore_validation_flag', true); } } + + /** + * Set customer group id + * + * @param Customer $customerModel + * @param array $customerArr + * @param array $prevCustomerDataArr + */ + private function setCustomerGroupId($customerModel, $customerArr, $prevCustomerDataArr) + { + if (!isset($customerArr['group_id']) && $prevCustomerDataArr && isset($prevCustomerDataArr['group_id'])) { + $customerModel->setGroupId($prevCustomerDataArr['group_id']); + } + } } From 1a1ca42ff4af7e5621455ed92eb76e5dddadeadb Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Mon, 9 Dec 2019 16:31:50 +0200 Subject: [PATCH 08/39] fix code style --- .../Customer/Model/ResourceModel/CustomerRepository.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php b/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php index 1f2d3726b8fa7..323b6c5d53714 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php +++ b/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php @@ -31,6 +31,8 @@ /** * Customer repository. * + * CRUD operations for customer entity + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) */ @@ -187,8 +189,7 @@ public function save(CustomerInterface $customer, $passwordHash = null) { /** @var NewOperation|null $delegatedNewOperation */ $delegatedNewOperation = !$customer->getId() ? $this->delegatedStorage->consumeNewOperation() : null; - $prevCustomerData = null; - $prevCustomerDataArr = null; + $prevCustomerData = $prevCustomerDataArr = null; if ($customer->getId()) { $prevCustomerData = $this->getById($customer->getId()); $prevCustomerDataArr = $prevCustomerData->__toArray(); From a882be9e27c602755fd79c2cc79b217b358a9f38 Mon Sep 17 00:00:00 2001 From: divyajyothi5321 <54176640+divyajyothi5321@users.noreply.github.com> Date: Mon, 16 Dec 2019 20:45:15 +0530 Subject: [PATCH 09/39] 26064 issuefix --- app/code/Magento/Wishlist/Controller/Index/Send.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Wishlist/Controller/Index/Send.php b/app/code/Magento/Wishlist/Controller/Index/Send.php index 54aa53d829db5..1ff4e3a653a2d 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Send.php +++ b/app/code/Magento/Wishlist/Controller/Index/Send.php @@ -204,7 +204,7 @@ public function execute() $error = __('Please enter an email address.'); } else { if (count($emails) > $emailsLeft) { - $error = __('This wish list can be shared %1 more times.', $emailsLeft); + $error = __('Maximum of %1 Emails can be Sent.', $emailsLeft); } else { foreach ($emails as $index => $email) { $email = trim($email); From 13f34cd6e15c0e1ce1b1183761d3ca4bfc318c22 Mon Sep 17 00:00:00 2001 From: Marco Oliveira Date: Tue, 17 Dec 2019 15:14:50 -0300 Subject: [PATCH 10/39] Fixing #26083 --- app/code/Magento/Payment/Model/Info.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Payment/Model/Info.php b/app/code/Magento/Payment/Model/Info.php index 3b7f93be776ee..39a5a4cdc70a3 100644 --- a/app/code/Magento/Payment/Model/Info.php +++ b/app/code/Magento/Payment/Model/Info.php @@ -188,6 +188,7 @@ public function getAdditionalInformation($key = null) */ public function unsAdditionalInformation($key = null) { + $this->_initAdditionalInformation(); if ($key && isset($this->_additionalInformation[$key])) { unset($this->_additionalInformation[$key]); return $this->setData('additional_information', $this->_additionalInformation); From 32227d2773836da0574db70fac8aad46ac0dad83 Mon Sep 17 00:00:00 2001 From: Marco Oliveira Date: Tue, 17 Dec 2019 16:37:50 -0300 Subject: [PATCH 11/39] Removing an unnecessary , --- app/code/Magento/Payment/Model/Info.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Payment/Model/Info.php b/app/code/Magento/Payment/Model/Info.php index 39a5a4cdc70a3..3ca9b072e8321 100644 --- a/app/code/Magento/Payment/Model/Info.php +++ b/app/code/Magento/Payment/Model/Info.php @@ -38,7 +38,7 @@ class Info extends AbstractExtensibleModel implements InfoInterface * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory - * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, + * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource From e830f2e93ffb37a48d149ad4f4a3a18bcbe218a4 Mon Sep 17 00:00:00 2001 From: divyajyothi5321 <54176640+divyajyothi5321@users.noreply.github.com> Date: Wed, 18 Dec 2019 12:37:36 +0530 Subject: [PATCH 12/39] Added requested Changes --- app/code/Magento/Wishlist/Controller/Index/Send.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Wishlist/Controller/Index/Send.php b/app/code/Magento/Wishlist/Controller/Index/Send.php index 1ff4e3a653a2d..f0bd2c4b4b37c 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Send.php +++ b/app/code/Magento/Wishlist/Controller/Index/Send.php @@ -27,7 +27,6 @@ /** * Class Send * - * @package Magento\Wishlist\Controller\Index * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Send extends \Magento\Wishlist\Controller\AbstractIndex implements Action\HttpPostActionInterface From 0d220177689ce7ffbfcb29ed9316e46b708a02c5 Mon Sep 17 00:00:00 2001 From: divyajyothi5321 <54176640+divyajyothi5321@users.noreply.github.com> Date: Wed, 18 Dec 2019 13:53:30 +0530 Subject: [PATCH 13/39] Changes Added --- app/code/Magento/Wishlist/Controller/Index/Send.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Wishlist/Controller/Index/Send.php b/app/code/Magento/Wishlist/Controller/Index/Send.php index f0bd2c4b4b37c..b7c93473cde94 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Send.php +++ b/app/code/Magento/Wishlist/Controller/Index/Send.php @@ -25,7 +25,7 @@ use Magento\Customer\Model\Customer; /** - * Class Send + * Class Send Email Wishlist Controller * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ From 731c456463ede2d22a408447386dd83818bb3c63 Mon Sep 17 00:00:00 2001 From: Roman Hanin Date: Wed, 18 Dec 2019 13:57:11 -0600 Subject: [PATCH 14/39] B2B-272: Remove Ship To column, fix pagination selector --- app/code/Magento/Theme/view/frontend/templates/html/pager.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Theme/view/frontend/templates/html/pager.phtml b/app/code/Magento/Theme/view/frontend/templates/html/pager.phtml index bd50fa39d4099..a6cd29c3713ac 100644 --- a/app/code/Magento/Theme/view/frontend/templates/html/pager.phtml +++ b/app/code/Magento/Theme/view/frontend/templates/html/pager.phtml @@ -120,7 +120,7 @@ escapeHtml(__('Show')) ?> - getAvailableLimit() as $_key => $_limit) : ?> + getAvailableLimit() as $_key => $_limit): ?> @@ -133,7 +133,7 @@ - getUseContainer()) : ?> + getUseContainer()): ?> From cfd5c22848f82f29f69cd42ffbcc8e09fa848568 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Szubert?= Date: Thu, 19 Dec 2019 05:00:50 +0100 Subject: [PATCH 17/39] Fix #25390 - fix backward incompatible constructor in UPS carrier, cleanup of class imports --- app/code/Magento/Ups/Model/Carrier.php | 160 ++++++++++++++----------- 1 file changed, 90 insertions(+), 70 deletions(-) diff --git a/app/code/Magento/Ups/Model/Carrier.php b/app/code/Magento/Ups/Model/Carrier.php index 9e33b86ea8215..103ba9d3fb4b7 100644 --- a/app/code/Magento/Ups/Model/Carrier.php +++ b/app/code/Magento/Ups/Model/Carrier.php @@ -7,6 +7,12 @@ namespace Magento\Ups\Model; +use Magento\CatalogInventory\Api\StockRegistryInterface; +use Magento\Directory\Helper\Data; +use Magento\Directory\Model\CountryFactory; +use Magento\Directory\Model\CurrencyFactory; +use Magento\Directory\Model\RegionFactory; +use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\ObjectManager; use Magento\Framework\Async\CallbackDeferred; use Magento\Framework\DataObject; @@ -15,16 +21,30 @@ use Magento\Framework\HTTP\AsyncClient\Request; use Magento\Framework\HTTP\AsyncClientInterface; use Magento\Framework\HTTP\ClientFactory; +use Magento\Framework\Locale\FormatInterface; use Magento\Framework\Xml\Security; use Magento\Quote\Model\Quote\Address\RateRequest; use Magento\Quote\Model\Quote\Address\RateResult\Error; +use Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory as RateErrorFactory; +use Magento\Quote\Model\Quote\Address\RateResult\MethodFactory as RateMethodFactory; +use Magento\Sales\Model\Order\Shipment as OrderShipment; use Magento\Shipping\Model\Carrier\AbstractCarrierOnline; use Magento\Shipping\Model\Carrier\CarrierInterface; use Magento\Shipping\Model\Rate\Result; use Magento\Shipping\Model\Rate\Result\ProxyDeferredFactory; +use Magento\Shipping\Model\Rate\ResultFactory as RateFactory; use Magento\Shipping\Model\Simplexml\Element; +use Magento\Shipping\Model\Simplexml\ElementFactory; +use Magento\Shipping\Model\Tracking\Result\ErrorFactory as TrackErrorFactory; +use Magento\Shipping\Model\Tracking\Result\StatusFactory as TrackStatusFactory; +use Magento\Shipping\Model\Tracking\ResultFactory as TrackFactory; +use Magento\Store\Model\ScopeInterface; use Magento\Ups\Helper\Config; use Magento\Shipping\Model\Shipment\Request as Shipment; +use Psr\Log\LoggerInterface; +use RuntimeException; +use Throwable; +use Zend_Http_Client; /** * UPS shipping implementation @@ -117,12 +137,12 @@ class Carrier extends AbstractCarrierOnline implements CarrierInterface protected $_customizableContainerTypes = ['CP', 'CSP']; /** - * @var \Magento\Framework\Locale\FormatInterface + * @var FormatInterface */ protected $_localeFormat; /** - * @var \Psr\Log\LoggerInterface + * @var LoggerInterface */ protected $_logger; @@ -149,22 +169,22 @@ class Carrier extends AbstractCarrierOnline implements CarrierInterface private $deferredProxyFactory; /** - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory - * @param \Psr\Log\LoggerInterface $logger + * @param ScopeConfigInterface $scopeConfig + * @param RateErrorFactory $rateErrorFactory + * @param LoggerInterface $logger * @param Security $xmlSecurity - * @param \Magento\Shipping\Model\Simplexml\ElementFactory $xmlElFactory - * @param \Magento\Shipping\Model\Rate\ResultFactory $rateFactory - * @param \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory - * @param \Magento\Shipping\Model\Tracking\ResultFactory $trackFactory - * @param \Magento\Shipping\Model\Tracking\Result\ErrorFactory $trackErrorFactory - * @param \Magento\Shipping\Model\Tracking\Result\StatusFactory $trackStatusFactory - * @param \Magento\Directory\Model\RegionFactory $regionFactory - * @param \Magento\Directory\Model\CountryFactory $countryFactory - * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Directory\Helper\Data $directoryData - * @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry - * @param \Magento\Framework\Locale\FormatInterface $localeFormat + * @param ElementFactory $xmlElFactory + * @param RateFactory $rateFactory + * @param RateMethodFactory $rateMethodFactory + * @param TrackFactory $trackFactory + * @param TrackErrorFactory $trackErrorFactory + * @param TrackStatusFactory $trackStatusFactory + * @param RegionFactory $regionFactory + * @param CountryFactory $countryFactory + * @param CurrencyFactory $currencyFactory + * @param Data $directoryData + * @param StockRegistryInterface $stockRegistry + * @param FormatInterface $localeFormat * @param Config $configHelper * @param ClientFactory $httpClientFactory * @param array $data @@ -175,27 +195,27 @@ class Carrier extends AbstractCarrierOnline implements CarrierInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function __construct( - \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory, - \Psr\Log\LoggerInterface $logger, + ScopeConfigInterface $scopeConfig, + RateErrorFactory $rateErrorFactory, + LoggerInterface $logger, Security $xmlSecurity, - \Magento\Shipping\Model\Simplexml\ElementFactory $xmlElFactory, - \Magento\Shipping\Model\Rate\ResultFactory $rateFactory, - \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory, - \Magento\Shipping\Model\Tracking\ResultFactory $trackFactory, - \Magento\Shipping\Model\Tracking\Result\ErrorFactory $trackErrorFactory, - \Magento\Shipping\Model\Tracking\Result\StatusFactory $trackStatusFactory, - \Magento\Directory\Model\RegionFactory $regionFactory, - \Magento\Directory\Model\CountryFactory $countryFactory, - \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Directory\Helper\Data $directoryData, - \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry, - \Magento\Framework\Locale\FormatInterface $localeFormat, + ElementFactory $xmlElFactory, + RateFactory $rateFactory, + RateMethodFactory $rateMethodFactory, + TrackFactory $trackFactory, + TrackErrorFactory $trackErrorFactory, + TrackStatusFactory $trackStatusFactory, + RegionFactory $regionFactory, + CountryFactory $countryFactory, + CurrencyFactory $currencyFactory, + Data $directoryData, + StockRegistryInterface $stockRegistry, + FormatInterface $localeFormat, Config $configHelper, ClientFactory $httpClientFactory, array $data = [], ?AsyncClientInterface $asyncHttpClient = null, - ?ProxyDeferredFactory $proxyDeferredFactory + ?ProxyDeferredFactory $proxyDeferredFactory = null ) { parent::__construct( $scopeConfig, @@ -265,7 +285,7 @@ public function setRequest(RateRequest $request) { $this->_request = $request; - $rowRequest = new \Magento\Framework\DataObject(); + $rowRequest = new DataObject(); if ($request->getLimitMethod()) { $rowRequest->setAction($this->configHelper->getCode('action', 'single')); @@ -300,8 +320,8 @@ public function setRequest(RateRequest $request) $origCountry = $request->getOrigCountry(); } else { $origCountry = $this->_scopeConfig->getValue( - \Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_COUNTRY_ID, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + OrderShipment::XML_PATH_STORE_COUNTRY_ID, + ScopeInterface::SCOPE_STORE, $request->getStoreId() ); } @@ -312,8 +332,8 @@ public function setRequest(RateRequest $request) $origRegionCode = $request->getOrigRegionCode(); } else { $origRegionCode = $this->_scopeConfig->getValue( - \Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_REGION_ID, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + OrderShipment::XML_PATH_STORE_REGION_ID, + ScopeInterface::SCOPE_STORE, $request->getStoreId() ); } @@ -327,8 +347,8 @@ public function setRequest(RateRequest $request) } else { $rowRequest->setOrigPostal( $this->_scopeConfig->getValue( - \Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_ZIP, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + OrderShipment::XML_PATH_STORE_ZIP, + ScopeInterface::SCOPE_STORE, $request->getStoreId() ) ); @@ -339,8 +359,8 @@ public function setRequest(RateRequest $request) } else { $rowRequest->setOrigCity( $this->_scopeConfig->getValue( - \Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_CITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + OrderShipment::XML_PATH_STORE_CITY, + ScopeInterface::SCOPE_STORE, $request->getStoreId() ) ); @@ -516,7 +536,7 @@ protected function _getCgiQuotes() if (!$url) { $url = $this->_defaultCgiGatewayUrl; } - $client = new \Zend_Http_Client(); + $client = new Zend_Http_Client(); $client->setUri($url); $client->setConfig(['maxredirects' => 0, 'timeout' => 30]); $client->setParameterGet($params); @@ -525,7 +545,7 @@ protected function _getCgiQuotes() $debugData['result'] = $responseBody; $this->_setCachedQuotes($params, $responseBody); - } catch (\Throwable $e) { + } catch (Throwable $e) { $debugData['result'] = ['error' => $e->getMessage(), 'code' => $e->getCode()]; $responseBody = ''; } @@ -727,7 +747,7 @@ protected function _getXmlQuotes() {$shipperStateProvince} - +
{$params['19_destPostal']} @@ -743,7 +763,7 @@ protected function _getXmlQuotes() $xmlParams .= << - +
{$params['15_origPostal']} @@ -1056,7 +1076,7 @@ protected function setXMLAccessRequest() * Get cgi tracking * * @param string[] $trackings - * @return \Magento\Shipping\Model\Tracking\ResultFactory + * @return TrackFactory */ protected function _getCgiTracking($trackings) { @@ -1321,13 +1341,13 @@ public function getAllowedMethods() /** * Form XML for shipment request * - * @param \Magento\Framework\DataObject $request + * @param DataObject $request * @return string * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - protected function _formShipmentRequest(\Magento\Framework\DataObject $request) + protected function _formShipmentRequest(DataObject $request) { $packageParams = $request->getPackageParams(); $height = $packageParams->getHeight(); @@ -1339,7 +1359,7 @@ protected function _formShipmentRequest(\Magento\Framework\DataObject $request) $itemsDesc = []; $itemsShipment = $request->getPackageItems(); foreach ($itemsShipment as $itemShipment) { - $item = new \Magento\Framework\DataObject(); + $item = new DataObject(); $item->setData($itemShipment); $itemsDesc[] = $item->getName(); } @@ -1533,7 +1553,7 @@ protected function _formShipmentRequest(\Magento\Framework\DataObject $request) * Send and process shipment accept request * * @param Element $shipmentConfirmResponse - * @return \Magento\Framework\DataObject + * @return DataObject * @deprecated New asynchronous methods introduced. * @see requestToShipment */ @@ -1559,18 +1579,18 @@ protected function _sendShipmentAcceptRequest(Element $shipmentConfirmResponse) $xmlResponse = $deferredResponse->get()->getBody(); $debugData['result'] = $xmlResponse; $this->_setCachedQuotes($xmlRequest, $xmlResponse); - } catch (\Throwable $e) { + } catch (Throwable $e) { $debugData['result'] = ['error' => $e->getMessage(), 'code' => $e->getCode()]; $xmlResponse = ''; } try { $response = $this->_xmlElFactory->create(['data' => $xmlResponse]); - } catch (\Throwable $e) { + } catch (Throwable $e) { $debugData['result'] = ['error' => $e->getMessage(), 'code' => $e->getCode()]; } - $result = new \Magento\Framework\DataObject(); + $result = new DataObject(); if (isset($response->Error)) { $result->setErrors((string)$response->Error->ErrorDescription); } else { @@ -1609,7 +1629,7 @@ public function getShipAcceptUrl() * @param DataObject[] $packages * @return string[] Quote IDs. * @throws LocalizedException - * @throws \RuntimeException + * @throws RuntimeException */ private function requestQuotes(array $packages): array { @@ -1640,13 +1660,13 @@ private function requestQuotes(array $packages): array try { /** @var Element $response */ $response = $this->_xmlElFactory->create(['data' => $httpResponse->getBody()]); - } catch (\Throwable $e) { - throw new \RuntimeException($e->getMessage()); + } catch (Throwable $e) { + throw new RuntimeException($e->getMessage()); } if (isset($response->Response->Error) && in_array($response->Response->Error->ErrorSeverity, ['Hard', 'Transient']) ) { - throw new \RuntimeException((string)$response->Response->Error->ErrorDescription); + throw new RuntimeException((string)$response->Response->Error->ErrorDescription); } $ids[] = $response->ShipmentDigest; @@ -1661,7 +1681,7 @@ private function requestQuotes(array $packages): array * @param string[] $quoteIds * @return DataObject[] * @throws LocalizedException - * @throws \RuntimeException + * @throws RuntimeException */ private function requestShipments(array $quoteIds): array { @@ -1697,11 +1717,11 @@ private function requestShipments(array $quoteIds): array try { /** @var Element $response */ $response = $this->_xmlElFactory->create(['data' => $httpResponse->getBody()]); - } catch (\Throwable $e) { - throw new \RuntimeException($e->getMessage()); + } catch (Throwable $e) { + throw new RuntimeException($e->getMessage()); } if (isset($response->Error)) { - throw new \RuntimeException((string)$response->Error->ErrorDescription); + throw new RuntimeException((string)$response->Error->ErrorDescription); } else { $shippingLabelContent = (string)$response->ShipmentResults->PackageResults->LabelImage->GraphicImage; $trackingNumber = (string)$response->ShipmentResults->PackageResults->TrackingNumber; @@ -1726,7 +1746,7 @@ private function requestShipments(array $quoteIds): array protected function _doShipmentRequest(DataObject $request) { $this->_prepareShipmentRequest($request); - $result = new \Magento\Framework\DataObject(); + $result = new DataObject(); $rawXmlRequest = $this->_formShipmentRequest($request); $this->setXMLAccessRequest(); $xmlRequest = $this->_xmlAccessRequest . $rawXmlRequest; @@ -1747,14 +1767,14 @@ protected function _doShipmentRequest(DataObject $request) $xmlResponse = $deferredResponse->get()->getBody(); $debugData['result'] = $xmlResponse; $this->_setCachedQuotes($xmlRequest, $xmlResponse); - } catch (\Throwable $e) { + } catch (Throwable $e) { $debugData['result'] = ['code' => $e->getCode(), 'error' => $e->getMessage()]; } } try { $response = $this->_xmlElFactory->create(['data' => $xmlResponse]); - } catch (\Throwable $e) { + } catch (Throwable $e) { $debugData['result'] = ['error' => $e->getMessage(), 'code' => $e->getCode()]; $result->setErrors($e->getMessage()); } @@ -1827,7 +1847,7 @@ public function requestToShipment($request) $labels = $this->requestShipments($quoteIds); } catch (LocalizedException $exception) { return new DataObject(['errors' => [$exception->getMessage()]]); - } catch (\RuntimeException $exception) { + } catch (RuntimeException $exception) { return new DataObject(['errors' => __('Failed to send items')]); } // phpcs:enable @@ -1848,11 +1868,11 @@ public function returnOfShipment($request) /** * Return container types of carrier * - * @param \Magento\Framework\DataObject|null $params + * @param DataObject|null $params * @return array|bool * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - public function getContainerTypes(\Magento\Framework\DataObject $params = null) + public function getContainerTypes(DataObject $params = null) { if ($params === null) { return $this->_getAllowedContainers($params); @@ -1932,10 +1952,10 @@ public function getContainerTypesFilter() /** * Return delivery confirmation types of carrier * - * @param \Magento\Framework\DataObject|null $params + * @param DataObject|null $params * @return array|bool */ - public function getDeliveryConfirmationTypes(\Magento\Framework\DataObject $params = null) + public function getDeliveryConfirmationTypes(DataObject $params = null) { $countryRecipient = $params != null ? $params->getCountryRecipient() : null; $deliveryConfirmationTypes = []; From 2e1ef16d755bbc6b0f675d8624b47b8f6cf35fa8 Mon Sep 17 00:00:00 2001 From: Roman Hanin Date: Thu, 19 Dec 2019 00:09:15 -0600 Subject: [PATCH 18/39] B2B-272: Remove Ship To column, fix pagination selector --- app/code/Magento/Sales/Block/Order/History.php | 10 ++++++++++ .../Sales/view/frontend/templates/order/history.phtml | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Block/Order/History.php b/app/code/Magento/Sales/Block/Order/History.php index c06a5d8b24c1e..09300424212fe 100644 --- a/app/code/Magento/Sales/Block/Order/History.php +++ b/app/code/Magento/Sales/Block/Order/History.php @@ -188,4 +188,14 @@ public function getBackUrl() { return $this->getUrl('customer/account/'); } + + /** + * Get message for no orders. + * + * @return \Magento\Framework\Phrase + */ + public function getEmptyOrdersMessage() + { + return __('You have placed no orders.'); + } } diff --git a/app/code/Magento/Sales/view/frontend/templates/order/history.phtml b/app/code/Magento/Sales/view/frontend/templates/order/history.phtml index a785ca93511ad..bc1887c7669ca 100644 --- a/app/code/Magento/Sales/view/frontend/templates/order/history.phtml +++ b/app/code/Magento/Sales/view/frontend/templates/order/history.phtml @@ -59,5 +59,5 @@
getPagerHtml() ?>
-
escapeHtml(__('You have placed no orders.')) ?>
+
escapeHtml($block->getEmptyOrdersMessage()) ?>
From 52b66acf17e049dc2c5c7d9e12bd6d29d6a1a16d Mon Sep 17 00:00:00 2001 From: Michael Bottens Date: Tue, 12 Nov 2019 12:06:45 -0500 Subject: [PATCH 19/39] #1057: Emulate area code for graphql category/product attributes --- app/code/Magento/CatalogGraphQl/etc/graphql/di.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/code/Magento/CatalogGraphQl/etc/graphql/di.xml b/app/code/Magento/CatalogGraphQl/etc/graphql/di.xml index 066a7b38d8967..ed548efc896f8 100644 --- a/app/code/Magento/CatalogGraphQl/etc/graphql/di.xml +++ b/app/code/Magento/CatalogGraphQl/etc/graphql/di.xml @@ -176,4 +176,10 @@ + + + + Magento\Widget\Model\Template\FilterEmulate + + From 5fcac84a5d0a080279ff77e681aae051afd9490c Mon Sep 17 00:00:00 2001 From: Karyna Tsymbal Date: Wed, 20 Nov 2019 15:44:32 +0200 Subject: [PATCH 20/39] GraphQl Issue#1061 - Remove redundant logic from resolvers --- .../Customer/SetPaymentMethodTest.php | 120 +----------------- .../Customer/SetPaymentMethodTest.php | 29 ----- .../Braintree/Guest/SetPaymentMethodTest.php | 33 ----- .../Customer/AddSimpleProductToCartTest.php | 56 -------- .../Customer/AddVirtualProductToCartTest.php | 55 -------- .../Quote/Customer/ApplyCouponToCartTest.php | 43 ------- .../GraphQl/Quote/Customer/PlaceOrderTest.php | 20 --- .../Customer/RemoveCouponFromCartTest.php | 23 ---- .../Quote/Customer/RemoveItemFromCartTest.php | 44 ------- .../Customer/SetBillingAddressOnCartTest.php | 9 -- .../SetPaymentMethodAndPlaceOrderTest.php | 11 -- .../Customer/SetPaymentMethodOnCartTest.php | 8 -- .../Customer/SetShippingAddressOnCartTest.php | 13 -- .../Customer/SetShippingMethodsOnCartTest.php | 24 ---- .../Quote/Customer/UpdateCartItemsTest.php | 37 ------ .../Guest/AddSimpleProductToCartTest.php | 51 -------- .../Guest/AddVirtualProductToCartTest.php | 52 -------- .../Quote/Guest/ApplyCouponToCartTest.php | 43 ------- .../Quote/Guest/ApplyCouponsToCartTest.php | 43 ------- .../GraphQl/Quote/Guest/PlaceOrderTest.php | 19 --- .../Quote/Guest/RemoveCouponFromCartTest.php | 22 ---- .../Quote/Guest/RemoveItemFromCartTest.php | 43 ------- .../Guest/SetBillingAddressOnCartTest.php | 52 -------- .../Guest/SetPaymentMethodOnCartTest.php | 8 -- .../Guest/SetShippingAddressOnCartTest.php | 56 -------- .../Guest/SetShippingMethodsOnCartTest.php | 24 ---- .../Quote/Guest/UpdateCartItemsTest.php | 36 ------ 27 files changed, 1 insertion(+), 973 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/AuthorizenetAcceptjs/Customer/SetPaymentMethodTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/AuthorizenetAcceptjs/Customer/SetPaymentMethodTest.php index e9ab4456fae81..d6954c249f209 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/AuthorizenetAcceptjs/Customer/SetPaymentMethodTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/AuthorizenetAcceptjs/Customer/SetPaymentMethodTest.php @@ -157,38 +157,7 @@ function (string $maskedQuoteId) { [ 'Required parameter "authorizenet_acceptjs" for "payment_method" is missing.' ] - ], - [ - function (string $maskedQuoteId) { - return $this->getEmptyAcceptJsInput($maskedQuoteId); - }, - [ - 'Field AuthorizenetInput.cc_last_4 of required type Int! was not provided.', - 'Field AuthorizenetInput.opaque_data_descriptor of required type String! was not provided.', - 'Field AuthorizenetInput.opaque_data_value of required type String! was not provided.' - ] - - ], - [ - function (string $maskedQuoteId) { - return $this->getMissingCcLastFourAcceptJsInput( - $maskedQuoteId, - static::VALID_DESCRIPTOR, - static::VALID_NONCE - ); - }, - [ - 'Field AuthorizenetInput.cc_last_4 of required type Int! was not provided', - ] - ], - [ - function (string $maskedQuoteId) { - return $this->getMissingOpaqueDataValueAcceptJsInput($maskedQuoteId, static::VALID_DESCRIPTOR); - }, - [ - 'Field AuthorizenetInput.opaque_data_value of required type String! was not provided', - ] - ], + ] ]; } @@ -218,93 +187,6 @@ private function getInvalidSetPaymentMutation(string $maskedQuoteId): string QUERY; } - /** - * Get setPaymentMethodOnCart missing required additional data properties - * - * @param string $maskedQuoteId - * @return string - */ - private function getEmptyAcceptJsInput(string $maskedQuoteId): string - { - return <<graphQlMutation($setPaymentQuery, [], '', $this->getHeaderMap()); } - /** - * @magentoConfigFixture default_store carriers/flatrate/active 1 - * @magentoConfigFixture default_store payment/braintree/active 1 - * @magentoConfigFixture default_store payment/braintree_cc_vault/active 1 - * @magentoConfigFixture default_store payment/braintree/environment sandbox - * @magentoConfigFixture default_store payment/braintree/merchant_id def_merchant_id - * @magentoConfigFixture default_store payment/braintree/public_key def_public_key - * @magentoConfigFixture default_store payment/braintree/private_key def_private_key - * @magentoApiDataFixture Magento/Customer/_files/customer.php - * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php - * @expectedException \Exception - */ - public function testSetPaymentMethodWithoutRequiredPaymentMethodInput() - { - $reservedOrderId = 'test_quote'; - $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($reservedOrderId); - - $setPaymentQuery = $this->getSetPaymentBraintreeQueryInvalidPaymentMethodInput($maskedQuoteId); - $this->expectExceptionMessage( - 'Field BraintreeInput.is_active_payment_token_enabler of required type Boolean! was not provided.' - ); - $this->graphQlMutation($setPaymentQuery, [], '', $this->getHeaderMap()); - } - public function dataProviderTestSetPaymentMethodInvalidInput(): array { return [ diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/Guest/SetPaymentMethodTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/Guest/SetPaymentMethodTest.php index c0a7491cbc1bf..b000d6e7ff347 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/Guest/SetPaymentMethodTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/Guest/SetPaymentMethodTest.php @@ -129,39 +129,6 @@ public function testSetPaymentMethodInvalidInput() $this->graphQlMutation($setPaymentQuery); } - /** - * @magentoConfigFixture default_store carriers/flatrate/active 1 - * @magentoConfigFixture default_store payment/braintree/active 1 - * @magentoConfigFixture default_store payment/braintree/environment sandbox - * @magentoConfigFixture default_store payment/braintree/merchant_id def_merchant_id - * @magentoConfigFixture default_store payment/braintree/public_key def_public_key - * @magentoConfigFixture default_store payment/braintree/private_key def_private_key - * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/set_guest_email.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php - * @expectedException \Exception - */ - public function testSetPaymentMethodInvalidMethodInput() - { - $reservedOrderId = 'test_quote'; - $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($reservedOrderId); - - $setPaymentQuery = $this->getSetPaymentBraintreeQueryInvalidMethodInput($maskedQuoteId); - - $this->expectExceptionMessage( - 'Field BraintreeInput.is_active_payment_token_enabler of required type Boolean! was not provided' - ); - $this->expectExceptionMessage( - 'Field BraintreeInput.payment_method_nonce of required type String! was not provided.' - ); - - $this->graphQlMutation($setPaymentQuery); - } - private function assertPlaceOrderResponse(array $response, string $reservedOrderId): void { self::assertArrayHasKey('placeOrder', $response); diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddSimpleProductToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddSimpleProductToCartTest.php index 0c676d86a33da..aca98e946054c 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddSimpleProductToCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddSimpleProductToCartTest.php @@ -82,32 +82,6 @@ public function testAddSimpleProductToCart() self::assertEquals('USD', $rowTotalIncludingTax['currency']); } - /** - * @magentoApiDataFixture Magento/Customer/_files/customer.php - * @expectedException Exception - * @expectedExceptionMessage Field AddSimpleProductsToCartInput.cart_id of required type String! was not provided. - */ - public function testAddSimpleProductToCartIfCartIdIsMissed() - { - $query = <<graphQlMutation($query, [], '', $this->getHeaderMap()); - } - /** * @magentoApiDataFixture Magento/Customer/_files/customer.php * @expectedException Exception @@ -135,36 +109,6 @@ public function testAddSimpleProductToCartIfCartIdIsEmpty() $this->graphQlMutation($query, [], '', $this->getHeaderMap()); } - /** - * @magentoApiDataFixture Magento/Customer/_files/customer.php - * @expectedException Exception - */ - public function testAddSimpleProductToCartIfCartItemsAreMissed() - { - $query = <<expectExceptionMessage( - 'Field AddSimpleProductsToCartInput.cart_items of required type' - . ' [SimpleProductCartItemInput]! was not provided.' - ); - - $this->graphQlMutation($query, [], '', $this->getHeaderMap()); - } - /** * @magentoApiDataFixture Magento/Customer/_files/customer.php * @expectedException Exception diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddVirtualProductToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddVirtualProductToCartTest.php index a7a3028f2a369..4805721de625a 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddVirtualProductToCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddVirtualProductToCartTest.php @@ -54,32 +54,6 @@ public function testAddVirtualProductToCart() self::assertEquals($sku, $response['addVirtualProductsToCart']['cart']['items'][0]['product']['sku']); } - /** - * @magentoApiDataFixture Magento/Customer/_files/customer.php - * @expectedException Exception - * @expectedExceptionMessage Field AddSimpleProductsToCartInput.cart_id of required type String! was not provided. - */ - public function testAddVirtualProductToCartIfCartIdIsMissed() - { - $query = <<graphQlMutation($query, [], '', $this->getHeaderMap()); - } - /** * @magentoApiDataFixture Magento/Customer/_files/customer.php * @expectedException Exception @@ -107,35 +81,6 @@ public function testAddVirtualProductToCartIfCartIdIsEmpty() $this->graphQlMutation($query, [], '', $this->getHeaderMap()); } - /** - * @magentoApiDataFixture Magento/Customer/_files/customer.php - */ - public function testAddVirtualProductToCartIfCartItemsAreMissed() - { - $query = <<expectException(\Exception::class); - $this->expectExceptionMessage( - 'Field AddSimpleProductsToCartInput.cart_items of required type [SimpleProductCartItemInput]!' - . ' was not provided.' - ); - - $this->graphQlMutation($query, [], '', $this->getHeaderMap()); - } - /** * @magentoApiDataFixture Magento/Customer/_files/customer.php * @expectedException Exception diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/ApplyCouponToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/ApplyCouponToCartTest.php index fa96443eaee1e..d96bf77f2ef0e 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/ApplyCouponToCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/ApplyCouponToCartTest.php @@ -183,49 +183,6 @@ public function testApplyCouponWhichIsNotApplicable() $this->graphQlMutation($query, [], '', $this->getHeaderMap()); } - /** - * @param string $input - * @param string $message - * @dataProvider dataProviderUpdateWithMissedRequiredParameters - * @magentoApiDataFixture Magento/Customer/_files/customer.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php - * @expectedException \Exception - */ - public function testApplyCouponWithMissedRequiredParameters(string $input, string $message) - { - $query = <<expectExceptionMessage($message); - $this->graphQlMutation($query, [], '', $this->getHeaderMap()); - } - - /** - * @return array - */ - public function dataProviderUpdateWithMissedRequiredParameters(): array - { - return [ - 'missed_cart_id' => [ - 'coupon_code: "test"', - 'Field ApplyCouponToCartInput.cart_id of required type String! was not provided.' - ], - 'missed_coupon_code' => [ - 'cart_id: "test_quote"', - 'Field ApplyCouponToCartInput.coupon_code of required type String! was not provided.' - ], - ]; - } - /** * Retrieve customer authorization headers * diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/PlaceOrderTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/PlaceOrderTest.php index 189d5ceab838d..88c57cf2fb282 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/PlaceOrderTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/PlaceOrderTest.php @@ -103,26 +103,6 @@ public function testPlaceOrderIfCartIdIsEmpty() $this->graphQlMutation($query, [], '', $this->getHeaderMap()); } - /** - * @magentoApiDataFixture Magento/Customer/_files/customer.php - * @expectedException Exception - * @expectedExceptionMessage Field PlaceOrderInput.cart_id of required type String! was not provided. - */ - public function testPlaceOrderIfCartIdIsMissed() - { - $query = <<graphQlMutation($query, [], '', $this->getHeaderMap()); - } - /** * @magentoApiDataFixture Magento/Customer/_files/customer.php * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/RemoveCouponFromCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/RemoveCouponFromCartTest.php index d4390e902a3f9..1b5a308b5a9a8 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/RemoveCouponFromCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/RemoveCouponFromCartTest.php @@ -70,29 +70,6 @@ public function testRemoveCouponFromCartIfCartIdIsEmpty() $this->graphQlMutation($query, [], '', $this->getHeaderMap()); } - /** - * @magentoApiDataFixture Magento/Customer/_files/customer.php - * @expectedException Exception - * @expectedExceptionMessage Field RemoveCouponFromCartInput.cart_id of required type String! was not provided. - */ - public function testRemoveCouponFromCartIfCartIdIsMissed() - { - $query = <<graphQlMutation($query, [], '', $this->getHeaderMap()); - } - /** * @magentoApiDataFixture Magento/Customer/_files/customer.php * @expectedException Exception diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/RemoveItemFromCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/RemoveItemFromCartTest.php index a14aacc974af6..c93db424834ef 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/RemoveItemFromCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/RemoveItemFromCartTest.php @@ -90,50 +90,6 @@ public function testRemoveNonExistentItem() $this->graphQlMutation($query, [], '', $this->getHeaderMap()); } - /** - * @magentoApiDataFixture Magento/Customer/_files/customer.php - * @param string $input - * @param string $message - * @dataProvider dataProviderUpdateWithMissedRequiredParameters - */ - public function testUpdateWithMissedItemRequiredParameters(string $input, string $message) - { - $query = <<expectExceptionMessage($message); - $this->graphQlMutation($query, [], '', $this->getHeaderMap()); - } - - /** - * @return array - */ - public function dataProviderUpdateWithMissedRequiredParameters(): array - { - return [ - 'missed_cart_id' => [ - 'cart_item_id: 1', - 'Field RemoveItemFromCartInput.cart_id of required type String! was not provided.' - ], - 'missed_cart_item_id' => [ - 'cart_id: "test_quote"', - 'Field RemoveItemFromCartInput.cart_item_id of required type Int! was not provided.' - ], - ]; - } - /** * _security * @magentoApiDataFixture Magento/Customer/_files/customer.php diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php index 19a10d9466a32..05323a5a7ddf4 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php @@ -653,15 +653,6 @@ public function testSetBillingAddressWithoutRequiredParameters(string $input, st public function dataProviderSetWithoutRequiredParameters(): array { return [ - 'missed_billing_address' => [ - 'cart_id: "cart_id_value"', - 'Field SetBillingAddressOnCartInput.billing_address of required type BillingAddressInput!' - . ' was not provided.', - ], - 'missed_cart_id' => [ - 'billing_address: {}', - 'Field SetBillingAddressOnCartInput.cart_id of required type String! was not provided.' - ], 'missed_region' => [ 'cart_id: "cart_id_value" billing_address: { diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodAndPlaceOrderTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodAndPlaceOrderTest.php index 543ce6fe9c8e7..b31ce8a7302a9 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodAndPlaceOrderTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodAndPlaceOrderTest.php @@ -132,17 +132,6 @@ public function testSetPaymentOnCartWithException(string $input, string $message public function dataProviderSetPaymentOnCartWithException(): array { return [ - 'missed_cart_id' => [ - 'payment_method: { - code: "' . Checkmo::PAYMENT_METHOD_CHECKMO_CODE . '" - }', - 'Field SetPaymentMethodAndPlaceOrderInput.cart_id of required type String! was not provided.', - ], - 'missed_payment_method' => [ - 'cart_id: "cart_id_value"', - 'Field SetPaymentMethodAndPlaceOrderInput.payment_method of required type PaymentMethodInput!' - . ' was not provided.', - ], 'place_order_with_out_of_stock_products' => [ 'cart_id: "cart_id_value" payment_method: { diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodOnCartTest.php index da190be333600..57aeda3295268 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodOnCartTest.php @@ -233,14 +233,6 @@ public function testSetDisabledPaymentOnCart() public function dataProviderSetPaymentMethodWithoutRequiredParameters(): array { return [ - 'missed_cart_id' => [ - 'payment_method: {code: "' . Checkmo::PAYMENT_METHOD_CHECKMO_CODE . '"}', - 'Field SetPaymentMethodOnCartInput.cart_id of required type String! was not provided.' - ], - 'missed_payment_method' => [ - 'cart_id: "cart_id_value"', - 'Field SetPaymentMethodOnCartInput.payment_method of required type PaymentMethodInput! was not provided' - ], 'missed_payment_method_code' => [ 'cart_id: "cart_id_value", payment_method: {code: ""}', 'Required parameter "code" for "payment_method" is missing.' diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php index 47a3a13f05221..2a19fb0d10d6a 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php @@ -511,19 +511,6 @@ public function testSetNewShippingAddressWithMissedRequiredStreetParameters() public function dataProviderUpdateWithMissedRequiredParameters(): array { return [ - 'missed_shipping_addresses' => [ - 'cart_id: "cart_id_value"', - 'Field SetShippingAddressesOnCartInput.shipping_addresses of required type [ShippingAddressInput]! ' . - 'was not provided.', - ], - 'missed_city' => [ - 'shipping_addresses: [ { address: { save_in_address_book: false } } ]', - 'Field CartAddressInput.city of required type String! was not provided' - ], - 'missed_cart_id' => [ - 'shipping_addresses: {}', - 'Field SetShippingAddressesOnCartInput.cart_id of required type String! was not provided.' - ], 'missed_region' => [ 'cart_id: "cart_id_value" shipping_addresses: [{ diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingMethodsOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingMethodsOnCartTest.php index 149a2fbb1da32..293bfdaf502d9 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingMethodsOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingMethodsOnCartTest.php @@ -169,28 +169,10 @@ public function testSetShippingMethodWithWrongParameters(string $input, string $ public function dataProviderSetShippingMethodWithWrongParameters(): array { return [ - 'missed_cart_id' => [ - 'shipping_methods: [{ - carrier_code: "flatrate" - method_code: "flatrate" - }]', - 'Field SetShippingMethodsOnCartInput.cart_id of required type String! was not provided.' - ], - 'missed_shipping_methods' => [ - 'cart_id: "cart_id_value"', - 'Field SetShippingMethodsOnCartInput.shipping_methods of required type [ShippingMethodInput]!' - . ' was not provided.' - ], 'shipping_methods_are_empty' => [ 'cart_id: "cart_id_value" shipping_methods: []', 'Required parameter "shipping_methods" is missing' ], - 'missed_carrier_code' => [ - 'cart_id: "cart_id_value", shipping_methods: [{ - method_code: "flatrate" - }]', - 'Field ShippingMethodInput.carrier_code of required type String! was not provided.' - ], 'empty_carrier_code' => [ 'cart_id: "cart_id_value", shipping_methods: [{ carrier_code: "" @@ -205,12 +187,6 @@ public function dataProviderSetShippingMethodWithWrongParameters(): array }]', 'Carrier with such method not found: wrong-carrier-code, flatrate' ], - 'missed_method_code' => [ - 'cart_id: "cart_id_value", shipping_methods: [{ - carrier_code: "flatrate" - }]', - 'Field ShippingMethodInput.method_code of required type String! was not provided.' - ], 'empty_method_code' => [ 'cart_id: "cart_id_value", shipping_methods: [{ carrier_code: "flatrate" diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/UpdateCartItemsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/UpdateCartItemsTest.php index 1ec2de36a0bc2..b351872a69bc7 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/UpdateCartItemsTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/UpdateCartItemsTest.php @@ -209,35 +209,6 @@ public function testUpdateItemInAnotherCustomerCart() $this->graphQlMutation($query, [], '', $this->getHeaderMap()); } - /** - * @magentoApiDataFixture Magento/Customer/_files/customer.php - * @expectedException \Exception - * @expectedExceptionMessage Field UpdateCartItemsInput.cart_id of required type String! was not provided. - */ - public function testUpdateWithMissedCartItemId() - { - $query = <<graphQlMutation($query, [], '', $this->getHeaderMap()); - } - /** * @param string $input * @param string $message @@ -275,14 +246,6 @@ public function testUpdateWithMissedItemRequiredParameters(string $input, string public function dataProviderUpdateWithMissedRequiredParameters(): array { return [ - 'missed_cart_items' => [ - '', - 'Field UpdateCartItemsInput.cart_items of required type [CartItemUpdateInput]! was not provided.' - ], - 'missed_cart_item_id' => [ - 'cart_items: [{ quantity: 2 }]', - 'Field CartItemUpdateInput.cart_item_id of required type Int! was not provided.' - ], 'missed_cart_item_qty' => [ 'cart_items: [{ cart_item_id: 1 }]', 'Required parameter "quantity" for "cart_items" is missing.' diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddSimpleProductToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddSimpleProductToCartTest.php index 59f11be6d5b45..01ae565f00bf6 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddSimpleProductToCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddSimpleProductToCartTest.php @@ -79,31 +79,6 @@ public function testAddSimpleProductToCart() self::assertEquals('USD', $rowTotalIncludingTax['currency']); } - /** - * @expectedException Exception - * @expectedExceptionMessage Field AddSimpleProductsToCartInput.cart_id of required type String! was not provided. - */ - public function testAddSimpleProductToCartIfCartIdIsMissed() - { - $query = <<graphQlMutation($query); - } - /** * @expectedException Exception * @expectedExceptionMessage Required parameter "cart_id" is missing @@ -130,32 +105,6 @@ public function testAddSimpleProductToCartIfCartIdIsEmpty() $this->graphQlMutation($query); } - public function testAddSimpleProductToCartIfCartItemsAreMissed() - { - $query = <<expectException(\Exception::class); - $this->expectExceptionMessage( - 'Field AddSimpleProductsToCartInput.cart_items of required type [SimpleProductCartItemInput]!' - . ' was not provided.' - ); - - $this->graphQlMutation($query); - } - /** * @expectedException Exception * @expectedExceptionMessage Required parameter "cart_items" is missing diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddVirtualProductToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddVirtualProductToCartTest.php index c5723d137d070..3811a60ffc522 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddVirtualProductToCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddVirtualProductToCartTest.php @@ -51,31 +51,6 @@ public function testAddVirtualProductToCart() self::assertEquals($sku, $response['addVirtualProductsToCart']['cart']['items'][0]['product']['sku']); } - /** - * @expectedException Exception - * @expectedExceptionMessage Field AddSimpleProductsToCartInput.cart_id of required type String! was not provided. - */ - public function testAddVirtualProductToCartIfCartIdIsMissed() - { - $query = <<graphQlMutation($query); - } - /** * @expectedException Exception * @expectedExceptionMessage Required parameter "cart_id" is missing @@ -102,33 +77,6 @@ public function testAddVirtualProductToCartIfCartIdIsEmpty() $this->graphQlMutation($query); } - public function testAddVirtualProductToCartIfCartItemsAreMissed() - { - $query = <<expectException(\Exception::class); - $this->expectExceptionMessage( - 'Field AddSimpleProductsToCartInput.cart_items of required type [SimpleProductCartItemInput]!' - . ' was not provided.' - ); - - $this->graphQlMutation($query); - } - /** * @expectedException Exception * @expectedExceptionMessage Required parameter "cart_items" is missing diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/ApplyCouponToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/ApplyCouponToCartTest.php index 865837e6bd629..454f01b5cde19 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/ApplyCouponToCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/ApplyCouponToCartTest.php @@ -150,49 +150,6 @@ public function testApplyCouponWhichIsNotApplicable() $this->graphQlMutation($query); } - /** - * @param string $input - * @param string $message - * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php - * @dataProvider dataProviderUpdateWithMissedRequiredParameters - * @expectedException \Exception - */ - public function testApplyCouponWithMissedRequiredParameters(string $input, string $message) - { - $query = <<expectExceptionMessage($message); - $this->graphQlMutation($query); - } - - /** - * @return array - */ - public function dataProviderUpdateWithMissedRequiredParameters(): array - { - return [ - 'missed_cart_id' => [ - 'coupon_code: "test"', - 'Field ApplyCouponToCartInput.cart_id of required type String! was not provided.' - ], - 'missed_coupon_code' => [ - 'cart_id: "test_quote"', - 'Field ApplyCouponToCartInput.coupon_code of required type String! was not provided.' - ], - ]; - } - /** * @param string $maskedQuoteId * @param string $couponCode diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/ApplyCouponsToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/ApplyCouponsToCartTest.php index 7d5e21cd25b8a..0344e274d6fbc 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/ApplyCouponsToCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/ApplyCouponsToCartTest.php @@ -127,49 +127,6 @@ public function testApplyCouponsWhichIsNotApplicable() $this->graphQlMutation($query); } - /** - * @param string $input - * @param string $message - * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php - * @dataProvider dataProviderUpdateWithMissedRequiredParameters - * @expectedException \Exception - */ - public function testApplyCouponsWithMissedRequiredParameters(string $input, string $message) - { - $query = <<expectExceptionMessage($message); - $this->graphQlMutation($query); - } - - /** - * @return array - */ - public function dataProviderUpdateWithMissedRequiredParameters(): array - { - return [ - 'missed_cart_id' => [ - 'coupon_code: "test"', - 'Field ApplyCouponToCartInput.cart_id of required type String! was not provided.' - ], - 'missed_coupon_code' => [ - 'cart_id: "test_quote"', - 'Field ApplyCouponToCartInput.coupon_code of required type String! was not provided.' - ], - ]; - } - /** * @param string $maskedQuoteId * @param string $couponCode diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/PlaceOrderTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/PlaceOrderTest.php index c6c1d3be99c59..bf31d3c6fa3f4 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/PlaceOrderTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/PlaceOrderTest.php @@ -95,25 +95,6 @@ public function testPlaceOrderIfCartIdIsEmpty() $this->graphQlMutation($query); } - /** - * @expectedException Exception - * @expectedExceptionMessage Field PlaceOrderInput.cart_id of required type String! was not provided. - */ - public function testPlaceOrderIfCartIdIsMissed() - { - $query = <<graphQlMutation($query); - } - /** * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php * @magentoConfigFixture default_store carriers/flatrate/active 1 diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/RemoveCouponFromCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/RemoveCouponFromCartTest.php index 12c3918fcd0ac..e94a70cbd929f 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/RemoveCouponFromCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/RemoveCouponFromCartTest.php @@ -61,28 +61,6 @@ public function testRemoveCouponFromCartIfCartIdIsEmpty() $this->graphQlMutation($query); } - /** - * @expectedException Exception - * @expectedExceptionMessage Field RemoveCouponFromCartInput.cart_id of required type String! was not provided. - */ - public function testRemoveCouponFromCartIfCartIdIsMissed() - { - $query = <<graphQlMutation($query); - } - /** * @expectedException Exception * @expectedExceptionMessage Could not find a cart with ID "non_existent_masked_id" diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/RemoveItemFromCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/RemoveItemFromCartTest.php index c3a66291251c7..6f105259bf65c 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/RemoveItemFromCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/RemoveItemFromCartTest.php @@ -80,49 +80,6 @@ public function testRemoveNonExistentItem() $this->graphQlMutation($query); } - /** - * @param string $input - * @param string $message - * @dataProvider dataProviderUpdateWithMissedRequiredParameters - */ - public function testUpdateWithMissedItemRequiredParameters(string $input, string $message) - { - $query = <<expectExceptionMessage($message); - $this->graphQlMutation($query); - } - - /** - * @return array - */ - public function dataProviderUpdateWithMissedRequiredParameters(): array - { - return [ - 'missed_cart_id' => [ - 'cart_item_id: 1', - 'Field RemoveItemFromCartInput.cart_id of required type String! was not provided.' - ], - 'missed_cart_item_id' => [ - 'cart_id: "test_quote"', - 'Field RemoveItemFromCartInput.cart_item_id of required type Int! was not provided.' - ], - ]; - } - /** * _security * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php index 87335bd5c96dd..ea77ad35d2693 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php @@ -296,58 +296,6 @@ public function testSetBillingAddressOnNonExistentCart() $this->graphQlMutation($query); } - /** - * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php - * - * @dataProvider dataProviderSetWithoutRequiredParameters - * @param string $input - * @param string $message - * @throws \Exception - */ - public function testSetBillingAddressWithoutRequiredParameters(string $input, string $message) - { - $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); - $input = str_replace('cart_id_value', $maskedQuoteId, $input); - - $query = <<expectExceptionMessage($message); - $this->graphQlMutation($query); - } - - /** - * @return array - */ - public function dataProviderSetWithoutRequiredParameters(): array - { - return [ - 'missed_billing_address' => [ - 'cart_id: "cart_id_value"', - 'Field SetBillingAddressOnCartInput.billing_address of required type BillingAddressInput!' - . ' was not provided.', - ], - 'missed_cart_id' => [ - 'billing_address: {}', - 'Field SetBillingAddressOnCartInput.cart_id of required type String! was not provided.' - ] - ]; - } - /** * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetPaymentMethodOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetPaymentMethodOnCartTest.php index 24ba3e78f9b4e..c3e35f0bf80e8 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetPaymentMethodOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetPaymentMethodOnCartTest.php @@ -183,14 +183,6 @@ public function testSetPaymentMethodWithoutRequiredParameters(string $input, str public function dataProviderSetPaymentMethodWithoutRequiredParameters(): array { return [ - 'missed_cart_id' => [ - 'payment_method: {code: "' . Checkmo::PAYMENT_METHOD_CHECKMO_CODE . '"}', - 'Field SetPaymentMethodOnCartInput.cart_id of required type String! was not provided.' - ], - 'missed_payment_method' => [ - 'cart_id: "cart_id_value"', - 'Field SetPaymentMethodOnCartInput.payment_method of required type PaymentMethodInput! was not provided' - ], 'missed_payment_method_code' => [ 'cart_id: "cart_id_value", payment_method: {code: ""}', 'Required parameter "code" for "payment_method" is missing.' diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingAddressOnCartTest.php index b142de71e89a3..53a20b775530b 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingAddressOnCartTest.php @@ -208,40 +208,6 @@ public function testSetShippingAddressToCustomerCart() $this->graphQlMutation($query); } - /** - * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php - * - * @dataProvider dataProviderUpdateWithMissedRequiredParameters - * @param string $input - * @param string $message - * @throws \Exception - */ - public function testSetNewShippingAddressWithMissedRequiredParameters(string $input, string $message) - { - $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); - $input = str_replace('cart_id_value', $maskedQuoteId, $input); - - $query = <<expectExceptionMessage($message); - $this->graphQlMutation($query); - } - /** * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php @@ -285,28 +251,6 @@ public function testSetNewShippingAddressOnCartWithRedundantStreetLine() $this->graphQlMutation($query); } - /** - * @return array - */ - public function dataProviderUpdateWithMissedRequiredParameters(): array - { - return [ - 'missed_shipping_addresses' => [ - 'cart_id: "cart_id_value"', - 'Field SetShippingAddressesOnCartInput.shipping_addresses of required type [ShippingAddressInput]! ' . - 'was not provided.', - ], - 'missed_city' => [ - 'shipping_addresses: [ { address: { save_in_address_book: false } } ]', - 'Field CartAddressInput.city of required type String! was not provided' - ], - 'missed_cart_id' => [ - 'shipping_addresses: {}', - 'Field SetShippingAddressesOnCartInput.cart_id of required type String! was not provided.' - ] - ]; - } - /** * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingMethodsOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingMethodsOnCartTest.php index 007ada1ce57cf..0a49136421e9a 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingMethodsOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingMethodsOnCartTest.php @@ -186,28 +186,10 @@ public function testSetShippingMethodWithWrongParameters(string $input, string $ public function dataProviderSetShippingMethodWithWrongParameters(): array { return [ - 'missed_cart_id' => [ - 'shipping_methods: [{ - carrier_code: "flatrate" - method_code: "flatrate" - }]', - 'Field SetShippingMethodsOnCartInput.cart_id of required type String! was not provided.' - ], - 'missed_shipping_methods' => [ - 'cart_id: "cart_id_value"', - 'Field SetShippingMethodsOnCartInput.shipping_methods of required type [ShippingMethodInput]!' - . ' was not provided.' - ], 'shipping_methods_are_empty' => [ 'cart_id: "cart_id_value" shipping_methods: []', 'Required parameter "shipping_methods" is missing' ], - 'missed_carrier_code' => [ - 'cart_id: "cart_id_value", shipping_methods: [{ - method_code: "flatrate" - }]', - 'Field ShippingMethodInput.carrier_code of required type String! was not provided.' - ], 'empty_carrier_code' => [ 'cart_id: "cart_id_value", shipping_methods: [{ carrier_code: "" @@ -222,12 +204,6 @@ public function dataProviderSetShippingMethodWithWrongParameters(): array }]', 'Carrier with such method not found: wrong-carrier-code, flatrate' ], - 'missed_method_code' => [ - 'cart_id: "cart_id_value", shipping_methods: [{ - carrier_code: "flatrate" - }]', - 'Field ShippingMethodInput.method_code of required type String! was not provided.' - ], 'empty_method_code' => [ 'cart_id: "cart_id_value", shipping_methods: [{ carrier_code: "flatrate" diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/UpdateCartItemsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/UpdateCartItemsTest.php index 48d58a0dd8f17..761993d983db8 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/UpdateCartItemsTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/UpdateCartItemsTest.php @@ -181,34 +181,6 @@ public function testUpdateItemFromCustomerCart() $this->graphQlMutation($query); } - /** - * @expectedException \Exception - * @expectedExceptionMessage Field UpdateCartItemsInput.cart_id of required type String! was not provided. - */ - public function testUpdateWithMissedCartItemId() - { - $query = <<graphQlMutation($query); - } - /** * @param string $input * @param string $message @@ -246,14 +218,6 @@ public function testUpdateWithMissedItemRequiredParameters(string $input, string public function dataProviderUpdateWithMissedRequiredParameters(): array { return [ - 'missed_cart_items' => [ - '', - 'Field UpdateCartItemsInput.cart_items of required type [CartItemUpdateInput]! was not provided.' - ], - 'missed_cart_item_id' => [ - 'cart_items: [{ quantity: 2 }]', - 'Field CartItemUpdateInput.cart_item_id of required type Int! was not provided.' - ], 'missed_cart_item_qty' => [ 'cart_items: [{ cart_item_id: 1 }]', 'Required parameter "quantity" for "cart_items" is missing.' From 8fd5c7868a41ae660626cfe077388f02fa0b6a7b Mon Sep 17 00:00:00 2001 From: Vaha Date: Wed, 27 Nov 2019 16:15:01 +0200 Subject: [PATCH 21/39] magento/graphql-ce#808: [Test coverage] Add disabled variation of Configurable Product to cart --- .../AddConfigurableProductToCartTest.php | 60 ++++++++++++++++++- ...oduct_configurable_disable_first_child.php | 37 ++++++++++++ ...duct_configurable_zero_qty_first_child.php | 28 +++++++++ 3 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_disable_first_child.php create mode 100644 dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child.php diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php index b1858e843bf0f..f8eab768ca74d 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php @@ -199,7 +199,7 @@ public function testAddVariationFromAnotherConfigurableProductWithDifferentSuper /** * @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable_sku.php * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php - * @expectedException \Exception + * @expectedException Exception * @expectedExceptionMessage The requested qty is not available */ public function testAddProductIfQuantityIsNotAvailable() @@ -224,7 +224,7 @@ public function testAddProductIfQuantityIsNotAvailable() /** * @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable_sku.php * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php - * @expectedException \Exception + * @expectedException Exception * @expectedExceptionMessage Could not find a product with SKU "configurable_no_exist" */ public function testAddNonExistentConfigurableProductParentToCart() @@ -263,7 +263,7 @@ public function testAddNonExistentConfigurableProductVariationToCart() 2000 ); - $this->expectException(\Exception::class); + $this->expectException(Exception::class); $this->expectExceptionMessage( 'Could not add the product with SKU configurable to the shopping cart: The product that was requested ' . 'doesn\'t exist. Verify the product and try again.' @@ -272,6 +272,60 @@ public function testAddNonExistentConfigurableProductVariationToCart() $this->graphQlMutation($query); } + /** + * @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable_sku.php + * @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable_disable_first_child.php + * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php + */ + public function testAddDisabledVariationToCart() + { + $searchResponse = $this->graphQlQuery($this->getFetchProductQuery('configurable')); + $product = current($searchResponse['products']['items']); + $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_order_1'); + $parentSku = $product['sku']; + $sku = 'simple_10'; + $query = $this->getQuery( + $maskedQuoteId, + $parentSku, + $sku, + 1 + ); + + $this->expectException(Exception::class); + $this->expectExceptionMessage( + 'Could not add the product with SKU configurable to the shopping cart: This product is out of stock.' + ); + + $this->graphQlMutation($query); + } + + /** + * @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable_sku.php + * @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child.php + * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php + */ + public function testOutOfStockVariationToCart() + { + $searchResponse = $this->graphQlQuery($this->getFetchProductQuery('configurable')); + $product = current($searchResponse['products']['items']); + $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_order_1'); + $parentSku = $product['sku']; + $sku = 'simple_10'; + $query = $this->getQuery( + $maskedQuoteId, + $parentSku, + $sku, + 1 + ); + + $this->expectException(Exception::class); + $this->expectExceptionMessage( + 'Could not add the product with SKU configurable to the shopping cart: This product is out of stock.' + ); + + $this->graphQlMutation($query); + } + /** * @param string $maskedQuoteId * @param string $parentSku diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_disable_first_child.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_disable_first_child.php new file mode 100644 index 0000000000000..257db999417d1 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_disable_first_child.php @@ -0,0 +1,37 @@ +get(ProductRepositoryInterface::class); + +try { + /** @var Product $configurableProduct */ + $configurableProduct = $productRepository->get('configurable'); + /** @var Configurable $productTypeInstance */ + $productTypeInstance = $configurableProduct->getTypeInstance(); + /** @var Product $child */ + foreach ($productTypeInstance->getUsedProducts($configurableProduct) as $child) { + + $productAction = Bootstrap::getObjectManager()->get(Action::class); + $productAction->updateAttributes( + [$child->getId()], + [ProductAttributeInterface::CODE_STATUS => Status::STATUS_DISABLED], + $child->getStoreId() + ); + break; + } +} catch (Exception $e) { + // Nothing to remove +} diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child.php new file mode 100644 index 0000000000000..77d90e91726a4 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child.php @@ -0,0 +1,28 @@ +get(ProductRepositoryInterface::class); + +try { + $configurableProduct = $productRepository->get('configurable'); + $productTypeInstance = $configurableProduct->getTypeInstance(); + + /** @var ProductModel $child */ + foreach ($productTypeInstance->getUsedProducts($configurableProduct) as $child) { + $childProduct = $productRepository->getById($child->getId()); + $childProduct->setStockData(['use_config_manage_stock' => 1, 'qty' => 0, 'is_qty_decimal' => 0, 'is_in_stock' => 0]); + $productRepository->save($childProduct); + break; + } +} catch (Exception $e) { + // Nothing to remove +} From 201f9be15d8bbb9e944b4587aff1c9025fabcea1 Mon Sep 17 00:00:00 2001 From: Vaha Date: Thu, 28 Nov 2019 18:34:21 +0200 Subject: [PATCH 22/39] magento/graphql-ce#808: [Test coverage] Add disabled variation of Configurable Product to cart, improved fixtures --- .../AddConfigurableProductToCartTest.php | 2 -- ...oduct_configurable_disable_first_child.php | 31 ++++++------------- ...figurable_disable_first_child_roolback.php | 8 +++++ ...duct_configurable_zero_qty_first_child.php | 21 +++---------- ...igurable_zero_qty_first_child_roolback.php | 8 +++++ 5 files changed, 31 insertions(+), 39 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_disable_first_child_roolback.php create mode 100644 dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child_roolback.php diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php index f8eab768ca74d..dac59d1e34077 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php @@ -273,7 +273,6 @@ public function testAddNonExistentConfigurableProductVariationToCart() } /** - * @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable_sku.php * @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable_disable_first_child.php * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php */ @@ -300,7 +299,6 @@ public function testAddDisabledVariationToCart() } /** - * @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable_sku.php * @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child.php * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php */ diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_disable_first_child.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_disable_first_child.php index 257db999417d1..e7b644b318fd2 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_disable_first_child.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_disable_first_child.php @@ -5,33 +5,22 @@ */ declare(strict_types=1); +require __DIR__ . '/product_configurable_sku.php'; + use Magento\Catalog\Api\Data\ProductAttributeInterface; -use Magento\Catalog\Api\ProductRepositoryInterface; -use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\Action; use Magento\Catalog\Model\Product\Attribute\Source\Status; -use Magento\ConfigurableProduct\Model\Product\Type\Configurable; use Magento\TestFramework\Helper\Bootstrap; -/** @var ProductRepositoryInterface $productRepository */ -$productRepository = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class); - +$childSku = 'simple_10'; try { - /** @var Product $configurableProduct */ - $configurableProduct = $productRepository->get('configurable'); - /** @var Configurable $productTypeInstance */ - $productTypeInstance = $configurableProduct->getTypeInstance(); - /** @var Product $child */ - foreach ($productTypeInstance->getUsedProducts($configurableProduct) as $child) { - - $productAction = Bootstrap::getObjectManager()->get(Action::class); - $productAction->updateAttributes( - [$child->getId()], - [ProductAttributeInterface::CODE_STATUS => Status::STATUS_DISABLED], - $child->getStoreId() - ); - break; - } + $childProduct = $productRepository->get($childSku); + $productAction = Bootstrap::getObjectManager()->get(Action::class); + $productAction->updateAttributes( + [$childProduct->getEntityId()], + [ProductAttributeInterface::CODE_STATUS => Status::STATUS_DISABLED], + $childProduct->getStoreId() + ); } catch (Exception $e) { // Nothing to remove } diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_disable_first_child_roolback.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_disable_first_child_roolback.php new file mode 100644 index 0000000000000..7c73fa65cfcd1 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_disable_first_child_roolback.php @@ -0,0 +1,8 @@ +get(ProductRepositoryInterface::class); +require __DIR__ . '/product_configurable_sku.php'; +$childSku = 'simple_10'; try { - $configurableProduct = $productRepository->get('configurable'); - $productTypeInstance = $configurableProduct->getTypeInstance(); - - /** @var ProductModel $child */ - foreach ($productTypeInstance->getUsedProducts($configurableProduct) as $child) { - $childProduct = $productRepository->getById($child->getId()); - $childProduct->setStockData(['use_config_manage_stock' => 1, 'qty' => 0, 'is_qty_decimal' => 0, 'is_in_stock' => 0]); - $productRepository->save($childProduct); - break; - } + $childProduct = $productRepository->get($childSku); + $childProduct->setStockData(['use_config_manage_stock' => 1, 'qty' => 0, 'is_qty_decimal' => 0, 'is_in_stock' => 0]); + $productRepository->save($childProduct); } catch (Exception $e) { // Nothing to remove } diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child_roolback.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child_roolback.php new file mode 100644 index 0000000000000..7c73fa65cfcd1 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child_roolback.php @@ -0,0 +1,8 @@ + Date: Thu, 28 Nov 2019 22:41:57 +0200 Subject: [PATCH 23/39] magento/graphql-ce#808: [Test coverage] Add disabled variation of Configurable Product to cart, improved fixtures (line limit) --- .../_files/product_configurable_zero_qty_first_child.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child.php index f813beab19610..f8cce222f6605 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child.php @@ -10,7 +10,12 @@ $childSku = 'simple_10'; try { $childProduct = $productRepository->get($childSku); - $childProduct->setStockData(['use_config_manage_stock' => 1, 'qty' => 0, 'is_qty_decimal' => 0, 'is_in_stock' => 0]); + $childProduct->setStockData([ + 'use_config_manage_stock' => 1, + 'qty' => 0, + 'is_qty_decimal' => 0, + 'is_in_stock' => 0 + ]); $productRepository->save($childProduct); } catch (Exception $e) { // Nothing to remove From 5eae8f1b28a50b6f4ff4019e590df1205a04b1e4 Mon Sep 17 00:00:00 2001 From: Lena Orobei Date: Fri, 6 Dec 2019 13:04:23 -0600 Subject: [PATCH 24/39] magento/graphql-ce#808: [Test coverage] Add disabled variation of Configurable Product to cart - code style fixes --- .../product_configurable_zero_qty_first_child.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child.php index f8cce222f6605..5dcc461d83759 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child.php @@ -10,12 +10,14 @@ $childSku = 'simple_10'; try { $childProduct = $productRepository->get($childSku); - $childProduct->setStockData([ - 'use_config_manage_stock' => 1, - 'qty' => 0, - 'is_qty_decimal' => 0, - 'is_in_stock' => 0 - ]); + $childProduct->setStockData( + [ + 'use_config_manage_stock' => 1, + 'qty' => 0, + 'is_qty_decimal' => 0, + 'is_in_stock' => 0 + ] + ); $productRepository->save($childProduct); } catch (Exception $e) { // Nothing to remove From 2d76c5addb9d7b8c772ebc11eaa61e254771d325 Mon Sep 17 00:00:00 2001 From: Lena Orobei Date: Fri, 6 Dec 2019 13:21:04 -0600 Subject: [PATCH 25/39] magento/graphql-ce#1061: Remove redundant logic from resolvers --- .../Model/AuthorizenetDataProvider.php | 15 ----------- .../Model/BraintreeDataProvider.php | 13 --------- .../Customer/SetPaymentMethodTest.php | 27 ------------------- .../Braintree/Guest/SetPaymentMethodTest.php | 25 ----------------- 4 files changed, 80 deletions(-) diff --git a/app/code/Magento/AuthorizenetGraphQl/Model/AuthorizenetDataProvider.php b/app/code/Magento/AuthorizenetGraphQl/Model/AuthorizenetDataProvider.php index ffbacbf6ac88c..27d0693884121 100644 --- a/app/code/Magento/AuthorizenetGraphQl/Model/AuthorizenetDataProvider.php +++ b/app/code/Magento/AuthorizenetGraphQl/Model/AuthorizenetDataProvider.php @@ -49,21 +49,6 @@ public function getData(array $data): array __('Required parameter "authorizenet_acceptjs" for "payment_method" is missing.') ); } - if (!isset($data[self::PATH_ADDITIONAL_DATA]['opaque_data_descriptor'])) { - throw new GraphQlInputException( - __('Required parameter "opaque_data_descriptor" for "authorizenet_acceptjs" is missing.') - ); - } - if (!isset($data[self::PATH_ADDITIONAL_DATA]['opaque_data_value'])) { - throw new GraphQlInputException( - __('Required parameter "opaque_data_value" for "authorizenet_acceptjs" is missing.') - ); - } - if (!isset($data[self::PATH_ADDITIONAL_DATA]['cc_last_4'])) { - throw new GraphQlInputException( - __('Required parameter "cc_last_4" for "authorizenet_acceptjs" is missing.') - ); - } $additionalData = $this->arrayManager->get(static::PATH_ADDITIONAL_DATA, $data); foreach ($additionalData as $key => $value) { diff --git a/app/code/Magento/BraintreeGraphQl/Model/BraintreeDataProvider.php b/app/code/Magento/BraintreeGraphQl/Model/BraintreeDataProvider.php index 23ca1d88e3625..cb5c4a31837b4 100644 --- a/app/code/Magento/BraintreeGraphQl/Model/BraintreeDataProvider.php +++ b/app/code/Magento/BraintreeGraphQl/Model/BraintreeDataProvider.php @@ -31,19 +31,6 @@ public function getData(array $args): array __('Required parameter "braintree" for "payment_method" is missing.') ); } - - if (!isset($args[self::PATH_ADDITIONAL_DATA]['payment_method_nonce'])) { - throw new GraphQlInputException( - __('Required parameter "payment_method_nonce" for "braintree" is missing.') - ); - } - - if (!isset($args[self::PATH_ADDITIONAL_DATA]['is_active_payment_token_enabler'])) { - throw new GraphQlInputException( - __('Required parameter "is_active_payment_token_enabler" for "braintree" is missing.') - ); - } - return $args[self::PATH_ADDITIONAL_DATA]; } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/Customer/SetPaymentMethodTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/Customer/SetPaymentMethodTest.php index fbaa3a98613cf..a36a4f5d38223 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/Customer/SetPaymentMethodTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/Customer/SetPaymentMethodTest.php @@ -380,33 +380,6 @@ private function getSetPaymentBraintreeQueryInvalidInput(string $maskedQuoteId, QUERY; } - /** - * @param string $maskedQuoteId - * @return string - */ - private function getSetPaymentBraintreeQueryInvalidPaymentMethodInput(string $maskedQuoteId): string - { - return << Date: Fri, 6 Dec 2019 14:45:30 -0600 Subject: [PATCH 26/39] magento/graphql-ce#808: [Test coverage] Add disabled variation of Configurable Product to cart --- ...oduct_configurable_disable_first_child.php | 19 ++++++-------- ...igurable_disable_first_child_rollback.php} | 0 ...duct_configurable_zero_qty_first_child.php | 25 ++++++++----------- ...gurable_zero_qty_first_child_rollback.php} | 0 4 files changed, 19 insertions(+), 25 deletions(-) rename dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/{product_configurable_disable_first_child_roolback.php => product_configurable_disable_first_child_rollback.php} (100%) rename dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/{product_configurable_zero_qty_first_child_roolback.php => product_configurable_zero_qty_first_child_rollback.php} (100%) diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_disable_first_child.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_disable_first_child.php index e7b644b318fd2..51d192f76c807 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_disable_first_child.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_disable_first_child.php @@ -13,14 +13,11 @@ use Magento\TestFramework\Helper\Bootstrap; $childSku = 'simple_10'; -try { - $childProduct = $productRepository->get($childSku); - $productAction = Bootstrap::getObjectManager()->get(Action::class); - $productAction->updateAttributes( - [$childProduct->getEntityId()], - [ProductAttributeInterface::CODE_STATUS => Status::STATUS_DISABLED], - $childProduct->getStoreId() - ); -} catch (Exception $e) { - // Nothing to remove -} + +$childProduct = $productRepository->get($childSku); +$productAction = Bootstrap::getObjectManager()->get(Action::class); +$productAction->updateAttributes( + [$childProduct->getEntityId()], + [ProductAttributeInterface::CODE_STATUS => Status::STATUS_DISABLED], + $childProduct->getStoreId() +); diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_disable_first_child_roolback.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_disable_first_child_rollback.php similarity index 100% rename from dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_disable_first_child_roolback.php rename to dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_disable_first_child_rollback.php diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child.php index 5dcc461d83759..b923ae6399cc3 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child.php @@ -8,17 +8,14 @@ require __DIR__ . '/product_configurable_sku.php'; $childSku = 'simple_10'; -try { - $childProduct = $productRepository->get($childSku); - $childProduct->setStockData( - [ - 'use_config_manage_stock' => 1, - 'qty' => 0, - 'is_qty_decimal' => 0, - 'is_in_stock' => 0 - ] - ); - $productRepository->save($childProduct); -} catch (Exception $e) { - // Nothing to remove -} + +$childProduct = $productRepository->get($childSku); +$childProduct->setStockData( + [ + 'use_config_manage_stock' => 1, + 'qty' => 0, + 'is_qty_decimal' => 0, + 'is_in_stock' => 0 + ] +); +$productRepository->save($childProduct); diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child_roolback.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child_rollback.php similarity index 100% rename from dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child_roolback.php rename to dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_zero_qty_first_child_rollback.php From ee228afd4c469d590332dc6f79130fab88ab6857 Mon Sep 17 00:00:00 2001 From: Lena Orobei Date: Mon, 9 Dec 2019 13:17:12 -0600 Subject: [PATCH 27/39] magento/graphql-ce#808: [Test coverage] Add disabled variation of Configurable Product to cart --- .../ConfigurableProduct/AddConfigurableProductToCartTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php index dac59d1e34077..8e6400a9a3b93 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php @@ -292,7 +292,7 @@ public function testAddDisabledVariationToCart() $this->expectException(Exception::class); $this->expectExceptionMessage( - 'Could not add the product with SKU configurable to the shopping cart: This product is out of stock.' + 'Could not add the product with SKU configurable to the shopping cart' ); $this->graphQlMutation($query); @@ -318,7 +318,7 @@ public function testOutOfStockVariationToCart() $this->expectException(Exception::class); $this->expectExceptionMessage( - 'Could not add the product with SKU configurable to the shopping cart: This product is out of stock.' + 'Could not add the product with SKU configurable to the shopping cart' ); $this->graphQlMutation($query); From 8251bc91a45ffb61cdfb0015ccf570f63f23484b Mon Sep 17 00:00:00 2001 From: divyajyothi5321 <54176640+divyajyothi5321@users.noreply.github.com> Date: Fri, 20 Dec 2019 17:07:29 +0530 Subject: [PATCH 28/39] Update Send.php --- app/code/Magento/Wishlist/Controller/Index/Send.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Wishlist/Controller/Index/Send.php b/app/code/Magento/Wishlist/Controller/Index/Send.php index b7c93473cde94..2f1813cf886ed 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Send.php +++ b/app/code/Magento/Wishlist/Controller/Index/Send.php @@ -318,7 +318,6 @@ protected function addLayoutHandles(ResultLayout $resultLayout) * * @param int $wishlistId * @param \Magento\Framework\View\Result\Layout $resultLayout - * @return mixed */ protected function getRssLink($wishlistId, ResultLayout $resultLayout) { From 0802b480a0f29e3d9e609d33915abf8e4dbf2e10 Mon Sep 17 00:00:00 2001 From: divyajyothi5321 <54176640+divyajyothi5321@users.noreply.github.com> Date: Mon, 23 Dec 2019 14:09:27 +0530 Subject: [PATCH 29/39] added requested changes --- app/code/Magento/Wishlist/Controller/Index/Send.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Wishlist/Controller/Index/Send.php b/app/code/Magento/Wishlist/Controller/Index/Send.php index 2f1813cf886ed..283400a6f94ea 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Send.php +++ b/app/code/Magento/Wishlist/Controller/Index/Send.php @@ -203,7 +203,7 @@ public function execute() $error = __('Please enter an email address.'); } else { if (count($emails) > $emailsLeft) { - $error = __('Maximum of %1 Emails can be Sent.', $emailsLeft); + $error = __('Maximum of %1 emails can be sent.', $emailsLeft); } else { foreach ($emails as $index => $email) { $email = trim($email); From 63ec3e575ca3f9621867e891c102a4bd0f55ed5d Mon Sep 17 00:00:00 2001 From: divyajyothi5321 <54176640+divyajyothi5321@users.noreply.github.com> Date: Thu, 26 Dec 2019 14:44:55 +0530 Subject: [PATCH 30/39] Added fix for - 26176 --- .../luma/Magento_Newsletter/web/css/source/_module.less | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/design/frontend/Magento/luma/Magento_Newsletter/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Newsletter/web/css/source/_module.less index 5d44a32b9391b..cebde47e35191 100644 --- a/app/design/frontend/Magento/luma/Magento_Newsletter/web/css/source/_module.less +++ b/app/design/frontend/Magento/luma/Magento_Newsletter/web/css/source/_module.less @@ -81,6 +81,13 @@ .block.newsletter { max-width: 44%; width: max-content; + + .form.subscribe { + > .field, + > .actions { + float: left; + } + } } } From adc7908db1db52171e4ec60ffe0eaad152535230 Mon Sep 17 00:00:00 2001 From: divyajyothi5321 <54176640+divyajyothi5321@users.noreply.github.com> Date: Thu, 26 Dec 2019 15:33:51 +0530 Subject: [PATCH 31/39] Added necessary indentations --- .../luma/Magento_Newsletter/web/css/source/_module.less | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/design/frontend/Magento/luma/Magento_Newsletter/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Newsletter/web/css/source/_module.less index cebde47e35191..a72f31d72ce48 100644 --- a/app/design/frontend/Magento/luma/Magento_Newsletter/web/css/source/_module.less +++ b/app/design/frontend/Magento/luma/Magento_Newsletter/web/css/source/_module.less @@ -84,9 +84,9 @@ .form.subscribe { > .field, - > .actions { - float: left; - } + > .actions { + float: left; + } } } } From ad1059fb9a0abb316a6cb92b62ef9fee546f1f77 Mon Sep 17 00:00:00 2001 From: Marco Oliveira Date: Fri, 27 Dec 2019 15:40:25 -0300 Subject: [PATCH 32/39] Adding coverage test cases, fixing Order/Payment/Info that had the same problem. --- .../Sales/Model/Order/Payment/Info.php | 1 + .../Magento/Payment/Model/PaymentInfoTest.php | 64 ++++++++++++++ .../Magento/Payment/_files/payment_info.php | 83 +++++++++++++++++++ 3 files changed, 148 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Payment/Model/PaymentInfoTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Payment/_files/payment_info.php diff --git a/app/code/Magento/Sales/Model/Order/Payment/Info.php b/app/code/Magento/Sales/Model/Order/Payment/Info.php index fee846fe6a62c..479d96b5842d9 100644 --- a/app/code/Magento/Sales/Model/Order/Payment/Info.php +++ b/app/code/Magento/Sales/Model/Order/Payment/Info.php @@ -192,6 +192,7 @@ public function getAdditionalInformation($key = null) */ public function unsAdditionalInformation($key = null) { + $this->initAdditionalInformation(); if ($key && isset($this->additionalInformation[$key])) { unset($this->additionalInformation[$key]); return $this->setData('additional_information', $this->additionalInformation); diff --git a/dev/tests/integration/testsuite/Magento/Payment/Model/PaymentInfoTest.php b/dev/tests/integration/testsuite/Magento/Payment/Model/PaymentInfoTest.php new file mode 100644 index 0000000000000..7a4efe4a22ce9 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Payment/Model/PaymentInfoTest.php @@ -0,0 +1,64 @@ +_objectManager = Bootstrap::getObjectManager(); + $this->_order = $this->_objectManager->create( + Order::class + ); + $this->_quote = $this->_objectManager->create( + Quote::class + ); + } + + /** + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoDataFixture Magento/Payment/_files/payment_info.php + */ + public function testUnsetPaymentInformation() + { + $order = $this->_order->loadByIncrementId('100000001'); + /** @var \Magento\Sales\Model\Order\Payment $paymentOrder */ + $paymentOrder = $order->getPayment(); + $paymentOrder->unsAdditionalInformation('testing'); + + $quote = $this->_quote->load('reserved_order_id', 'reserved_order_id'); + /** @var \Magento\Quote\Model\Quote\Payment $paymentQuote */ + $paymentQuote = $quote->getPayment(); + $paymentQuote->unsAdditionalInformation('testing'); + + + $this->assertFalse($paymentOrder->hasAdditionalInformation('testing')); + $this->assertFalse($paymentQuote->hasAdditionalInformation('testing')); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Payment/_files/payment_info.php b/dev/tests/integration/testsuite/Magento/Payment/_files/payment_info.php new file mode 100644 index 0000000000000..bf40cb6b99820 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Payment/_files/payment_info.php @@ -0,0 +1,83 @@ + 'guest', + 'lastname' => 'guest', + 'email' => 'customer@example.com', + 'street' => 'street', + 'city' => 'Los Angeles', + 'region' => 'CA', + 'postcode' => '1', + 'country_id' => 'US', + 'telephone' => '1' +]; +$billingAddress = $objectManager->create( + Address::class, + ['data' => $addressData] +); +$billingAddress->setAddressType('billing'); +$shippingAddress = clone $billingAddress; +$shippingAddress->setId(null)->setAddressType('shipping'); + +/** @var Payment $paymentOrder */ +$paymentOrder = $objectManager->create( + Payment::class +); + +$paymentOrder->setMethod(Config::METHOD_WPP_EXPRESS); +$paymentOrder->setAdditionalInformation('testing', 'testing additional data'); + +$amount = 100; + +/** @var Order $order */ +$order = $objectManager->create(Order::class); +$order->setCustomerEmail('co@co.co') + ->setIncrementId('100000001') + ->setSubtotal($amount) + ->setBaseSubtotal($amount) + ->setBaseGrandTotal($amount) + ->setGrandTotal($amount) + ->setBaseCurrencyCode('USD') + ->setCustomerIsGuest(true) + ->setStoreId(1) + ->setEmailSent(true) + ->setBillingAddress($billingAddress) + ->setShippingAddress($shippingAddress) + ->setPayment($paymentOrder); +$order->save(); + + + +/** @var Quote $quote */ +$quote = $objectManager->create(Quote::class); +$quote->setStoreId(1) + ->setIsActive(true) + ->setIsMultiShipping(false) + ->setReservedOrderId('reserved_order_id'); + +$quote->getPayment() + ->setMethod(Config::METHOD_WPP_EXPRESS) + ->setAdditionalInformation('testing', 'testing additional data'); + +$quote->collectTotals(); + + +/** @var CartRepositoryInterface $repository */ +$repository = $objectManager->get(CartRepositoryInterface::class); +$repository->save($quote); From 408b725157f031a81119cb27816d204d48b45b97 Mon Sep 17 00:00:00 2001 From: Marco Oliveira Date: Fri, 27 Dec 2019 16:04:17 -0300 Subject: [PATCH 33/39] Removing unnecessary line. --- .../testsuite/Magento/Payment/Model/PaymentInfoTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Payment/Model/PaymentInfoTest.php b/dev/tests/integration/testsuite/Magento/Payment/Model/PaymentInfoTest.php index 7a4efe4a22ce9..3d037ceb17044 100644 --- a/dev/tests/integration/testsuite/Magento/Payment/Model/PaymentInfoTest.php +++ b/dev/tests/integration/testsuite/Magento/Payment/Model/PaymentInfoTest.php @@ -56,8 +56,7 @@ public function testUnsetPaymentInformation() /** @var \Magento\Quote\Model\Quote\Payment $paymentQuote */ $paymentQuote = $quote->getPayment(); $paymentQuote->unsAdditionalInformation('testing'); - - + $this->assertFalse($paymentOrder->hasAdditionalInformation('testing')); $this->assertFalse($paymentQuote->hasAdditionalInformation('testing')); } From dbcb81df310cb16d07e9f8b8397fe529239dba9b Mon Sep 17 00:00:00 2001 From: Yogesh Suhagiya Date: Mon, 30 Dec 2019 11:34:12 +0530 Subject: [PATCH 34/39] Fixed transaction issues --- app/code/Magento/CatalogUrlRewrite/etc/adminhtml/system.xml | 6 ++---- app/code/Magento/CatalogUrlRewrite/i18n/en_US.csv | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/CatalogUrlRewrite/etc/adminhtml/system.xml b/app/code/Magento/CatalogUrlRewrite/etc/adminhtml/system.xml index 1e1f4e86fa3dc..ad0ff68192af4 100644 --- a/app/code/Magento/CatalogUrlRewrite/etc/adminhtml/system.xml +++ b/app/code/Magento/CatalogUrlRewrite/etc/adminhtml/system.xml @@ -28,13 +28,11 @@ Magento\Config\Model\Config\Source\Yesno - + Magento\CatalogUrlRewrite\Model\TableCleaner Magento\Config\Model\Config\Source\Yesno - - Warning! Turning this option off will result in permanent removal of category/product URL rewrites without an ability to restore them.]]> - + Warning! Turning this option off will result in permanent removal of category/product URL rewrites without an ability to restore them.]]> generate_category_product_rewrites diff --git a/app/code/Magento/CatalogUrlRewrite/i18n/en_US.csv b/app/code/Magento/CatalogUrlRewrite/i18n/en_US.csv index 0f21e8ddf9fc9..1dddaa458a16c 100644 --- a/app/code/Magento/CatalogUrlRewrite/i18n/en_US.csv +++ b/app/code/Magento/CatalogUrlRewrite/i18n/en_US.csv @@ -5,5 +5,6 @@ "Product URL Suffix","Product URL Suffix" "Use Categories Path for Product URLs","Use Categories Path for Product URLs" "Create Permanent Redirect for URLs if URL Key Changed","Create Permanent Redirect for URLs if URL Key Changed" -"Generate "category/product" URL Rewrites","Generate "category/product" URL Rewrites" +"Generate ""category/product"" URL Rewrites","Generate ""category/product"" URL Rewrites" "URL key ""%1"" matches a reserved endpoint name (%2). Use another URL key.","URL key ""%1"" matches a reserved endpoint name (%2). Use another URL key." +"Warning! Turning this option off will result in permanent removal of category/product URL rewrites without an ability to restore them.","Warning! Turning this option off will result in permanent removal of category/product URL rewrites without an ability to restore them." From d6a73f9f678df05f9731dcb435857c64002e872a Mon Sep 17 00:00:00 2001 From: Volodymyr Zaets Date: Tue, 31 Dec 2019 15:44:48 -0600 Subject: [PATCH 35/39] Fix static --- .../Framework/Setup/Declaration/Schema/Dto/Factories/Json.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Json.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Json.php index ec20e4a9438f3..5c9c88bb4fe26 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Json.php +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Json.php @@ -10,6 +10,8 @@ /** * Class Json + * + * Json Factory */ class Json implements FactoryInterface { From 84b131070043a4ad47f8bfa7a4999c42ed9940ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Bajsarowicz?= Date: Thu, 2 Jan 2020 00:33:45 +0100 Subject: [PATCH 36/39] Set of fixes for Integration and Functional tests failing because of date used --- ...dminCreateDatetimeProductAttributeTest.xml | 2 +- .../Report/Product/Viewed/CollectionTest.php | 52 +++++++++---------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDatetimeProductAttributeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDatetimeProductAttributeTest.xml index 5da824d2ccdb9..981af5b5abb4a 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDatetimeProductAttributeTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDatetimeProductAttributeTest.xml @@ -27,7 +27,7 @@ - + diff --git a/dev/tests/integration/testsuite/Magento/Reports/Model/ResourceModel/Report/Product/Viewed/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Reports/Model/ResourceModel/Report/Product/Viewed/CollectionTest.php index fff057fd05688..18b6aa6405663 100644 --- a/dev/tests/integration/testsuite/Magento/Reports/Model/ResourceModel/Report/Product/Viewed/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/Reports/Model/ResourceModel/Report/Product/Viewed/CollectionTest.php @@ -72,20 +72,20 @@ public function testTableSelection($period, $expectedTable, $dateFrom, $dateTo, $this->assertArrayHasKey('tableName', $from[$dbTableName]); } else { $union = $this->_collection->getSelect()->getPart('union'); + $count = count($union); if ($period !== null && $dateFrom !== null && $dateTo !== null && $period != 'month') { - $count = count($union); if ($period == 'year') { if ($dbTableName == "report_viewed_product_aggregated_daily") { - $this->assertEquals($count, 2); + $this->assertEquals(2, $count); } if ($dbTableName == "report_viewed_product_aggregated_yearly") { - $this->assertEquals($count, 3); + $this->assertEquals(3, $count); } } else { - $this->assertEquals($count, 3); + $this->assertEquals(3, $count); } } else { - $this->assertEquals(count($union), 2); + $this->assertEquals(2, $count); } } } @@ -98,8 +98,8 @@ public function testTableSelection($period, $expectedTable, $dateFrom, $dateTo, */ public function tableForPeriodDataProvider() { - $dateNow = date('Y-m-d', time()); - $dateYearAgo = date('Y-m-d', strtotime($dateNow . ' -1 year')); + $dateFrom = '2019-10-15'; + $dateYearBefore = date('Y-m-d', strtotime($dateFrom . ' -1 year')); return [ [ 'period' => 'year', @@ -111,32 +111,32 @@ public function tableForPeriodDataProvider() [ 'period' => 'year', 'table' => 'report_viewed_product_aggregated_yearly', - 'date_from' => $dateYearAgo, - 'date_to' => $dateNow, + 'date_from' => $dateYearBefore, + 'date_to' => $dateFrom, ], [ 'period' => 'year', 'table' => 'report_viewed_product_aggregated_yearly', - 'date_from' => $dateYearAgo, + 'date_from' => $dateYearBefore, 'date_to' => null, ], [ 'period' => 'month', 'table' => 'report_viewed_product_aggregated_monthly', 'date_from' => null, - 'date_to' => $dateNow, + 'date_to' => $dateFrom, ], [ 'period' => 'year', 'table' => 'report_viewed_product_aggregated_yearly', - 'date_from' => $dateYearAgo, + 'date_from' => $dateYearBefore, 'date_to' => null, ], [ 'period' => 'year', 'table' => 'report_viewed_product_aggregated_yearly', 'date_from' => null, - 'date_to' => $dateNow, + 'date_to' => $dateFrom, ], [ 'period' => 'month', @@ -147,19 +147,19 @@ public function tableForPeriodDataProvider() [ 'period' => 'month', 'table' => 'report_viewed_product_aggregated_monthly', - 'date_from' => $dateYearAgo, - 'date_to' => $dateYearAgo, + 'date_from' => $dateYearBefore, + 'date_to' => $dateYearBefore, ], [ 'period' => 'month', 'table' => 'report_viewed_product_aggregated_monthly', 'date_from' => null, - 'date_to' => $dateYearAgo, + 'date_to' => $dateYearBefore, ], [ 'period' => 'month', 'table' => 'report_viewed_product_aggregated_monthly', - 'date_from' => $dateYearAgo, + 'date_from' => $dateYearBefore, 'date_to' => null, ], [ @@ -177,32 +177,32 @@ public function tableForPeriodDataProvider() [ 'period' => null, 'table' => 'report_viewed_product_aggregated_daily', - 'date_from' => $dateYearAgo, - 'date_to' => $dateNow, + 'date_from' => $dateYearBefore, + 'date_to' => $dateFrom, ], [ 'period' => null, 'table' => 'report_viewed_product_aggregated_daily', - 'date_from' => $dateNow, - 'date_to' => $dateNow, + 'date_from' => $dateFrom, + 'date_to' => $dateFrom, ], [ 'period' => 'day', 'table' => 'report_viewed_product_aggregated_daily', - 'date_from' => $dateYearAgo, - 'date_to' => $dateYearAgo, + 'date_from' => $dateYearBefore, + 'date_to' => $dateYearBefore, ], [ 'period' => 'year', 'table' => 'report_viewed_product_aggregated_daily', - 'date_from' => $dateYearAgo, - 'date_to' => $dateYearAgo, + 'date_from' => $dateYearBefore, + 'date_to' => $dateYearBefore, ], [ 'period' => 'year', 'table' => 'report_viewed_product_aggregated_daily', 'date_from' => null, - 'date_to' => $dateYearAgo, + 'date_to' => $dateYearBefore, ], [ 'period' => null, From add2bbb8f6b82f450dbf7e466f12f93254c0eed0 Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Thu, 2 Jan 2020 11:35:27 +0200 Subject: [PATCH 37/39] cover changes with unit test --- .../Test/Unit/Controller/Index/SendTest.php | 57 ++++++++++++++++--- 1 file changed, 50 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/SendTest.php b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/SendTest.php index 47148f7878134..c70c2a1a6a9b6 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/SendTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/SendTest.php @@ -5,7 +5,10 @@ */ namespace Magento\Wishlist\Test\Unit\Controller\Index; +use Magento\Captcha\Helper\Data as CaptchaHelper; +use Magento\Captcha\Model\DefaultModel as CaptchaModel; use Magento\Customer\Model\Data\Customer as CustomerData; +use Magento\Customer\Model\Session; use Magento\Framework\App\Action\Context as ActionContext; use Magento\Framework\App\RequestInterface; use Magento\Framework\Controller\Result\Redirect as ResultRedirect; @@ -14,15 +17,13 @@ use Magento\Framework\Event\ManagerInterface as EventManagerInterface; use Magento\Framework\Mail\TransportInterface; use Magento\Framework\Message\ManagerInterface; +use Magento\Framework\Phrase; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Framework\UrlInterface; use Magento\Framework\View\Result\Layout as ResultLayout; use Magento\Store\Model\Store; use Magento\Wishlist\Controller\Index\Send; use Magento\Wishlist\Controller\WishlistProviderInterface; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\Captcha\Helper\Data as CaptchaHelper; -use Magento\Captcha\Model\DefaultModel as CaptchaModel; -use Magento\Customer\Model\Session; /** * @SuppressWarnings(PHPMD.TooManyFields) @@ -212,7 +213,12 @@ protected function setUp() ); } - public function testExecuteNoFormKeyValidated() + /** + * Verify execute method without Form Key validated + * + * @return void + */ + public function testExecuteNoFormKeyValidated(): void { $this->formKeyValidator->expects($this->once()) ->method('validate') @@ -228,8 +234,43 @@ public function testExecuteNoFormKeyValidated() } /** - * @expectedException \Magento\Framework\Exception\NotFoundException - * @expectedExceptionMessage Page not found. + * Verify execute with no emails left + * + * @return void + */ + public function testExecuteWithNoEmailLeft(): void + { + $expectedMessage = new Phrase('Maximum of %1 emails can be sent.', [0]); + + $this->formKeyValidator->expects($this->once()) + ->method('validate') + ->with($this->request) + ->willReturn(true); + + $this->request->expects($this->at(0)) + ->method('getPost') + ->with('emails') + ->willReturn('some.Email@gmail.com', 'some.email2@gmail.com'); + $this->request->expects($this->at(1)) + ->method('getPost') + ->with('message'); + $wishlist = $this->createMock(\Magento\Wishlist\Model\Wishlist::class); + $this->wishlistProvider->expects($this->once()) + ->method('getWishlist') + ->willReturn($wishlist); + $this->resultRedirect->expects($this->once()) + ->method('setPath') + ->with('*/*/share') + ->willReturnSelf(); + $this->messageManager->expects($this->once()) + ->method('addErrorMessage') + ->with($expectedMessage); + + $this->assertEquals($this->resultRedirect, $this->model->execute()); + } + + /** + * Execute method with no wishlist available */ public function testExecuteNoWishlistAvailable() { @@ -241,6 +282,8 @@ public function testExecuteNoWishlistAvailable() $this->wishlistProvider->expects($this->once()) ->method('getWishlist') ->willReturn(null); + $this->expectException(\Magento\Framework\Exception\NotFoundException::class); + $this->expectExceptionMessage('Page not found'); $this->model->execute(); } From 3182759c834cdb623a2194b75e5ae6bd4188577d Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Thu, 2 Jan 2020 12:42:49 +0200 Subject: [PATCH 38/39] Cover changes with unit test --- .../Unit/Model/ResourceModel/CustomerRepositoryTest.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/CustomerRepositoryTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/CustomerRepositoryTest.php index 8032399e14881..015213847e7ee 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/CustomerRepositoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/CustomerRepositoryTest.php @@ -211,6 +211,7 @@ public function testSave() 'setFirstFailure', 'setLockExpires', 'save', + 'setGroupId' ] ); @@ -245,9 +246,15 @@ public function testSave() $this->customer->expects($this->atLeastOnce()) ->method('getId') ->willReturn($customerId); - $this->customer->expects($this->atLeastOnce()) + $this->customer->expects($this->at(4)) ->method('__toArray') ->willReturn([]); + $this->customer->expects($this->at(3)) + ->method('__toArray') + ->willReturn(['group_id' => 1]); + $customerModel->expects($this->once()) + ->method('setGroupId') + ->with(1); $this->customerRegistry->expects($this->atLeastOnce()) ->method('retrieve') ->with($customerId) From 3bce77fda3f048829b217b49dc37368fc6bf79e4 Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Thu, 2 Jan 2020 13:12:42 +0200 Subject: [PATCH 39/39] fix phpStan test --- .../Magento/Customer/Model/ResourceModel/CustomerRepository.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php b/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php index 323b6c5d53714..0611a2df641e7 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php +++ b/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php @@ -17,6 +17,7 @@ use Magento\Customer\Model\Data\CustomerSecureFactory; use Magento\Customer\Model\Delegation\Data\NewOperation; use Magento\Customer\Model\Delegation\Storage as DelegatedStorage; +use Magento\Customer\Model\ResourceModel\Customer\Collection; use Magento\Framework\Api\DataObjectHelper; use Magento\Framework\Api\ExtensibleDataObjectConverter; use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;