diff --git a/Controller/Adminhtml/Notifications/Overview.php b/Controller/Adminhtml/Notifications/Overview.php index 276f1bd3b0..8e6822ac8a 100644 --- a/Controller/Adminhtml/Notifications/Overview.php +++ b/Controller/Adminhtml/Notifications/Overview.php @@ -11,18 +11,26 @@ namespace Adyen\Payment\Controller\Adminhtml\Notifications; -class Overview extends \Magento\Backend\App\Action +use Magento\Backend\App\Action; +use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\View\Result\Page; + +class Overview extends Action { /** * Load the page defined in corresponding layout XML * - * @return \Magento\Framework\View\Result\Page + * @return Page */ - public function execute() + public function execute(): Page { - $resultPage = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_PAGE); + /** @var Page $resultPage */ + $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); $resultPage->setActiveMenu('Adyen_Payment::notifications_overview') - ->getConfig()->getTitle()->prepend(__('Adyen Notifications Overview')); + ->getConfig() + ->getTitle() + ->prepend(__('Adyen Webhooks Overview')); + return $resultPage; } } diff --git a/Test/Unit/Controller/Adminhtml/Notification/OverviewTest.php b/Test/Unit/Controller/Adminhtml/Notification/OverviewTest.php new file mode 100644 index 0000000000..d51f7c6aba --- /dev/null +++ b/Test/Unit/Controller/Adminhtml/Notification/OverviewTest.php @@ -0,0 +1,57 @@ + + */ + +namespace Adyen\Payment\Test\Unit\Controller\Adminhtml\Notification; + +use Adyen\Payment\Controller\Adminhtml\Notifications\Overview; +use Adyen\Payment\Test\Unit\AbstractAdyenTestCase; +use Magento\Backend\Model\View\Result\Page; +use Magento\Backend\App\Action\Context; +use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\View\Page\Config; +use Magento\Framework\View\Page\Title; + +class OverviewTest extends AbstractAdyenTestCase +{ + /** + * @return void + */ + public function testExecute() + { + $titleMock = $this->createMock(Title::class); + $titleMock->expects($this->once()) + ->method('prepend') + ->with(__('Adyen Webhooks Overview')); + + $configMock = $this->createMock(Config::class); + $configMock->method('getTitle')->willReturn($titleMock); + + $pageMock = $this->createMock(Page::class); + $pageMock->method('setActiveMenu') + ->with('Adyen_Payment::notifications_overview') + ->willReturnSelf(); + $pageMock->method('getConfig')->willReturn($configMock); + + $resultFactoryMock = $this->createMock(ResultFactory::class); + $resultFactoryMock->expects($this->once()) + ->method('create') + ->with(ResultFactory::TYPE_PAGE) + ->willReturn($pageMock); + + $contextMock = $this->createMock(Context::class); + $contextMock->method('getResultFactory')->willReturn($resultFactoryMock); + + $overview = new Overview($contextMock); + + $result = $overview->execute(); + $this->assertInstanceOf(Page::class, $result); + } +}