From 40a8866a2ea9fec04866bbe3aa7d97736255de00 Mon Sep 17 00:00:00 2001 From: Bartosz Kubicki Date: Wed, 29 Apr 2020 23:18:29 +0200 Subject: [PATCH 1/2] Moving Magento_Rss and Magento_AdminNotification from testsuite to corresponding modules --- .../Adminhtml/Notification/MarkAsReadTest.php | 11 +++- .../Notification/MassMarkAsReadTest.php | 28 +++++++++ .../Adminhtml/Notification/MassRemoveTest.php | 15 ++++- .../Adminhtml/Notification/RemoveTest.php | 26 ++++++++ .../Inbox/Collection/CriticalTest.php | 42 +++++++++++++ .../Test/Integration/_files/notifications.php | 62 +++++++++++++++++++ .../Controller/Feed/IndexTest.php | 49 ++++++++++----- .../Notification/MassMarkAsReadTest.php | 19 ------ .../Adminhtml/Notification/RemoveTest.php | 16 ----- .../Inbox/Collection/CriticalTest.php | 30 --------- .../_files/notifications.php | 54 ---------------- 11 files changed, 211 insertions(+), 141 deletions(-) rename {dev/tests/integration/testsuite/Magento/AdminNotification => app/code/Magento/AdminNotification/Test/Integration}/Controller/Adminhtml/Notification/MarkAsReadTest.php (59%) create mode 100644 app/code/Magento/AdminNotification/Test/Integration/Controller/Adminhtml/Notification/MassMarkAsReadTest.php rename {dev/tests/integration/testsuite/Magento/AdminNotification => app/code/Magento/AdminNotification/Test/Integration}/Controller/Adminhtml/Notification/MassRemoveTest.php (50%) create mode 100644 app/code/Magento/AdminNotification/Test/Integration/Controller/Adminhtml/Notification/RemoveTest.php create mode 100644 app/code/Magento/AdminNotification/Test/Integration/Model/ResourceModel/Inbox/Collection/CriticalTest.php create mode 100644 app/code/Magento/AdminNotification/Test/Integration/_files/notifications.php rename {dev/tests/integration/testsuite/Magento/Rss => app/code/Magento/Rss/Test/Integration}/Controller/Feed/IndexTest.php (60%) delete mode 100644 dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsReadTest.php delete mode 100644 dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/RemoveTest.php delete mode 100644 dev/tests/integration/testsuite/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/CriticalTest.php delete mode 100644 dev/tests/integration/testsuite/Magento/AdminNotification/_files/notifications.php diff --git a/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsReadTest.php b/app/code/Magento/AdminNotification/Test/Integration/Controller/Adminhtml/Notification/MarkAsReadTest.php similarity index 59% rename from dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsReadTest.php rename to app/code/Magento/AdminNotification/Test/Integration/Controller/Adminhtml/Notification/MarkAsReadTest.php index ab72a2e1b1dd2..c8cdcb92e1439 100644 --- a/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsReadTest.php +++ b/app/code/Magento/AdminNotification/Test/Integration/Controller/Adminhtml/Notification/MarkAsReadTest.php @@ -1,21 +1,26 @@ resource = 'Magento_AdminNotification::mark_as_read'; $this->uri = 'backend/admin/notification/markasread'; diff --git a/app/code/Magento/AdminNotification/Test/Integration/Controller/Adminhtml/Notification/MassMarkAsReadTest.php b/app/code/Magento/AdminNotification/Test/Integration/Controller/Adminhtml/Notification/MassMarkAsReadTest.php new file mode 100644 index 0000000000000..28f3f35baf996 --- /dev/null +++ b/app/code/Magento/AdminNotification/Test/Integration/Controller/Adminhtml/Notification/MassMarkAsReadTest.php @@ -0,0 +1,28 @@ +resource = 'Magento_AdminNotification::mark_as_read'; + $this->uri = 'backend/admin/notification/massmarkasread'; + $this->httpMethod = HttpRequest::METHOD_POST; + parent::setUp(); + } +} diff --git a/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemoveTest.php b/app/code/Magento/AdminNotification/Test/Integration/Controller/Adminhtml/Notification/MassRemoveTest.php similarity index 50% rename from dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemoveTest.php rename to app/code/Magento/AdminNotification/Test/Integration/Controller/Adminhtml/Notification/MassRemoveTest.php index 55ee6a58063a4..bbabfe4837580 100644 --- a/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemoveTest.php +++ b/app/code/Magento/AdminNotification/Test/Integration/Controller/Adminhtml/Notification/MassRemoveTest.php @@ -1,15 +1,24 @@ resource = 'Magento_AdminNotification::adminnotification_remove'; $this->uri = 'backend/admin/notification/massremove'; diff --git a/app/code/Magento/AdminNotification/Test/Integration/Controller/Adminhtml/Notification/RemoveTest.php b/app/code/Magento/AdminNotification/Test/Integration/Controller/Adminhtml/Notification/RemoveTest.php new file mode 100644 index 0000000000000..71ada57285832 --- /dev/null +++ b/app/code/Magento/AdminNotification/Test/Integration/Controller/Adminhtml/Notification/RemoveTest.php @@ -0,0 +1,26 @@ +resource = 'Magento_AdminNotification::adminnotification_remove'; + $this->uri = 'backend/admin/notification/remove'; + parent::setUp(); + } +} diff --git a/app/code/Magento/AdminNotification/Test/Integration/Model/ResourceModel/Inbox/Collection/CriticalTest.php b/app/code/Magento/AdminNotification/Test/Integration/Model/ResourceModel/Inbox/Collection/CriticalTest.php new file mode 100644 index 0000000000000..6572184d6826a --- /dev/null +++ b/app/code/Magento/AdminNotification/Test/Integration/Model/ResourceModel/Inbox/Collection/CriticalTest.php @@ -0,0 +1,42 @@ +model = Bootstrap::getObjectManager()->create( + Critical::class + ); + } + + /** + * @magentoDataFixture Magento_AdminNotification::Test/Integration/_files/notifications.php + * + * @return void + */ + public function testCollectionContainsLastUnreadCriticalItem(): void + { + $items = array_values($this->model->getItems()); + $this->assertEquals('Unread Critical 3', $items[0]->getTitle()); + } +} diff --git a/app/code/Magento/AdminNotification/Test/Integration/_files/notifications.php b/app/code/Magento/AdminNotification/Test/Integration/_files/notifications.php new file mode 100644 index 0000000000000..d9acf14396d5a --- /dev/null +++ b/app/code/Magento/AdminNotification/Test/Integration/_files/notifications.php @@ -0,0 +1,62 @@ +create(Inbox::class); +$message->setSeverity( + MessageInterface::SEVERITY_CRITICAL +)->setTitle( + 'Unread Critical 1' +)->save(); + +$message = $om->create(Inbox::class); +$message->setSeverity(MessageInterface::SEVERITY_MAJOR) + ->setTitle('Unread Major 1') + ->save(); + +$message = $om->create(Inbox::class); +$message->setSeverity( + MessageInterface::SEVERITY_CRITICAL +)->setTitle( + 'Unread Critical 2' +)->save(); + +$message = $om->create(Inbox::class); +$message->setSeverity( + MessageInterface::SEVERITY_CRITICAL +)->setTitle( + 'Unread Critical 3' +)->save(); + +$message = $om->create(Inbox::class); +$message->setSeverity( + MessageInterface::SEVERITY_CRITICAL +)->setTitle( + 'Read Critical 1' +)->setIsRead( + 1 +)->save(); + +$message = $om->create(Inbox::class); +$message->setSeverity(MessageInterface::SEVERITY_MAJOR) + ->setTitle('Unread Major 2') + ->save(); + +$message = $om->create(Inbox::class); +$message->setSeverity( + MessageInterface::SEVERITY_CRITICAL +)->setTitle( + 'Removed Critical 1' +)->setIsRemove( + 1 +)->save(); diff --git a/dev/tests/integration/testsuite/Magento/Rss/Controller/Feed/IndexTest.php b/app/code/Magento/Rss/Test/Integration/Controller/Feed/IndexTest.php similarity index 60% rename from dev/tests/integration/testsuite/Magento/Rss/Controller/Feed/IndexTest.php rename to app/code/Magento/Rss/Test/Integration/Controller/Feed/IndexTest.php index 9a611b8f2b9ea..b682fee09654e 100644 --- a/dev/tests/integration/testsuite/Magento/Rss/Controller/Feed/IndexTest.php +++ b/app/code/Magento/Rss/Test/Integration/Controller/Feed/IndexTest.php @@ -5,22 +5,29 @@ */ declare(strict_types=1); -namespace Magento\Rss\Controller\Feed; +namespace Magento\Rss\Test\Integration\Controller\Feed; -class IndexTest extends \Magento\TestFramework\TestCase\AbstractBackendController +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Customer\Model\Session; +use Magento\Framework\Exception\AuthenticationException; +use Magento\Rss\Model\UrlBuilder; +use Magento\TestFramework\TestCase\AbstractBackendController; +use Magento\Wishlist\Model\Wishlist; + +class IndexTest extends AbstractBackendController { /** - * @var \Magento\Rss\Model\UrlBuilder + * @var UrlBuilder */ private $urlBuilder; /** - * @var \Magento\Customer\Api\CustomerRepositoryInterface + * @var CustomerRepositoryInterface */ private $customerRepository; /** - * @var \Magento\Wishlist\Model\Wishlist + * @var Wishlist */ private $wishlist; @@ -29,15 +36,19 @@ class IndexTest extends \Magento\TestFramework\TestCase\AbstractBackendControlle */ private $customerSession; - protected function setUp() + /** + * @return void + * @throws AuthenticationException + */ + protected function setUp(): void { parent::setUp(); - $this->urlBuilder = $this->_objectManager->get(\Magento\Rss\Model\UrlBuilder::class); + $this->urlBuilder = $this->_objectManager->get(UrlBuilder::class); $this->customerRepository = $this->_objectManager->get( - \Magento\Customer\Api\CustomerRepositoryInterface::class + CustomerRepositoryInterface::class ); - $this->wishlist = $this->_objectManager->get(\Magento\Wishlist\Model\Wishlist::class); - $this->customerSession = $this->_objectManager->get(\Magento\Customer\Model\Session::class); + $this->wishlist = $this->_objectManager->get(Wishlist::class); + $this->customerSession = $this->_objectManager->get(Session::class); } /** @@ -48,13 +59,13 @@ protected function setUp() * @magentoConfigFixture current_store rss/wishlist/active 1 * @magentoConfigFixture current_store rss/config/active 1 */ - public function testRssResponse() + public function testRssResponse(): void { $firstCustomerId = 1; $this->customerSession->setCustomerId($firstCustomerId); $customer = $this->customerRepository->getById($firstCustomerId); $customerEmail = $customer->getEmail(); - $wishlistId = $this->wishlist->loadByCustomerId($firstCustomerId)->getId(); + $wishlistId = (int) $this->wishlist->loadByCustomerId($firstCustomerId)->getId(); $this->dispatch($this->getLink($firstCustomerId, $customerEmail, $wishlistId)); $body = $this->getResponse()->getBody(); $this->assertContains('John Smith\'s Wishlist', $body); @@ -68,22 +79,28 @@ public function testRssResponse() * @magentoConfigFixture current_store rss/wishlist/active 1 * @magentoConfigFixture current_store rss/config/active 1 */ - public function testRssResponseWithIncorrectWishlistId() + public function testRssResponseWithIncorrectWishlistId(): void { $firstCustomerId = 1; $secondCustomerId = 2; $this->customerSession->setCustomerId($firstCustomerId); $customer = $this->customerRepository->getById($firstCustomerId); $customerEmail = $customer->getEmail(); - $wishlistId = $this->wishlist->loadByCustomerId($secondCustomerId, true)->getId(); + $wishlistId = (int) $this->wishlist->loadByCustomerId($secondCustomerId, true)->getId(); $this->dispatch($this->getLink($firstCustomerId, $customerEmail, $wishlistId)); $body = $this->getResponse()->getBody(); $this->assertContains('404 Not Found', $body); } - private function getLink($customerId, $customerEmail, $wishlistId) + /** + * @param int $customerId + * @param string $customerEmail + * @param int $wishlistId + * + * @return string + */ + private function getLink(int $customerId, string $customerEmail, int $wishlistId): string { - return 'rss/feed/index/type/wishlist/data/' . base64_encode($customerId . ',' . $customerEmail) . '/wishlist_id/' . $wishlistId; diff --git a/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsReadTest.php b/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsReadTest.php deleted file mode 100644 index 04a69fe200dd1..0000000000000 --- a/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsReadTest.php +++ /dev/null @@ -1,19 +0,0 @@ -resource = 'Magento_AdminNotification::mark_as_read'; - $this->uri = 'backend/admin/notification/massmarkasread'; - $this->httpMethod = HttpRequest::METHOD_POST; - parent::setUp(); - } -} diff --git a/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/RemoveTest.php b/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/RemoveTest.php deleted file mode 100644 index 47f842ff005d3..0000000000000 --- a/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/RemoveTest.php +++ /dev/null @@ -1,16 +0,0 @@ -resource = 'Magento_AdminNotification::adminnotification_remove'; - $this->uri = 'backend/admin/notification/remove'; - parent::setUp(); - } -} diff --git a/dev/tests/integration/testsuite/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/CriticalTest.php b/dev/tests/integration/testsuite/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/CriticalTest.php deleted file mode 100644 index bd0084de43041..0000000000000 --- a/dev/tests/integration/testsuite/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/CriticalTest.php +++ /dev/null @@ -1,30 +0,0 @@ -_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Critical::class - ); - } - - /** - * @magentoDataFixture Magento/AdminNotification/_files/notifications.php - */ - public function testCollectionContainsLastUnreadCriticalItem() - { - $items = array_values($this->_model->getItems()); - $this->assertEquals('Unread Critical 3', $items[0]->getTitle()); - } -} diff --git a/dev/tests/integration/testsuite/Magento/AdminNotification/_files/notifications.php b/dev/tests/integration/testsuite/Magento/AdminNotification/_files/notifications.php deleted file mode 100644 index 6615c24320b21..0000000000000 --- a/dev/tests/integration/testsuite/Magento/AdminNotification/_files/notifications.php +++ /dev/null @@ -1,54 +0,0 @@ -create(\Magento\AdminNotification\Model\Inbox::class); -$message->setSeverity( - \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL -)->setTitle( - 'Unread Critical 1' -)->save(); - -$message = $om->create(\Magento\AdminNotification\Model\Inbox::class); -$message->setSeverity(\Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR) - ->setTitle('Unread Major 1') - ->save(); - -$message = $om->create(\Magento\AdminNotification\Model\Inbox::class); -$message->setSeverity( - \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL -)->setTitle( - 'Unread Critical 2' -)->save(); - -$message = $om->create(\Magento\AdminNotification\Model\Inbox::class); -$message->setSeverity( - \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL -)->setTitle( - 'Unread Critical 3' -)->save(); - -$message = $om->create(\Magento\AdminNotification\Model\Inbox::class); -$message->setSeverity( - \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL -)->setTitle( - 'Read Critical 1' -)->setIsRead( - 1 -)->save(); - -$message = $om->create(\Magento\AdminNotification\Model\Inbox::class); -$message->setSeverity(\Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR) - ->setTitle('Unread Major 2') - ->save(); - -$message = $om->create(\Magento\AdminNotification\Model\Inbox::class); -$message->setSeverity( - \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL -)->setTitle( - 'Removed Critical 1' -)->setIsRemove( - 1 -)->save(); From cd630aed8c3a1c43c114c0e3dadcd5dc08b2d2a0 Mon Sep 17 00:00:00 2001 From: Bartosz Kubicki Date: Wed, 3 Jun 2020 17:30:16 +0200 Subject: [PATCH 2/2] Removing already moved integration tests --- .../Controller/Adminhtml/Notification/MassMarkAsReadTest.php | 0 .../Controller/Adminhtml/Notification/RemoveTest.php | 0 .../Model/ResourceModel/Inbox/Collection/CriticalTest.php | 0 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsReadTest.php delete mode 100644 dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/RemoveTest.php delete mode 100644 dev/tests/integration/testsuite/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/CriticalTest.php diff --git a/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsReadTest.php b/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsReadTest.php deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/RemoveTest.php b/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/RemoveTest.php deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/dev/tests/integration/testsuite/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/CriticalTest.php b/dev/tests/integration/testsuite/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/CriticalTest.php deleted file mode 100644 index e69de29bb2d1d..0000000000000