From b7983889cf3a12a59da0468a2b089d400027c264 Mon Sep 17 00:00:00 2001 From: Denis Kopylov Date: Tue, 16 Mar 2021 12:07:34 +0300 Subject: [PATCH 1/7] [AdobeStockImageAdminUi] Fix class extends and unit tests related to PR magento/magento2/pull/32090 --- .../Ui/Component/Listing/Filter/ColorTest.php | 16 +++++++++++++--- .../Ui/Component/Listing/Filter/Color.php | 9 ++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/AdobeStockImageAdminUi/Test/Unit/Ui/Component/Listing/Filter/ColorTest.php b/AdobeStockImageAdminUi/Test/Unit/Ui/Component/Listing/Filter/ColorTest.php index df5a91a763c6..d19bedae968d 100644 --- a/AdobeStockImageAdminUi/Test/Unit/Ui/Component/Listing/Filter/ColorTest.php +++ b/AdobeStockImageAdminUi/Test/Unit/Ui/Component/Listing/Filter/ColorTest.php @@ -19,6 +19,7 @@ use Magento\Ui\Component\Filters\FilterModifier; use Magento\Ui\Component\Filters\Type\Input; use Magento\Ui\Model\ColorPicker\ColorModesProvider; +use Magento\Ui\View\Element\BookmarkContextInterface; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -95,6 +96,12 @@ private function createObject(array $data, ContextInterface $context): Color $this->filterBuilder = $this->createMock(FilterBuilder::class); $this->filterModifier = $this->createMock(FilterModifier::class); $this->colorModesProvider = $this->createMock(ColorModesProvider::class); + + $bookmarkContextMock = $this->getMockForAbstractClass( + BookmarkContextInterface::class + ); + $bookmarkContextMock->expects($this->once())->method('getFilterData'); + return new Color( $context, $this->uiComponentFactory, @@ -102,7 +109,8 @@ private function createObject(array $data, ContextInterface $context): Color $this->filterModifier, $this->colorModesProvider, [], - $data + $data, + $bookmarkContextMock ); } @@ -230,10 +238,12 @@ public function colorPickerModeProvider(): array { return [ [ - 'full', '#21ffff' + 'full', + '#21ffff' ], [ - null, '#ffffff' + null, + '#ffffff' ] ]; } diff --git a/AdobeStockImageAdminUi/Ui/Component/Listing/Filter/Color.php b/AdobeStockImageAdminUi/Ui/Component/Listing/Filter/Color.php index 9caed61ca93a..3f8de6bc5f13 100644 --- a/AdobeStockImageAdminUi/Ui/Component/Listing/Filter/Color.php +++ b/AdobeStockImageAdminUi/Ui/Component/Listing/Filter/Color.php @@ -16,8 +16,8 @@ use Magento\Ui\Component\Filters\Type\AbstractFilter; use Magento\Ui\Component\Filters\Type\Input; use Magento\Ui\Component\Form\Element\ColorPicker; -use Magento\Ui\Component\Form\Element\Input as ElementInput; use Magento\Ui\Model\ColorPicker\ColorModesProvider; +use Magento\Ui\View\Element\BookmarkContextInterface; /** * Color grid filter @@ -42,6 +42,7 @@ class Color extends AbstractFilter * @param ColorModesProvider $modesProvider * @param array $components * @param array $data + * @param BookmarkContextInterface|null $bookmarkContext */ public function __construct( ContextInterface $context, @@ -50,7 +51,8 @@ public function __construct( FilterModifier $filterModifier, ColorModesProvider $modesProvider, array $components = [], - array $data = [] + array $data = [], + BookmarkContextInterface $bookmarkContext = null ) { $this->modesProvider = $modesProvider; parent::__construct( @@ -59,7 +61,8 @@ public function __construct( $filterBuilder, $filterModifier, $components, - $data + $data, + $bookmarkContext ); } From 23828a842fd17a25b6b3dcacdcdbed14e342b327 Mon Sep 17 00:00:00 2001 From: Denis Kopylov Date: Tue, 16 Mar 2021 22:10:47 +0300 Subject: [PATCH 2/7] Fix unit tests --- .../Ui/Component/Listing/Filter/ColorTest.php | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/AdobeStockImageAdminUi/Test/Unit/Ui/Component/Listing/Filter/ColorTest.php b/AdobeStockImageAdminUi/Test/Unit/Ui/Component/Listing/Filter/ColorTest.php index d19bedae968d..ad6a90098832 100644 --- a/AdobeStockImageAdminUi/Test/Unit/Ui/Component/Listing/Filter/ColorTest.php +++ b/AdobeStockImageAdminUi/Test/Unit/Ui/Component/Listing/Filter/ColorTest.php @@ -88,9 +88,10 @@ class ColorTest extends TestCase * * @param array $data * @param ContextInterface $context + * @param array $filderData * @return Color */ - private function createObject(array $data, ContextInterface $context): Color + private function createObject(array $data, ContextInterface $context, array $filderData): Color { $this->uiComponentFactory = $this->createMock(UiComponentFactory::class); $this->filterBuilder = $this->createMock(FilterBuilder::class); @@ -100,7 +101,9 @@ private function createObject(array $data, ContextInterface $context): Color $bookmarkContextMock = $this->getMockForAbstractClass( BookmarkContextInterface::class ); - $bookmarkContextMock->expects($this->once())->method('getFilterData'); + $bookmarkContextMock->expects($this->once()) + ->method('getFilterData') + ->willReturn($filderData); return new Color( $context, @@ -117,15 +120,11 @@ private function createObject(array $data, ContextInterface $context): Color /** * Get context * - * @param array $filterParams - * @return ContextInterface + * @return MockObject|ContextInterface */ - private function getContext(array $filterParams): ContextInterface + private function getContext(): MockObject { $context = $this->createMock(ContextInterface::class); - $context->expects($this->once()) - ->method('getFiltersParams') - ->willReturn($filterParams); $context->expects($this->any()) ->method('getNamespace'); @@ -151,11 +150,7 @@ private function getContext(array $filterParams): ContextInterface public function testPrepare(?string $colorPickerMode, string $appliedValue): void { $filter = $this->createMock(Filter::class); - $context = $this->getContext( - [ - self::FILTER_NAME => $appliedValue - ] - ); + $context = $this->getContext(); $color = $this->createObject( [ @@ -164,7 +159,10 @@ public function testPrepare(?string $colorPickerMode, string $appliedValue): voi ], 'name' => self::FILTER_NAME ], - $context + $context, + [ + self::FILTER_NAME => $appliedValue + ] ); $this->uiComponentFactory->expects($this->once()) From 26cee8e4fbf5f3d224a69c0816e95523c0090bb6 Mon Sep 17 00:00:00 2001 From: Denis Kopylov Date: Wed, 17 Mar 2021 13:48:33 +0300 Subject: [PATCH 3/7] Update parameter name --- .../Test/Unit/Ui/Component/Listing/Filter/ColorTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AdobeStockImageAdminUi/Test/Unit/Ui/Component/Listing/Filter/ColorTest.php b/AdobeStockImageAdminUi/Test/Unit/Ui/Component/Listing/Filter/ColorTest.php index ad6a90098832..74bdf25f1b82 100644 --- a/AdobeStockImageAdminUi/Test/Unit/Ui/Component/Listing/Filter/ColorTest.php +++ b/AdobeStockImageAdminUi/Test/Unit/Ui/Component/Listing/Filter/ColorTest.php @@ -88,10 +88,10 @@ class ColorTest extends TestCase * * @param array $data * @param ContextInterface $context - * @param array $filderData + * @param array $filterData * @return Color */ - private function createObject(array $data, ContextInterface $context, array $filderData): Color + private function createObject(array $data, ContextInterface $context, array $filterData): Color { $this->uiComponentFactory = $this->createMock(UiComponentFactory::class); $this->filterBuilder = $this->createMock(FilterBuilder::class); @@ -103,7 +103,7 @@ private function createObject(array $data, ContextInterface $context, array $fil ); $bookmarkContextMock->expects($this->once()) ->method('getFilterData') - ->willReturn($filderData); + ->willReturn($filterData); return new Color( $context, From 3d44e33995451e612625674ecf760dd508313353 Mon Sep 17 00:00:00 2001 From: Denis Kopylov Date: Thu, 25 Mar 2021 13:12:21 +0300 Subject: [PATCH 4/7] Refactroign due to usage of BookmarkContextProvider --- .../Ui/Component/Listing/Filter/Color.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/AdobeStockImageAdminUi/Ui/Component/Listing/Filter/Color.php b/AdobeStockImageAdminUi/Ui/Component/Listing/Filter/Color.php index 3f8de6bc5f13..5e6e3b05290f 100644 --- a/AdobeStockImageAdminUi/Ui/Component/Listing/Filter/Color.php +++ b/AdobeStockImageAdminUi/Ui/Component/Listing/Filter/Color.php @@ -17,7 +17,7 @@ use Magento\Ui\Component\Filters\Type\Input; use Magento\Ui\Component\Form\Element\ColorPicker; use Magento\Ui\Model\ColorPicker\ColorModesProvider; -use Magento\Ui\View\Element\BookmarkContextInterface; +use Magento\Ui\View\Element\BookmarkContextProviderInterface; /** * Color grid filter @@ -42,7 +42,7 @@ class Color extends AbstractFilter * @param ColorModesProvider $modesProvider * @param array $components * @param array $data - * @param BookmarkContextInterface|null $bookmarkContext + * @param BookmarkContextProviderInterface|null $bookmarkContextProvider */ public function __construct( ContextInterface $context, @@ -52,7 +52,7 @@ public function __construct( ColorModesProvider $modesProvider, array $components = [], array $data = [], - BookmarkContextInterface $bookmarkContext = null + BookmarkContextProviderInterface $bookmarkContextProvider = null ) { $this->modesProvider = $modesProvider; parent::__construct( @@ -62,7 +62,7 @@ public function __construct( $filterModifier, $components, $data, - $bookmarkContext + $bookmarkContextProvider ); } From fc994540475c0cedba4b20d0c38b75c527d5959d Mon Sep 17 00:00:00 2001 From: Denis Kopylov Date: Thu, 25 Mar 2021 15:36:53 +0300 Subject: [PATCH 5/7] Fix unit tests --- .../Unit/Ui/Component/Listing/Filter/ColorTest.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/AdobeStockImageAdminUi/Test/Unit/Ui/Component/Listing/Filter/ColorTest.php b/AdobeStockImageAdminUi/Test/Unit/Ui/Component/Listing/Filter/ColorTest.php index 74bdf25f1b82..c6755507e44c 100644 --- a/AdobeStockImageAdminUi/Test/Unit/Ui/Component/Listing/Filter/ColorTest.php +++ b/AdobeStockImageAdminUi/Test/Unit/Ui/Component/Listing/Filter/ColorTest.php @@ -20,12 +20,13 @@ use Magento\Ui\Component\Filters\Type\Input; use Magento\Ui\Model\ColorPicker\ColorModesProvider; use Magento\Ui\View\Element\BookmarkContextInterface; +use Magento\Ui\View\Element\BookmarkContextProviderInterface; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; /** * ColorTest test. - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects)= */ class ColorTest extends TestCase { @@ -98,12 +99,18 @@ private function createObject(array $data, ContextInterface $context, array $fil $this->filterModifier = $this->createMock(FilterModifier::class); $this->colorModesProvider = $this->createMock(ColorModesProvider::class); + $bookmarkContextProviderMock = $this->getMockForAbstractClass( + BookmarkContextProviderInterface::class + ); $bookmarkContextMock = $this->getMockForAbstractClass( BookmarkContextInterface::class ); $bookmarkContextMock->expects($this->once()) ->method('getFilterData') ->willReturn($filterData); + $bookmarkContextProviderMock->expects($this->once()) + ->method('getByUiContext') + ->willReturn($bookmarkContextMock); return new Color( $context, @@ -113,7 +120,7 @@ private function createObject(array $data, ContextInterface $context, array $fil $this->colorModesProvider, [], $data, - $bookmarkContextMock + $bookmarkContextProviderMock ); } From 2b4c75707c5728b912ab26c1f8e615e11a1ec7cf Mon Sep 17 00:00:00 2001 From: Denis Kopylov Date: Sat, 10 Apr 2021 23:13:50 +0300 Subject: [PATCH 6/7] Update AdminAdobeStockSignInACLTest --- .../Test/Mftf/Test/AdminAdobeStockSignInACLTest.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/AdobeStockImageAdminUi/Test/Mftf/Test/AdminAdobeStockSignInACLTest.xml b/AdobeStockImageAdminUi/Test/Mftf/Test/AdminAdobeStockSignInACLTest.xml index 10781821bea1..808a5f3c1e20 100644 --- a/AdobeStockImageAdminUi/Test/Mftf/Test/AdminAdobeStockSignInACLTest.xml +++ b/AdobeStockImageAdminUi/Test/Mftf/Test/AdminAdobeStockSignInACLTest.xml @@ -24,7 +24,6 @@ - From a252eb42dea5e83d734ec2704c952aa2777ae4cf Mon Sep 17 00:00:00 2001 From: Denis Kopylov Date: Thu, 15 Apr 2021 07:36:23 +0300 Subject: [PATCH 7/7] Rollback action for mftf --- .../Test/Mftf/Test/AdminAdobeStockSignInACLTest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/AdobeStockImageAdminUi/Test/Mftf/Test/AdminAdobeStockSignInACLTest.xml b/AdobeStockImageAdminUi/Test/Mftf/Test/AdminAdobeStockSignInACLTest.xml index 808a5f3c1e20..10781821bea1 100644 --- a/AdobeStockImageAdminUi/Test/Mftf/Test/AdminAdobeStockSignInACLTest.xml +++ b/AdobeStockImageAdminUi/Test/Mftf/Test/AdminAdobeStockSignInACLTest.xml @@ -24,6 +24,7 @@ +