Skip to content

Commit

Permalink
[EPC-9177] Refactor the overview page title
Browse files Browse the repository at this point in the history
  • Loading branch information
Can Demiralp committed Feb 14, 2025
1 parent 5103a62 commit 2ae0815
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 5 deletions.
18 changes: 13 additions & 5 deletions Controller/Adminhtml/Notifications/Overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
57 changes: 57 additions & 0 deletions Test/Unit/Controller/Adminhtml/Notification/OverviewTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2025 Adyen N.V. (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/

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);
}
}

0 comments on commit 2ae0815

Please sign in to comment.