Skip to content

Commit

Permalink
Merge branch '2.4-develop' into compare-remove-product-issue
Browse files Browse the repository at this point in the history
  • Loading branch information
eduard13 committed Apr 8, 2020
2 parents 244a46b + d69c242 commit 95a2a09
Show file tree
Hide file tree
Showing 2,064 changed files with 38,010 additions and 38,201 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="LoginAdminWithCredentialsActionGroup" deprecated="Use AdminLoginActionGroup instead">
<conditionalClick selector="{{AdminUsageNotificationSection.adminUsageDontAllowButton}}" dependentSelector="{{AdminUsageNotificationSection.adminUsageDontAllowButton}}" visible="true" stepKey="clickDontAllowButtonIfVisible" before="closeAdminNotification"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="LoginAsAdmin" deprecated="Use AdminLoginActionGroup instead">
<conditionalClick selector="{{AdminUsageNotificationSection.adminUsageDontAllowButton}}" dependentSelector="{{AdminUsageNotificationSection.adminUsageDontAllowButton}}" visible="true" stepKey="clickDontAllowButtonIfVisible" before="closeAdminNotification"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
</annotations>

<!-- Logging in Magento admin -->
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<group value="mtf_migrated"/>
</annotations>
<before>
<actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/>
</before>
<after>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Magento\Framework\Escaper;
use Magento\Framework\Url\Helper\Data;
use Magento\Framework\UrlInterface;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class ActionsTest extends TestCase
Expand All @@ -32,20 +33,20 @@ protected function setUp() : void
{
parent::setUp();

/** @var Escaper | \PHPUnit_Framework_MockObject_MockObject $escaperMock */
/** @var Escaper|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 */
/** @var UrlInterface|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 */
/** @var Context|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 */
/** @var Data|MockObject $urlHelperMock */
$urlHelperMock = $this->getMockBuilder(Data::class)->disableOriginalConstructor()->getMock();
$urlHelperMock->expects($this->once())->method('getEncodedUrl')->willReturn('http://magento.com');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Magento\Framework\DataObject;
use Magento\Framework\Escaper;
use Magento\Backend\Block\Context;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class NoticeTest extends TestCase
Expand All @@ -30,11 +31,11 @@ protected function setUp() : void
{
parent::setUp();

/** @var Escaper | \PHPUnit_Framework_MockObject_MockObject $escaperMock */
/** @var Escaper|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 */
/** @var Context|MockObject $contextMock */
$contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
$contextMock->expects($this->once())->method('getEscaper')->willReturn($escaperMock);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Magento\Backend\Block\Widget\Grid\Column;
use Magento\Framework\DataObject;
use Magento\Framework\Escaper;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class SeverityTest extends TestCase
Expand All @@ -32,18 +33,18 @@ protected function setUp() : void
{
parent::setUp();

/** @var Inbox |\PHPUnit_Framework_MockObject_MockObject $inboxMock */
/** @var Inbox|MockObject $inboxMock */
$inboxMock = $this->getMockBuilder(Inbox::class)->disableOriginalConstructor()->getMock();

/** @var Context | \PHPUnit_Framework_MockObject_MockObject $contextMock */
/** @var Context|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 */
/** @var Column|MockObject $columnMock */
$columnMock = $this->getMockBuilder(Column::class)
->disableOriginalConstructor()
->setMethods(['getIndex'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,31 @@
*/
namespace Magento\AdminNotification\Test\Unit\Block;

class ToolbarEntryTest extends \PHPUnit\Framework\TestCase
use Magento\AdminNotification\Block\ToolbarEntry;
use Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Unread;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use PHPUnit\Framework\TestCase;

class ToolbarEntryTest extends TestCase
{
/**
* Retrieve toolbar entry block instance
*
* @param int $unreadNotifications number of unread notifications
* @return \Magento\AdminNotification\Block\ToolbarEntry
* @return ToolbarEntry
*/
protected function _getBlockInstance($unreadNotifications)
{
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$objectManagerHelper = new ObjectManager($this);
// mock collection of unread notifications
$notificationList = $this->createPartialMock(
\Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Unread::class,
Unread::class,
['getSize', 'setCurPage', 'setPageSize']
);
$notificationList->expects($this->any())->method('getSize')->will($this->returnValue($unreadNotifications));

$block = $objectManagerHelper->getObject(
\Magento\AdminNotification\Block\ToolbarEntry::class,
ToolbarEntry::class,
['notificationList' => $notificationList]
);

Expand All @@ -44,25 +49,23 @@ public function testGetUnreadNotificationCount()

public function testGetLatestUnreadNotifications()
{
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$helper = new ObjectManager($this);

// 1. Create mocks
$notificationList = $this->getMockBuilder(
\Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Unread::class
)
$notificationList = $this->getMockBuilder(Unread::class)
->disableOriginalConstructor()
->getMock();

/** @var \Magento\AdminNotification\Block\ToolbarEntry $model */
/** @var ToolbarEntry $model */
$model = $helper->getObject(
\Magento\AdminNotification\Block\ToolbarEntry::class,
ToolbarEntry::class,
['notificationList' => $notificationList]
);

// 2. Set expectations
$notificationList->expects($this->atLeastOnce())
->method('setPageSize')
->with(\Magento\AdminNotification\Block\ToolbarEntry::NOTIFICATIONS_NUMBER)
->with(ToolbarEntry::NOTIFICATIONS_NUMBER)
->will($this->returnSelf());

// 3. Run tested method
Expand Down
61 changes: 37 additions & 24 deletions app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,74 +6,87 @@

namespace Magento\AdminNotification\Test\Unit\Model;

use Magento\AdminNotification\Model\Feed;
use Magento\AdminNotification\Model\Inbox;
use Magento\AdminNotification\Model\InboxFactory;
use Magento\Backend\App\ConfigInterface;
use Magento\Framework\App\CacheInterface;
use Magento\Framework\App\DeploymentConfig;
use Magento\Framework\App\ProductMetadata;
use Magento\Framework\App\State;
use Magento\Framework\Config\ConfigOptionsListConstants;
use Magento\Framework\HTTP\Adapter\Curl;
use Magento\Framework\HTTP\Adapter\CurlFactory;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use Magento\Framework\UrlInterface;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class FeedTest extends \PHPUnit\Framework\TestCase
class FeedTest extends TestCase
{
/** @var \Magento\AdminNotification\Model\Feed */
/** @var Feed */
protected $feed;

/** @var ObjectManagerHelper */
protected $objectManagerHelper;

/** @var \Magento\AdminNotification\Model\InboxFactory|\PHPUnit_Framework_MockObject_MockObject */
/** @var InboxFactory|MockObject */
protected $inboxFactory;

/** @var \Magento\AdminNotification\Model\Inbox|\PHPUnit_Framework_MockObject_MockObject */
/** @var Inbox|MockObject */
protected $inboxModel;

/** @var \Magento\Framework\HTTP\Adapter\CurlFactory|\PHPUnit_Framework_MockObject_MockObject */
/** @var CurlFactory|MockObject */
protected $curlFactory;

/** @var \Magento\Framework\HTTP\Adapter\Curl|\PHPUnit_Framework_MockObject_MockObject */
/** @var Curl|MockObject */
protected $curl;

/** @var \Magento\Backend\App\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject */
/** @var ConfigInterface|MockObject */
protected $backendConfig;

/** @var \Magento\Framework\App\CacheInterface|\PHPUnit_Framework_MockObject_MockObject */
/** @var CacheInterface|MockObject */
protected $cacheManager;

/** @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject */
/** @var State|MockObject */
protected $appState;

/** @var \Magento\Framework\App\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject */
/** @var DeploymentConfig|MockObject */
protected $deploymentConfig;

/** @var \Magento\Framework\App\ProductMetadata|\PHPUnit_Framework_MockObject_MockObject */
/** @var ProductMetadata|MockObject */
protected $productMetadata;

/** @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject */
/** @var UrlInterface|MockObject */
protected $urlBuilder;

protected function setUp()
protected function setUp(): void
{
$this->inboxFactory = $this->createPartialMock(
\Magento\AdminNotification\Model\InboxFactory::class,
InboxFactory::class,
['create']
);
$this->curlFactory = $this->createPartialMock(\Magento\Framework\HTTP\Adapter\CurlFactory::class, ['create']);
$this->curl = $this->getMockBuilder(\Magento\Framework\HTTP\Adapter\Curl::class)
$this->curlFactory = $this->createPartialMock(CurlFactory::class, ['create']);
$this->curl = $this->getMockBuilder(Curl::class)
->disableOriginalConstructor()->getMock();
$this->appState = $this->createPartialMock(\Magento\Framework\App\State::class, ['getInstallDate']);
$this->inboxModel = $this->createPartialMock(\Magento\AdminNotification\Model\Inbox::class, [
$this->appState = $this->createPartialMock(State::class, []);
$this->inboxModel = $this->createPartialMock(Inbox::class, [
'__wakeup',
'parse'
]);
$this->backendConfig = $this->createPartialMock(
\Magento\Backend\App\ConfigInterface::class,
ConfigInterface::class,
[
'getValue',
'setValue',
'isSetFlag'
]
);
$this->cacheManager = $this->createPartialMock(
\Magento\Framework\App\CacheInterface::class,
CacheInterface::class,
[
'load',
'getFrontend',
Expand All @@ -83,18 +96,18 @@ protected function setUp()
]
);

$this->deploymentConfig = $this->getMockBuilder(\Magento\Framework\App\DeploymentConfig::class)
$this->deploymentConfig = $this->getMockBuilder(DeploymentConfig::class)
->disableOriginalConstructor()->getMock();

$this->objectManagerHelper = new ObjectManagerHelper($this);

$this->productMetadata = $this->getMockBuilder(\Magento\Framework\App\ProductMetadata::class)
$this->productMetadata = $this->getMockBuilder(ProductMetadata::class)
->disableOriginalConstructor()->getMock();

$this->urlBuilder = $this->createMock(\Magento\Framework\UrlInterface::class);
$this->urlBuilder = $this->createMock(UrlInterface::class);

$this->feed = $this->objectManagerHelper->getObject(
\Magento\AdminNotification\Model\Feed::class,
Feed::class,
[
'backendConfig' => $this->backendConfig,
'cacheManager' => $this->cacheManager,
Expand Down
Loading

0 comments on commit 95a2a09

Please sign in to comment.