forked from magento/magento2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2.4-develop' into fix-for-issue-23619-luma-theme
- Loading branch information
Showing
2,321 changed files
with
50,065 additions
and
20,912 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/ActionsTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
/** | ||
* Test class for \Magento\AdminNotification\Block\Grid\Renderer\Actions | ||
*/ | ||
|
||
namespace Magento\AdminNotification\Test\Unit\Block\Grid\Renderer; | ||
|
||
use Magento\AdminNotification\Block\Grid\Renderer\Actions; | ||
use Magento\Backend\Block\Context; | ||
use Magento\Framework\DataObject; | ||
use Magento\Framework\Escaper; | ||
use Magento\Framework\Url\Helper\Data; | ||
use Magento\Framework\UrlInterface; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ActionsTest extends TestCase | ||
{ | ||
/** | ||
* System under Test | ||
* @var Actions | ||
*/ | ||
private $sut; | ||
|
||
protected function setUp() : void | ||
{ | ||
parent::setUp(); | ||
|
||
/** @var Escaper | \PHPUnit_Framework_MockObject_MockObject $escaperMock */ | ||
$escaperMock = $this->getMockBuilder(Escaper::class)->disableOriginalConstructor()->getMock(); | ||
$escaperMock->expects($this->once())->method('escapeUrl')->willReturn('https://magento.com'); | ||
|
||
/** @var UrlInterface | \PHPUnit_Framework_MockObject_MockObject $urlBuilder */ | ||
$urlBuilder = $this->getMockBuilder(UrlInterface::class)->getMock(); | ||
$urlBuilder->expects($this->once())->method('getUrl')->willReturn('http://magento.com'); | ||
|
||
/** @var Context | \PHPUnit_Framework_MockObject_MockObject $contextMock */ | ||
$contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock(); | ||
$contextMock->expects($this->once())->method('getEscaper')->willReturn($escaperMock); | ||
$contextMock->expects($this->once())->method('getUrlBuilder')->willReturn($urlBuilder); | ||
|
||
/** @var Data | \PHPUnit_Framework_MockObject_MockObject $urlHelperMock */ | ||
$urlHelperMock = $this->getMockBuilder(Data::class)->disableOriginalConstructor()->getMock(); | ||
$urlHelperMock->expects($this->once())->method('getEncodedUrl')->willReturn('http://magento.com'); | ||
|
||
$this->sut = new Actions($contextMock, $urlHelperMock); | ||
} | ||
|
||
public function testShouldRenderMessageWhenUrlIsGiven() : void | ||
{ | ||
$dataObject = new DataObject(); | ||
$dataObject->setdata('url', 'https://magento.com'); | ||
$dataObject->setdata('is_read', true); | ||
$dataObject->setdata('id', 1); | ||
|
||
$actual = $this->sut->render($dataObject); | ||
|
||
// Ignoring Code Style at this point due to the long HEREDOC | ||
// phpcs:disable | ||
$expected = <<<HTML | ||
<a class="action-details" target="_blank" href="https://magento.com">Read Details</a><a class="action-delete" href="http://magento.com" onClick="deleteConfirm('Are you sure?', this.href); return false;">Remove</a> | ||
HTML; | ||
// phpcs:enable | ||
|
||
$this->assertEquals($actual, $expected); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/NoticeTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
/** | ||
* Test class for \Magento\AdminNotification\Block\Grid\Renderer\Actions | ||
*/ | ||
namespace Magento\AdminNotification\Test\Unit\Block\Grid\Renderer; | ||
|
||
use Magento\AdminNotification\Block\Grid\Renderer\Notice; | ||
use Magento\Framework\DataObject; | ||
use Magento\Framework\Escaper; | ||
use Magento\Backend\Block\Context; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class NoticeTest extends TestCase | ||
{ | ||
/** | ||
* System under Test | ||
* | ||
* @var Notice | ||
*/ | ||
private $sut; | ||
|
||
protected function setUp() : void | ||
{ | ||
parent::setUp(); | ||
|
||
/** @var Escaper | \PHPUnit_Framework_MockObject_MockObject $escaperMock */ | ||
$escaperMock = $this->getMockBuilder(Escaper::class)->disableOriginalConstructor()->getMock(); | ||
$escaperMock->expects($this->exactly(2))->method('escapeHtml')->willReturn('<div>Some random html</div>'); | ||
|
||
/** @var Context | \PHPUnit_Framework_MockObject_MockObject $contextMock */ | ||
$contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock(); | ||
$contextMock->expects($this->once())->method('getEscaper')->willReturn($escaperMock); | ||
|
||
$this->sut = new Notice($contextMock); | ||
} | ||
|
||
public function testShouldRenderNotice() : void | ||
{ | ||
$dataObject = new DataObject(); | ||
$dataObject->setData('title', 'A great Title'); | ||
$dataObject->setData('description', 'Handy description right here'); | ||
|
||
$actual = $this->sut->render($dataObject); | ||
$expected = '<span class="grid-row-title"><div>Some random html</div></span><br /><div>Some random html</div>'; | ||
|
||
$this->assertEquals($actual, $expected); | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/SeverityTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
/** | ||
* Test class for \Magento\AdminNotification\Block\Grid\Renderer\Actions | ||
*/ | ||
namespace Magento\AdminNotification\Test\Unit\Block\Grid\Renderer; | ||
|
||
use Magento\AdminNotification\Block\Grid\Renderer\Severity; | ||
use Magento\AdminNotification\Model\Inbox; | ||
use Magento\Backend\Block\Context; | ||
use Magento\Backend\Block\Widget\Grid\Column; | ||
use Magento\Framework\DataObject; | ||
use Magento\Framework\Escaper; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class SeverityTest extends TestCase | ||
{ | ||
/** | ||
* System under Test | ||
* | ||
* @var Severity | ||
*/ | ||
private $sut; | ||
|
||
protected function setUp() : void | ||
{ | ||
parent::setUp(); | ||
|
||
/** @var Inbox |\PHPUnit_Framework_MockObject_MockObject $inboxMock */ | ||
$inboxMock = $this->getMockBuilder(Inbox::class)->disableOriginalConstructor()->getMock(); | ||
|
||
/** @var Context | \PHPUnit_Framework_MockObject_MockObject $contextMock */ | ||
$contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock(); | ||
|
||
$this->sut = new Severity($contextMock, $inboxMock); | ||
} | ||
|
||
public function testShouldRenderSeverity() : void | ||
{ | ||
/** @var Column | \PHPUnit_Framework_MockObject_MockObject $columnMock */ | ||
$columnMock = $this->getMockBuilder(Column::class) | ||
->disableOriginalConstructor() | ||
->setMethods(['getIndex']) | ||
->getMock(); | ||
$columnMock->expects($this->exactly(5))->method('getIndex')->willReturn('index'); | ||
$this->sut->setColumn($columnMock); | ||
$dataObject = new DataObject(); | ||
|
||
// Test critical severity | ||
$dataObject->setData('index', 1); | ||
$actual = $this->sut->render($dataObject); | ||
$expected = '<span class="grid-severity-critical"><span></span></span>'; | ||
|
||
$this->assertEquals($actual, $expected); | ||
|
||
// Test major severity | ||
$dataObject->setData('index', 2); | ||
$actual = $this->sut->render($dataObject); | ||
$expected = '<span class="grid-severity-major"><span></span></span>'; | ||
|
||
$this->assertEquals($actual, $expected); | ||
|
||
// Test minor severity | ||
$dataObject->setData('index', 3); | ||
$actual = $this->sut->render($dataObject); | ||
$expected = '<span class="grid-severity-minor"><span></span></span>'; | ||
|
||
$this->assertEquals($actual, $expected); | ||
|
||
// Test notice severity | ||
$dataObject->setData('index', 4); | ||
$actual = $this->sut->render($dataObject); | ||
$expected = '<span class="grid-severity-notice"><span></span></span>'; | ||
|
||
$this->assertEquals($actual, $expected); | ||
|
||
// Test default severity | ||
$dataObject->setData('index', 5); | ||
$actual = $this->sut->render($dataObject); | ||
$expected = '<span class="grid-severity-"><span></span></span>'; | ||
|
||
$this->assertEquals($actual, $expected); | ||
} | ||
} |
Oops, something went wrong.