Skip to content

Commit

Permalink
Merge branch '2.4-develop' into fix-for-issue-23619-luma-theme
Browse files Browse the repository at this point in the history
  • Loading branch information
slavvka authored Jan 15, 2020
2 parents 4abaaa0 + 3a55648 commit 5657076
Show file tree
Hide file tree
Showing 2,321 changed files with 50,065 additions and 20,912 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/AdminAnalytics/registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
* See COPYING.txt for license details.
*/

use \Magento\Framework\Component\ComponentRegistrar;
use Magento\Framework\Component\ComponentRegistrar;

ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_AdminAnalytics', __DIR__);
27 changes: 15 additions & 12 deletions app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

/**
* Adminhtml AdminNotification Severity Renderer
*
Expand All @@ -8,12 +10,16 @@

namespace Magento\AdminNotification\Block\Grid\Renderer;

use Magento\Backend\Block\Context;
use Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer;
use Magento\Framework\App\ActionInterface;
use Magento\Framework\DataObject;
use Magento\Framework\Url\Helper\Data;

/**
* Renderer class for action in the admin notifications grid
*
* @package Magento\AdminNotification\Block\Grid\Renderer
*/
class Actions extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
class Actions extends AbstractRenderer
{
/**
* @var \Magento\Framework\Url\Helper\Data
Expand All @@ -25,11 +31,8 @@ class Actions extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstrac
* @param \Magento\Framework\Url\Helper\Data $urlHelper
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Context $context,
\Magento\Framework\Url\Helper\Data $urlHelper,
array $data = []
) {
public function __construct(Context $context, Data $urlHelper, array $data = [])
{
$this->_urlHelper = $urlHelper;
parent::__construct($context, $data);
}
Expand All @@ -40,7 +43,7 @@ public function __construct(
* @param \Magento\Framework\DataObject $row
* @return string
*/
public function render(\Magento\Framework\DataObject $row)
public function render(DataObject $row)
{
$readDetailsHtml = $row->getUrl() ? '<a class="action-details" target="_blank" href="' .
$this->escapeUrl($row->getUrl())
Expand All @@ -49,7 +52,7 @@ public function render(\Magento\Framework\DataObject $row)

$markAsReadHtml = !$row->getIsRead() ? '<a class="action-mark" href="' . $this->getUrl(
'*/*/markAsRead/',
['_current' => true, 'id' => $row->getId()]
['_current' => true, 'id' => $row->getNotificationId()]
) . '">' . __(
'Mark as Read'
) . '</a>' : '';
Expand All @@ -63,8 +66,8 @@ public function render(\Magento\Framework\DataObject $row)
'*/*/remove/',
[
'_current' => true,
'id' => $row->getId(),
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $encodedUrl
'id' => $row->getNotificationId(),
ActionInterface::PARAM_NAME_URL_ENCODED => $encodedUrl
]
),
__('Are you sure?'),
Expand Down
12 changes: 10 additions & 2 deletions app/code/Magento/AdminNotification/Block/Grid/Renderer/Notice.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

/**
* Adminhtml AdminNotification Severity Renderer
*
Expand All @@ -7,15 +9,21 @@
*/
namespace Magento\AdminNotification\Block\Grid\Renderer;

class Notice extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
use Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer;
use Magento\Framework\DataObject;

/**
* Renderer class for notice in the admin notifications grid
*/
class Notice extends AbstractRenderer
{
/**
* Renders grid column
*
* @param \Magento\Framework\DataObject $row
* @return string
*/
public function render(\Magento\Framework\DataObject $row)
public function render(DataObject $row)
{
return '<span class="grid-row-title">' .
$this->escapeHtml($row->getTitle()) .
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

/**
* Adminhtml AdminNotification Severity Renderer
*
Expand All @@ -7,9 +9,16 @@
*/
namespace Magento\AdminNotification\Block\Grid\Renderer;

use Magento\AdminNotification\Model\Inbox;
use Magento\Backend\Block\Context;
use Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer;
use Magento\Framework\DataObject;
use Magento\Framework\Notification\MessageInterface;

class Severity extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
/**
* Renderer class for severity in the admin notifications grid
*/
class Severity extends AbstractRenderer
{
/**
* @var \Magento\AdminNotification\Model\Inbox
Expand All @@ -21,11 +30,8 @@ class Severity extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstra
* @param \Magento\AdminNotification\Model\Inbox $notice
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Context $context,
\Magento\AdminNotification\Model\Inbox $notice,
array $data = []
) {
public function __construct(Context $context, Inbox $notice, array $data = [])
{
parent::__construct($context, $data);
$this->_notice = $notice;
}
Expand All @@ -36,12 +42,14 @@ public function __construct(
* @param \Magento\Framework\DataObject $row
* @return string
*/
public function render(\Magento\Framework\DataObject $row)
public function render(DataObject $row)
{
$class = '';
$value = '';

switch ($row->getData($this->getColumn()->getIndex())) {
$column = $this->getColumn();
$index = $column->getIndex();
switch ($row->getData($index)) {
case MessageInterface::SEVERITY_CRITICAL:
$class = 'critical';
$value = $this->_notice->getSeverities(MessageInterface::SEVERITY_CRITICAL);
Expand All @@ -59,6 +67,7 @@ public function render(\Magento\Framework\DataObject $row)
$value = $this->_notice->getSeverities(MessageInterface::SEVERITY_NOTICE);
break;
}

return '<span class="grid-severity-' . $class . '"><span>' . $value . '</span></span>';
}
}
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);
}
}
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);
}
}
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);
}
}
Loading

0 comments on commit 5657076

Please sign in to comment.