Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration testssuite decomposition - Rss and AdminNotification #28733

Open
wants to merge 1 commit into
base: 2.4-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
<?php
/***

declare(strict_types=1);

/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AdminNotification\Controller\Adminhtml\Notification;
namespace Magento\AdminNotification\Test\Integration\Controller\Adminhtml\Notification;

use Magento\TestFramework\TestCase\AbstractBackendController;

/**
* Testing markAsRead controller.
*
* @magentoAppArea adminhtml
*/
class MarkAsReadTest extends \Magento\TestFramework\TestCase\AbstractBackendController
class MarkAsReadTest extends AbstractBackendController
{
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$this->resource = 'Magento_AdminNotification::mark_as_read';
$this->uri = 'backend/admin/notification/markasread';
parent::setUp();
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
<?php
/***

declare(strict_types=1);

/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AdminNotification\Controller\Adminhtml\Notification;
namespace Magento\AdminNotification\Test\Integration\Controller\Adminhtml\Notification;

use Magento\Framework\App\Request\Http as HttpRequest;
use Magento\Framework\Exception\AuthenticationException;
use Magento\TestFramework\TestCase\AbstractBackendController;

class MassMarkAsReadTest extends \Magento\TestFramework\TestCase\AbstractBackendController
class MassMarkAsReadTest extends AbstractBackendController
{
/**
* @return void
* @throws AuthenticationException
*/
protected function setUp(): void
{
parent::setUp();
$this->resource = 'Magento_AdminNotification::mark_as_read';
$this->uri = 'backend/admin/notification/massmarkasread';
$this->httpMethod = HttpRequest::METHOD_POST;
parent::setUp();
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
<?php
/***

declare(strict_types=1);

/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AdminNotification\Controller\Adminhtml\Notification;
namespace Magento\AdminNotification\Test\Integration\Controller\Adminhtml\Notification;

use Magento\Framework\App\Request\Http as HttpRequest;
use Magento\Framework\Exception\AuthenticationException;
use Magento\TestFramework\TestCase\AbstractBackendController;

class MassRemoveTest extends \Magento\TestFramework\TestCase\AbstractBackendController
class MassRemoveTest extends AbstractBackendController
{
/**
* @return void
* @throws AuthenticationException
*/
protected function setUp(): void
{
parent::setUp();
$this->resource = 'Magento_AdminNotification::adminnotification_remove';
$this->uri = 'backend/admin/notification/massremove';
$this->httpMethod = HttpRequest::METHOD_POST;
parent::setUp();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AdminNotification\Test\Integration\Controller\Adminhtml\Notification;

use Magento\Framework\Exception\AuthenticationException;
use Magento\TestFramework\TestCase\AbstractBackendController;

class RemoveTest extends AbstractBackendController
{
/**
* @return void
* @throws AuthenticationException
*/
protected function setUp(): void
{
parent::setUp();
$this->resource = 'Magento_AdminNotification::adminnotification_remove';
$this->uri = 'backend/admin/notification/remove';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AdminNotification\Test\Integration\Model\ResourceModel\Inbox\Collection;

use Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Critical;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;

class CriticalTest extends TestCase
{
/**
* @var Critical
*/
private $model;

/**
* @return void
*/
protected function setUp(): void
{
$this->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());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

declare(strict_types=1);

/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

use Magento\AdminNotification\Model\Inbox;
use Magento\Framework\Notification\MessageInterface;
use Magento\TestFramework\Helper\Bootstrap;

$om = Bootstrap::getObjectManager();
$message = $om->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();
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}

/**
Expand All @@ -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('<title>John Smith\'s Wishlist</title>', $body);
Expand All @@ -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->assertStringContainsString('<title>404 Not Found</title>', $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;
Expand Down

This file was deleted.

This file was deleted.

Loading