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 63% 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 ca2033b2efda2..dc52e60c3b4c2 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,24 +1,29 @@ resource = 'Magento_AdminNotification::mark_as_read'; $this->uri = 'backend/admin/notification/markasread'; - parent::setUp(); } } diff --git a/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsReadTest.php b/app/code/Magento/AdminNotification/Test/Integration/Controller/Adminhtml/Notification/MassMarkAsReadTest.php similarity index 53% rename from dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsReadTest.php rename to app/code/Magento/AdminNotification/Test/Integration/Controller/Adminhtml/Notification/MassMarkAsReadTest.php index ea5fd8ec72ab1..b0155ae985e22 100644 --- a/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsReadTest.php +++ b/app/code/Magento/AdminNotification/Test/Integration/Controller/Adminhtml/Notification/MassMarkAsReadTest.php @@ -1,19 +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 54% 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 06ccf4bb8a4af..ba9e9cf01e971 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,19 +1,28 @@ resource = 'Magento_AdminNotification::adminnotification_remove'; $this->uri = 'backend/admin/notification/massremove'; $this->httpMethod = HttpRequest::METHOD_POST; - parent::setUp(); } } 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..98cb38afa6dfc --- /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'; + } +} 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..5bf6a27675d74 --- /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..d62914d6902de --- /dev/null +++ b/app/code/Magento/AdminNotification/Test/Integration/_files/notifications.php @@ -0,0 +1,57 @@ +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 62% 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 991914460c61b..19b09433ef790 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; + /** + * @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(): void * @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->assertStringContainsString('