diff --git a/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/ActionsTest.php b/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/ActionsTest.php
index 781734186ce6b..7199d1f44222d 100644
--- a/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/ActionsTest.php
+++ b/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/ActionsTest.php
@@ -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
@@ -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');
diff --git a/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/NoticeTest.php b/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/NoticeTest.php
index 7b4b0a0f66e96..a4fb6227ecdc7 100644
--- a/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/NoticeTest.php
+++ b/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/NoticeTest.php
@@ -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
@@ -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('
Some random html
');
- /** @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);
diff --git a/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/SeverityTest.php b/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/SeverityTest.php
index 2a30be02f173b..c2e109cff130e 100644
--- a/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/SeverityTest.php
+++ b/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/SeverityTest.php
@@ -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
@@ -32,10 +33,10 @@ 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);
@@ -43,7 +44,7 @@ protected function setUp() : void
public function testShouldRenderSeverity() : void
{
- /** @var Column | \PHPUnit_Framework_MockObject_MockObject $columnMock */
+ /** @var Column|MockObject $columnMock */
$columnMock = $this->getMockBuilder(Column::class)
->disableOriginalConstructor()
->setMethods(['getIndex'])
diff --git a/app/code/Magento/AdminNotification/Test/Unit/Block/ToolbarEntryTest.php b/app/code/Magento/AdminNotification/Test/Unit/Block/ToolbarEntryTest.php
index 2afa9eced1d95..eb45a9af6beb2 100644
--- a/app/code/Magento/AdminNotification/Test/Unit/Block/ToolbarEntryTest.php
+++ b/app/code/Magento/AdminNotification/Test/Unit/Block/ToolbarEntryTest.php
@@ -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]
);
@@ -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
diff --git a/app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php b/app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php
index 2b3eb6247e899..604d33ccf9092 100644
--- a/app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php
+++ b/app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php
@@ -6,66 +6,79 @@
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',
@@ -73,7 +86,7 @@ protected function setUp()
]
);
$this->cacheManager = $this->createPartialMock(
- \Magento\Framework\App\CacheInterface::class,
+ CacheInterface::class,
[
'load',
'getFrontend',
@@ -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,
diff --git a/app/code/Magento/AdminNotification/Test/Unit/Model/NotificationServiceTest.php b/app/code/Magento/AdminNotification/Test/Unit/Model/NotificationServiceTest.php
index f8485847ccae2..68070add6cd98 100644
--- a/app/code/Magento/AdminNotification/Test/Unit/Model/NotificationServiceTest.php
+++ b/app/code/Magento/AdminNotification/Test/Unit/Model/NotificationServiceTest.php
@@ -9,27 +9,33 @@
*/
namespace Magento\AdminNotification\Test\Unit\Model;
-class NotificationServiceTest extends \PHPUnit\Framework\TestCase
+use Magento\AdminNotification\Model\Inbox;
+use Magento\AdminNotification\Model\InboxFactory;
+use Magento\AdminNotification\Model\NotificationService;
+use Magento\Framework\Exception\LocalizedException;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class NotificationServiceTest extends TestCase
{
/**
* Retrieve instance of notification service model
*
* @param $notificationId
- * @return \Magento\AdminNotification\Model\NotificationService
+ * @return NotificationService
*/
protected function _getServiceInstanceForMarkAsReadTest($notificationId)
{
/**
- * @var
- * $notificationFactory \PHPUnit_Framework_MockObject_MockObject|\Magento\AdminNotification\Model\InboxFactory
+ * @var $notificationFactory MockObject|InboxFactory
*/
$notificationFactory = $this->createPartialMock(
- \Magento\AdminNotification\Model\InboxFactory::class,
+ InboxFactory::class,
['create']
);
$notification = $this->createPartialMock(
- \Magento\AdminNotification\Model\Inbox::class,
- ['load', 'getId', 'save', 'setIsRead', '__sleep', '__wakeup']
+ Inbox::class,
+ ['load', 'getId', 'save', 'setData', '__sleep', '__wakeup']
);
$notification->expects($this->once())->method('load')->with($notificationId)->will($this->returnSelf());
$notification->expects($this->once())->method('getId')->will($this->returnValue($notificationId));
@@ -37,11 +43,12 @@ protected function _getServiceInstanceForMarkAsReadTest($notificationId)
// when notification Id is valid, add additional expectations
if ($notificationId) {
$notification->expects($this->once())->method('save')->will($this->returnSelf());
- $notification->expects($this->once())->method('setIsRead')->with(1)->will($this->returnSelf());
+ $notification->expects($this->once())->method('setData')
+ ->with('is_read', 1)->will($this->returnSelf());
}
$notificationFactory->expects($this->once())->method('create')->will($this->returnValue($notification));
- return new \Magento\AdminNotification\Model\NotificationService($notificationFactory);
+ return new NotificationService($notificationFactory);
}
public function testMarkAsRead()
@@ -51,12 +58,11 @@ public function testMarkAsRead()
$service->markAsRead($notificationId);
}
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage Wrong notification ID specified.
- */
public function testMarkAsReadThrowsExceptionWhenNotificationIdIsInvalid()
{
+ $this->expectException(LocalizedException::class);
+ $this->expectExceptionMessage('Wrong notification ID specified.');
+
$notificationId = null;
$service = $this->_getServiceInstanceForMarkAsReadTest($notificationId);
$service->markAsRead($notificationId);
diff --git a/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/CacheOutdatedTest.php b/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/CacheOutdatedTest.php
index f49911c3e7a93..381e3fff3d080 100644
--- a/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/CacheOutdatedTest.php
+++ b/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/CacheOutdatedTest.php
@@ -5,42 +5,50 @@
*/
namespace Magento\AdminNotification\Test\Unit\Model\System\Message;
-class CacheOutdatedTest extends \PHPUnit\Framework\TestCase
+use Magento\AdminNotification\Model\System\Message\CacheOutdated;
+use Magento\Framework\App\Cache\TypeListInterface;
+use Magento\Framework\AuthorizationInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\UrlInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class CacheOutdatedTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_authorizationMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_cacheTypeListMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_urlInterfaceMock;
/**
- * @var \Magento\AdminNotification\Model\System\Message\CacheOutdated
+ * @var CacheOutdated
*/
protected $_messageModel;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_authorizationMock = $this->createMock(\Magento\Framework\AuthorizationInterface::class);
- $this->_urlInterfaceMock = $this->createMock(\Magento\Framework\UrlInterface::class);
- $this->_cacheTypeListMock = $this->createMock(\Magento\Framework\App\Cache\TypeListInterface::class);
+ $this->_authorizationMock = $this->createMock(AuthorizationInterface::class);
+ $this->_urlInterfaceMock = $this->createMock(UrlInterface::class);
+ $this->_cacheTypeListMock = $this->createMock(TypeListInterface::class);
- $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManagerHelper = new ObjectManager($this);
$arguments = [
'authorization' => $this->_authorizationMock,
'urlBuilder' => $this->_urlInterfaceMock,
'cacheTypeList' => $this->_cacheTypeListMock,
];
$this->_messageModel = $objectManagerHelper->getObject(
- \Magento\AdminNotification\Model\System\Message\CacheOutdated::class,
+ CacheOutdated::class,
$arguments
);
}
diff --git a/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/Media/Synchronization/ErrorTest.php b/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/Media/Synchronization/ErrorTest.php
index b490efd8e9683..91595732bdb58 100644
--- a/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/Media/Synchronization/ErrorTest.php
+++ b/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/Media/Synchronization/ErrorTest.php
@@ -5,37 +5,44 @@
*/
namespace Magento\AdminNotification\Test\Unit\Model\System\Message\Media\Synchronization;
-class ErrorTest extends \PHPUnit\Framework\TestCase
+use Magento\AdminNotification\Model\System\Message\Media\Synchronization\Error;
+use Magento\Framework\Notification\MessageInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\MediaStorage\Model\File\Storage\Flag;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class ErrorTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_syncFlagMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_fileStorage;
/**
- * @var \Magento\AdminNotification\Model\System\Message\Media\Synchronization\Error
+ * @var Error
*/
protected $_model;
- protected function setUp()
+ protected function setUp(): void
{
$this->_syncFlagMock = $this->createPartialMock(
- \Magento\MediaStorage\Model\File\Storage\Flag::class,
- ['setState', 'save', 'getFlagData']
+ Flag::class,
+ ['save', 'getFlagData']
);
- $this->_fileStorage = $this->createMock(\Magento\MediaStorage\Model\File\Storage\Flag::class);
+ $this->_fileStorage = $this->createMock(Flag::class);
$this->_fileStorage->expects($this->any())->method('loadSelf')->will($this->returnValue($this->_syncFlagMock));
- $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManagerHelper = new ObjectManager($this);
$arguments = ['fileStorage' => $this->_fileStorage];
$this->_model = $objectManagerHelper->getObject(
- \Magento\AdminNotification\Model\System\Message\Media\Synchronization\Error::class,
+ Error::class,
$arguments
);
}
@@ -43,7 +50,6 @@ protected function setUp()
public function testGetText()
{
$messageText = 'We were unable to synchronize one or more media files.';
-
$this->assertContains($messageText, (string)$this->_model->getText());
}
@@ -55,15 +61,14 @@ public function testGetText()
public function testIsDisplayed($expectedFirstRun, $data)
{
$arguments = ['fileStorage' => $this->_fileStorage];
- $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManagerHelper = new ObjectManager($this);
// create new instance to ensure that it hasn't been displayed yet (var $this->_isDisplayed is unset)
- /** @var $model \Magento\AdminNotification\Model\System\Message\Media\Synchronization\Error */
+ /** @var $model Error */
$model = $objectManagerHelper->getObject(
- \Magento\AdminNotification\Model\System\Message\Media\Synchronization\Error::class,
+ Error::class,
$arguments
);
- $this->_syncFlagMock->expects($this->any())->method('setState');
$this->_syncFlagMock->expects($this->any())->method('save');
$this->_syncFlagMock->expects($this->any())->method('getFlagData')->will($this->returnValue($data));
//check first call
@@ -92,7 +97,7 @@ public function testGetIdentity()
public function testGetSeverity()
{
- $severity = \Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR;
+ $severity = MessageInterface::SEVERITY_MAJOR;
$this->assertEquals($severity, $this->_model->getSeverity());
}
}
diff --git a/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/SecurityTest.php b/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/SecurityTest.php
index c6f61fee862ba..a0e09728cbacf 100644
--- a/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/SecurityTest.php
+++ b/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/SecurityTest.php
@@ -5,51 +5,55 @@
*/
namespace Magento\AdminNotification\Test\Unit\Model\System\Message;
-class SecurityTest extends \PHPUnit\Framework\TestCase
-{
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $_cacheMock;
+use Magento\AdminNotification\Model\System\Message\Security;
+use Magento\Framework\App\CacheInterface;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\HTTP\Adapter\Curl;
+use Magento\Framework\HTTP\Adapter\CurlFactory;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+class SecurityTest extends TestCase
+{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var CacheInterface|MockObject
*/
- protected $_scopeConfigMock;
+ private $cacheMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
- protected $_configMock;
+ private $scopeConfigMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var CurlFactory|MockObject
*/
- protected $_curlFactoryMock;
+ private $curlFactoryMock;
/**
- * @var \Magento\AdminNotification\Model\System\Message\Security
+ * @var Security
*/
- protected $_messageModel;
+ private $messageModel;
- protected function setUp()
+ protected function setUp(): void
{
//Prepare objects for constructor
- $this->_cacheMock = $this->createMock(\Magento\Framework\App\CacheInterface::class);
- $this->_scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
- $this->_curlFactoryMock = $this->createPartialMock(
- \Magento\Framework\HTTP\Adapter\CurlFactory::class,
+ $this->cacheMock = $this->createMock(CacheInterface::class);
+ $this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class);
+ $this->curlFactoryMock = $this->createPartialMock(
+ CurlFactory::class,
['create']
);
- $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManagerHelper = new ObjectManager($this);
$arguments = [
- 'cache' => $this->_cacheMock,
- 'scopeConfig' => $this->_scopeConfigMock,
- 'curlFactory' => $this->_curlFactoryMock,
+ 'cache' => $this->cacheMock,
+ 'scopeConfig' => $this->scopeConfigMock,
+ 'curlFactory' => $this->curlFactoryMock,
];
- $this->_messageModel = $objectManagerHelper->getObject(
- \Magento\AdminNotification\Model\System\Message\Security::class,
+ $this->messageModel = $objectManagerHelper->getObject(
+ Security::class,
$arguments
);
}
@@ -64,16 +68,16 @@ protected function setUp()
*/
public function testIsDisplayed($expectedResult, $cached, $response)
{
- $this->_cacheMock->expects($this->any())->method('load')->will($this->returnValue($cached));
- $this->_cacheMock->expects($this->any())->method('save')->will($this->returnValue(null));
+ $this->cacheMock->expects($this->any())->method('load')->will($this->returnValue($cached));
+ $this->cacheMock->expects($this->any())->method('save')->will($this->returnValue(null));
- $httpAdapterMock = $this->createMock(\Magento\Framework\HTTP\Adapter\Curl::class);
+ $httpAdapterMock = $this->createMock(Curl::class);
$httpAdapterMock->expects($this->any())->method('read')->will($this->returnValue($response));
- $this->_curlFactoryMock->expects($this->any())->method('create')->will($this->returnValue($httpAdapterMock));
+ $this->curlFactoryMock->expects($this->any())->method('create')->will($this->returnValue($httpAdapterMock));
- $this->_scopeConfigMock->expects($this->any())->method('getValue')->will($this->returnValue(null));
+ $this->scopeConfigMock->expects($this->any())->method('getValue')->will($this->returnValue(null));
- $this->assertEquals($expectedResult, $this->_messageModel->isDisplayed());
+ $this->assertEquals($expectedResult, $this->messageModel->isDisplayed());
}
/**
@@ -92,6 +96,6 @@ public function testGetText()
{
$messageStart = 'Your web server is set up incorrectly';
- $this->assertStringStartsWith($messageStart, (string)$this->_messageModel->getText());
+ $this->assertStringStartsWith($messageStart, (string)$this->messageModel->getText());
}
}
diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleProductShownInCategoryListAndGridTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleProductShownInCategoryListAndGridTest.xml
index 65b20ca1dd7c1..6e4835654e4c1 100644
--- a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleProductShownInCategoryListAndGridTest.xml
+++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleProductShownInCategoryListAndGridTest.xml
@@ -79,8 +79,7 @@
-
-
+
diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontCustomerSearchBundleProductsByKeywordsTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontCustomerSearchBundleProductsByKeywordsTest.xml
index ae9d01a50f46e..de6718dfd9f31 100644
--- a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontCustomerSearchBundleProductsByKeywordsTest.xml
+++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontCustomerSearchBundleProductsByKeywordsTest.xml
@@ -48,7 +48,7 @@
-
+
diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontGoToDetailsPageWhenAddingToCartTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontGoToDetailsPageWhenAddingToCartTest.xml
index 93554917b6783..8a0334f01dab2 100644
--- a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontGoToDetailsPageWhenAddingToCartTest.xml
+++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontGoToDetailsPageWhenAddingToCartTest.xml
@@ -66,8 +66,7 @@
-
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckCustomAttributeValuesAfterProductSaveTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckCustomAttributeValuesAfterProductSaveTest.xml
index 51d9e26ebd2cb..b3f7f0e6eb42a 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckCustomAttributeValuesAfterProductSaveTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckCustomAttributeValuesAfterProductSaveTest.xml
@@ -75,8 +75,7 @@
-
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateRootCategoryAndSubcategoriesTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateRootCategoryAndSubcategoriesTest.xml
index 9a0ff1d02c153..b959b961ef1ea 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateRootCategoryAndSubcategoriesTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateRootCategoryAndSubcategoriesTest.xml
@@ -72,8 +72,7 @@
-
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithTierPriceTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithTierPriceTest.xml
index d8eaed92de4cf..faae6a371db24 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithTierPriceTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithTierPriceTest.xml
@@ -102,8 +102,7 @@
-
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveAnchoredCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveAnchoredCategoryTest.xml
index 72092af331974..d302dad52d6e6 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveAnchoredCategoryTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveAnchoredCategoryTest.xml
@@ -55,8 +55,7 @@
-
-
+
@@ -97,8 +96,7 @@
-
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveProductBetweenCategoriesTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveProductBetweenCategoriesTest.xml
index 50c7fa38d881e..afac68ae2b1b7 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveProductBetweenCategoriesTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveProductBetweenCategoriesTest.xml
@@ -134,8 +134,7 @@
-
-
+
@@ -192,8 +191,7 @@
-
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductCustomURLKeyPreservedWhenAssignedToCategoryWithoutCustomURLKeyTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductCustomURLKeyPreservedWhenAssignedToCategoryWithoutCustomURLKeyTest.xml
index ee34d8286fe32..6d197d19eb924 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductCustomURLKeyPreservedWhenAssignedToCategoryWithoutCustomURLKeyTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductCustomURLKeyPreservedWhenAssignedToCategoryWithoutCustomURLKeyTest.xml
@@ -83,7 +83,7 @@
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/DeleteCategoriesTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/DeleteCategoriesTest.xml
index f70979285446a..b0a3d02f31846 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/DeleteCategoriesTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/DeleteCategoriesTest.xml
@@ -89,8 +89,7 @@
-
-
+
@@ -132,8 +131,7 @@
-
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest/EndToEndB2CGuestUserMysqlTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest/EndToEndB2CGuestUserMysqlTest.xml
index ee98e6e152d91..f334a6c5a66ce 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest/EndToEndB2CGuestUserMysqlTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest/EndToEndB2CGuestUserMysqlTest.xml
@@ -58,8 +58,7 @@
-
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest/EndToEndB2CGuestUserTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest/EndToEndB2CGuestUserTest.xml
index 93b08e3c468de..94b0deaf6ce1c 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest/EndToEndB2CGuestUserTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest/EndToEndB2CGuestUserTest.xml
@@ -61,8 +61,7 @@
-
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreLevelTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreLevelTest.xml
index 16f3c6ae25436..ff7c6c58a219c 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreLevelTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreLevelTest.xml
@@ -100,8 +100,7 @@
-
-
+
@@ -116,8 +115,7 @@
-
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml
index 9fbdde86bb5ee..284b2f6eeb16a 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml
@@ -94,9 +94,7 @@
-
-
-
+
@@ -116,9 +114,7 @@
-
-
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCategoryHighlightedAndProductDisplayedTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCategoryHighlightedAndProductDisplayedTest.xml
index b6ba5245645eb..a5dcc8fa28c6f 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCategoryHighlightedAndProductDisplayedTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCategoryHighlightedAndProductDisplayedTest.xml
@@ -51,8 +51,7 @@
-
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontForthLevelCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontForthLevelCategoryTest.xml
index bb46f8010eaa8..74264149cf1cb 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontForthLevelCategoryTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontForthLevelCategoryTest.xml
@@ -35,7 +35,7 @@
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductCustomOptionsDifferentStoreViewsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductCustomOptionsDifferentStoreViewsTest.xml
index 5659f053613c2..95af6e299662b 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductCustomOptionsDifferentStoreViewsTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductCustomOptionsDifferentStoreViewsTest.xml
@@ -209,7 +209,7 @@
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/VerifyChildCategoriesShouldNotIncludeInMenuTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/VerifyChildCategoriesShouldNotIncludeInMenuTest.xml
index 94b16ac8bddce..66d811ced9ac6 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/VerifyChildCategoriesShouldNotIncludeInMenuTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/VerifyChildCategoriesShouldNotIncludeInMenuTest.xml
@@ -40,8 +40,7 @@
-
-
+
@@ -53,8 +52,7 @@
-
-
+
@@ -67,8 +65,7 @@
-
-
+
@@ -80,8 +77,7 @@
-
-
+
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdminCreateSearchTermEntityTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdminCreateSearchTermEntityTest.xml
index 7ac06c0342229..6361c076ce177 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdminCreateSearchTermEntityTest.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdminCreateSearchTermEntityTest.xml
@@ -47,8 +47,7 @@
-
-
+
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontUpdateSearchTermEntityTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontUpdateSearchTermEntityTest.xml
index 3c0c7cf53d0a1..8a0d91ae05b34 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontUpdateSearchTermEntityTest.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontUpdateSearchTermEntityTest.xml
@@ -28,8 +28,7 @@
-
-
+
@@ -71,8 +70,7 @@
-
-
+
diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/RewriteStoreLevelUrlKeyOfChildCategoryTest.xml b/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/RewriteStoreLevelUrlKeyOfChildCategoryTest.xml
index 8764555f94357..9598c0a81ce26 100644
--- a/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/RewriteStoreLevelUrlKeyOfChildCategoryTest.xml
+++ b/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/RewriteStoreLevelUrlKeyOfChildCategoryTest.xml
@@ -46,8 +46,7 @@
-
-
+
diff --git a/app/code/Magento/Checkout/Controller/Sidebar/RemoveItem.php b/app/code/Magento/Checkout/Controller/Sidebar/RemoveItem.php
index f589e702de950..3a17f4f718019 100644
--- a/app/code/Magento/Checkout/Controller/Sidebar/RemoveItem.php
+++ b/app/code/Magento/Checkout/Controller/Sidebar/RemoveItem.php
@@ -3,104 +3,102 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Checkout\Controller\Sidebar;
-use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
+use Exception;
+use Magento\Checkout\Model\Sidebar;
+use Magento\Framework\App\Action\HttpPostActionInterface;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\Controller\Result\JsonFactory as ResultJsonFactory;
+use Magento\Framework\Controller\Result\RedirectFactory as ResultRedirectFactory;
+use Magento\Framework\Data\Form\FormKey\Validator;
+use Magento\Framework\Exception\LocalizedException;
+use Psr\Log\LoggerInterface;
-class RemoveItem extends \Magento\Framework\App\Action\Action implements HttpPostActionInterface
+class RemoveItem implements HttpPostActionInterface
{
/**
- * @var \Magento\Checkout\Model\Sidebar
+ * @var RequestInterface
*/
- protected $sidebar;
+ private $request;
/**
- * @var \Psr\Log\LoggerInterface
+ * @var ResultJsonFactory
*/
- protected $logger;
+ private $resultJsonFactory;
/**
- * @var \Magento\Framework\Json\Helper\Data
+ * @var ResultRedirectFactory
*/
- protected $jsonHelper;
+ private $resultRedirectFactory;
/**
- * @var \Magento\Framework\View\Result\PageFactory
+ * @var Sidebar
*/
- protected $resultPageFactory;
+ protected $sidebar;
/**
- * @var \Magento\Framework\Data\Form\FormKey\Validator
+ * @var Validator
*/
private $formKeyValidator;
/**
- * @param \Magento\Framework\App\Action\Context $context
- * @param \Magento\Checkout\Model\Sidebar $sidebar
- * @param \Psr\Log\LoggerInterface $logger
- * @param \Magento\Framework\Json\Helper\Data $jsonHelper
- * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
+ * @var LoggerInterface
+ */
+ protected $logger;
+
+ /**
+ * @param RequestInterface $request
+ * @param ResultJsonFactory $resultJsonFactory
+ * @param ResultRedirectFactory $resultRedirectFactory
+ * @param Sidebar $sidebar
+ * @param Validator $formKeyValidator
+ * @param LoggerInterface $logger
*/
public function __construct(
- \Magento\Framework\App\Action\Context $context,
- \Magento\Checkout\Model\Sidebar $sidebar,
- \Psr\Log\LoggerInterface $logger,
- \Magento\Framework\Json\Helper\Data $jsonHelper,
- \Magento\Framework\View\Result\PageFactory $resultPageFactory
+ RequestInterface $request,
+ ResultJsonFactory $resultJsonFactory,
+ ResultRedirectFactory $resultRedirectFactory,
+ Sidebar $sidebar,
+ Validator $formKeyValidator,
+ LoggerInterface $logger
) {
+ $this->request = $request;
+ $this->resultJsonFactory = $resultJsonFactory;
+ $this->resultRedirectFactory = $resultRedirectFactory;
$this->sidebar = $sidebar;
+ $this->formKeyValidator = $formKeyValidator;
$this->logger = $logger;
- $this->jsonHelper = $jsonHelper;
- $this->resultPageFactory = $resultPageFactory;
- parent::__construct($context);
}
/**
- * @return $this
+ * @inheritDoc
*/
public function execute()
{
- if (!$this->getFormKeyValidator()->validate($this->getRequest())) {
- return $this->resultRedirectFactory->create()->setPath('*/cart/');
+ if (!$this->formKeyValidator->validate($this->request)) {
+ return $this->resultRedirectFactory->create()
+ ->setPath('*/cart/');
}
- $itemId = (int)$this->getRequest()->getParam('item_id');
+
+ $itemId = (int)$this->request->getParam('item_id');
+ $error = '';
+
try {
$this->sidebar->checkQuoteItem($itemId);
$this->sidebar->removeQuoteItem($itemId);
- return $this->jsonResponse();
- } catch (\Magento\Framework\Exception\LocalizedException $e) {
- return $this->jsonResponse($e->getMessage());
- } catch (\Exception $e) {
+ } catch (LocalizedException $e) {
+ $error = $e->getMessage();
+ } catch (Exception $e) {
$this->logger->critical($e);
- return $this->jsonResponse($e->getMessage());
+ $error = $e->getMessage();
}
- }
-
- /**
- * Compile JSON response
- *
- * @param string $error
- * @return \Magento\Framework\App\Response\Http
- */
- protected function jsonResponse($error = '')
- {
- $response = $this->sidebar->getResponseData($error);
- return $this->getResponse()->representJson(
- $this->jsonHelper->jsonEncode($response)
- );
- }
+ $resultJson = $this->resultJsonFactory->create();
+ $resultJson->setData($this->sidebar->getResponseData($error));
- /**
- * @return \Magento\Framework\Data\Form\FormKey\Validator
- * @deprecated 100.0.9
- */
- private function getFormKeyValidator()
- {
- if (!$this->formKeyValidator) {
- $this->formKeyValidator = \Magento\Framework\App\ObjectManager::getInstance()
- ->get(\Magento\Framework\Data\Form\FormKey\Validator::class);
- }
- return $this->formKeyValidator;
+ return $resultJson;
}
}
diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml
index 3a9bec5cdfcf3..741fde91f851e 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml
@@ -135,8 +135,7 @@
-
-
+
@@ -168,8 +167,7 @@
-
-
+
diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Sidebar/RemoveItemTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Sidebar/RemoveItemTest.php
index 7653a51b2f9b7..c7dacbb1fe307 100644
--- a/app/code/Magento/Checkout/Test/Unit/Controller/Sidebar/RemoveItemTest.php
+++ b/app/code/Magento/Checkout/Test/Unit/Controller/Sidebar/RemoveItemTest.php
@@ -3,88 +3,105 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Checkout\Test\Unit\Controller\Sidebar;
+use Magento\Checkout\Controller\Sidebar\RemoveItem;
+use Magento\Checkout\Model\Sidebar;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\Controller\Result\Json as ResultJson;
+use Magento\Framework\Controller\Result\JsonFactory as ResultJsonFactory;
+use Magento\Framework\Controller\Result\Redirect as ResultRedirect;
+use Magento\Framework\Controller\Result\RedirectFactory as ResultRedirectFactory;
+use Magento\Framework\Data\Form\FormKey\Validator;
use Magento\Framework\Exception\LocalizedException;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+use Psr\Log\LoggerInterface;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class RemoveItemTest extends \PHPUnit\Framework\TestCase
+class RemoveItemTest extends TestCase
{
- /** @var \Magento\Checkout\Controller\Sidebar\RemoveItem */
- protected $removeItem;
-
- /** @var ObjectManagerHelper */
- protected $objectManagerHelper;
-
- /** @var \Magento\Checkout\Model\Sidebar|\PHPUnit_Framework_MockObject_MockObject */
- protected $sidebarMock;
+ /**
+ * @var RemoveItem
+ */
+ private $action;
- /** @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject */
- protected $loggerMock;
+ /**
+ * @var RequestInterface|MockObject
+ */
+ private $requestMock;
- /** @var \Magento\Framework\Json\Helper\Data|\PHPUnit_Framework_MockObject_MockObject */
- protected $jsonHelperMock;
+ /**
+ * @var ResultJsonFactory|MockObject
+ */
+ private $resultJsonFactoryMock;
- /** @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */
- protected $requestMock;
+ /**
+ * @var ResultRedirectFactory|MockObject
+ */
+ private $resultRedirectFactoryMock;
- /** @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject */
- protected $responseMock;
+ /**
+ * @var Sidebar|MockObject
+ */
+ private $sidebarMock;
- /** @var \Magento\Framework\View\Result\PageFactory|\PHPUnit_Framework_MockObject_MockObject */
- protected $resultPageFactoryMock;
+ /**
+ * @var Validator|MockObject
+ */
+ private $formKeyValidatorMock;
/**
- * @var \Magento\Framework\Controller\Result\RedirectFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var LoggerInterface|MockObject
*/
- private $resultRedirectFactory;
+ private $loggerMock;
protected function setUp()
{
- $this->sidebarMock = $this->createMock(\Magento\Checkout\Model\Sidebar::class);
- $this->loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class);
- $this->jsonHelperMock = $this->createMock(\Magento\Framework\Json\Helper\Data::class);
- $this->requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class);
- $this->responseMock = $this->getMockForAbstractClass(
- \Magento\Framework\App\ResponseInterface::class,
- [],
- '',
- false,
- true,
- true,
- ['representJson']
+ $this->requestMock = $this->createMock(RequestInterface::class);
+ $this->resultJsonFactoryMock = $this->createPartialMock(
+ ResultJsonFactory::class,
+ ['create']
);
- $this->resultPageFactoryMock = $this->createMock(\Magento\Framework\View\Result\PageFactory::class);
- $this->resultRedirectFactory = $this->createPartialMock(
- \Magento\Framework\Controller\Result\RedirectFactory::class,
+ $this->resultRedirectFactoryMock = $this->createPartialMock(
+ ResultRedirectFactory::class,
['create']
);
+ $this->sidebarMock = $this->createMock(Sidebar::class);
+ $this->formKeyValidatorMock = $this->createMock(Validator::class);
+ $this->loggerMock = $this->createMock(LoggerInterface::class);
- $this->objectManagerHelper = new ObjectManagerHelper($this);
- $this->removeItem = $this->objectManagerHelper->getObject(
- \Magento\Checkout\Controller\Sidebar\RemoveItem::class,
+ $objectManager = new ObjectManager($this);
+ $this->action = $objectManager->getObject(
+ RemoveItem::class,
[
- 'sidebar' => $this->sidebarMock,
- 'logger' => $this->loggerMock,
- 'jsonHelper' => $this->jsonHelperMock,
'request' => $this->requestMock,
- 'response' => $this->responseMock,
- 'resultPageFactory' => $this->resultPageFactoryMock,
- 'resultRedirectFactory' => $this->resultRedirectFactory
-
+ 'resultJsonFactory' => $this->resultJsonFactoryMock,
+ 'resultRedirectFactory' => $this->resultRedirectFactoryMock,
+ 'sidebar' => $this->sidebarMock,
+ 'formKeyValidator' => $this->formKeyValidatorMock,
+ 'logger' => $this->loggerMock
]
);
- $formKeyValidatorMock = $this->createMock(\Magento\Framework\Data\Form\FormKey\Validator::class);
- $this->setPropertyValue($this->removeItem, 'formKeyValidator', $formKeyValidatorMock);
}
public function testExecute()
{
- $this->getPropertyValue($this->removeItem, 'formKeyValidator')
- ->expects($this->once())
+ $responseData = [
+ 'cleanup' => true,
+ 'data' => [
+ 'summary_qty' => 0,
+ 'summary_text' => __(' items'),
+ 'subtotal' => 0,
+ ],
+ ];
+
+ $this->formKeyValidatorMock->expects($this->once())
->method('validate')
->with($this->requestMock)
->willReturn(true);
@@ -101,46 +118,33 @@ public function testExecute()
->method('removeQuoteItem')
->with(1)
->willReturnSelf();
+
$this->sidebarMock->expects($this->once())
->method('getResponseData')
->with('')
- ->willReturn(
- [
- 'cleanup' => true,
- 'data' => [
- 'summary_qty' => 0,
- 'summary_text' => __(' items'),
- 'subtotal' => 0,
- ],
- ]
- );
-
- $this->jsonHelperMock->expects($this->once())
- ->method('jsonEncode')
- ->with(
- [
- 'cleanup' => true,
- 'data' => [
- 'summary_qty' => 0,
- 'summary_text' => __(' items'),
- 'subtotal' => 0,
- ],
- ]
- )
- ->willReturn('json encoded');
-
- $this->responseMock->expects($this->once())
- ->method('representJson')
- ->with('json encoded')
- ->willReturn('json represented');
-
- $this->assertEquals('json represented', $this->removeItem->execute());
+ ->willReturn($responseData);
+
+ $resultJson = $this->createMock(ResultJson::class);
+ $resultJson->expects($this->once())
+ ->method('setData')
+ ->with($responseData)
+ ->willReturnSelf();
+ $this->resultJsonFactoryMock->expects($this->once())
+ ->method('create')
+ ->willReturn($resultJson);
+
+ $this->assertEquals($resultJson, $this->action->execute());
}
public function testExecuteWithLocalizedException()
{
- $this->getPropertyValue($this->removeItem, 'formKeyValidator')
- ->expects($this->once())
+ $errorMessage = 'Error message!';
+ $responseData = [
+ 'success' => false,
+ 'error_message' => $errorMessage
+ ];
+
+ $this->formKeyValidatorMock->expects($this->once())
->method('validate')
->with($this->requestMock)
->willReturn(true);
@@ -152,40 +156,34 @@ public function testExecuteWithLocalizedException()
$this->sidebarMock->expects($this->once())
->method('checkQuoteItem')
->with(1)
- ->willThrowException(new LocalizedException(__('Error message!')));
+ ->willThrowException(new LocalizedException(__($errorMessage)));
$this->sidebarMock->expects($this->once())
->method('getResponseData')
- ->with('Error message!')
- ->willReturn(
- [
- 'success' => false,
- 'error_message' => 'Error message!',
- ]
- );
-
- $this->jsonHelperMock->expects($this->once())
- ->method('jsonEncode')
- ->with(
- [
- 'success' => false,
- 'error_message' => 'Error message!',
- ]
- )
- ->willReturn('json encoded');
-
- $this->responseMock->expects($this->once())
- ->method('representJson')
- ->with('json encoded')
- ->willReturn('json represented');
-
- $this->assertEquals('json represented', $this->removeItem->execute());
+ ->with($errorMessage)
+ ->willReturn($responseData);
+
+ $resultJson = $this->createMock(ResultJson::class);
+ $resultJson->expects($this->once())
+ ->method('setData')
+ ->with($responseData)
+ ->willReturnSelf();
+ $this->resultJsonFactoryMock->expects($this->once())
+ ->method('create')
+ ->willReturn($resultJson);
+
+ $this->assertEquals($resultJson, $this->action->execute());
}
public function testExecuteWithException()
{
- $this->getPropertyValue($this->removeItem, 'formKeyValidator')
- ->expects($this->once())
+ $errorMessage = 'Error message!';
+ $responseData = [
+ 'success' => false,
+ 'error_message' => $errorMessage
+ ];
+
+ $this->formKeyValidatorMock->expects($this->once())
->method('validate')
->with($this->requestMock)
->willReturn(true);
@@ -194,7 +192,7 @@ public function testExecuteWithException()
->with('item_id', null)
->willReturn('1');
- $exception = new \Exception('Error message!');
+ $exception = new \Exception($errorMessage);
$this->sidebarMock->expects($this->once())
->method('checkQuoteItem')
@@ -208,77 +206,36 @@ public function testExecuteWithException()
$this->sidebarMock->expects($this->once())
->method('getResponseData')
- ->with('Error message!')
- ->willReturn(
- [
- 'success' => false,
- 'error_message' => 'Error message!',
- ]
- );
-
- $this->jsonHelperMock->expects($this->once())
- ->method('jsonEncode')
- ->with(
- [
- 'success' => false,
- 'error_message' => 'Error message!',
- ]
- )
- ->willReturn('json encoded');
-
- $this->responseMock->expects($this->once())
- ->method('representJson')
- ->with('json encoded')
- ->willReturn('json represented');
-
- $this->assertEquals('json represented', $this->removeItem->execute());
+ ->with($errorMessage)
+ ->willReturn($responseData);
+
+ $resultJson = $this->createMock(ResultJson::class);
+ $resultJson->expects($this->once())
+ ->method('setData')
+ ->with($responseData)
+ ->willReturnSelf();
+ $this->resultJsonFactoryMock->expects($this->once())
+ ->method('create')
+ ->willReturn($resultJson);
+
+ $this->assertEquals($resultJson, $this->action->execute());
}
public function testExecuteWhenFormKeyValidationFailed()
{
- $resultRedirect = $this->createMock(\Magento\Framework\Controller\Result\Redirect::class);
- $resultRedirect->expects($this->once())->method('setPath')->with('*/cart/')->willReturnSelf();
- $this->resultRedirectFactory->expects($this->once())->method('create')->willReturn($resultRedirect);
- $this->getPropertyValue($this->removeItem, 'formKeyValidator')
- ->expects($this->once())
+ $resultRedirect = $this->createMock(ResultRedirect::class);
+ $resultRedirect->expects($this->once())
+ ->method('setPath')
+ ->with('*/cart/')
+ ->willReturnSelf();
+ $this->resultRedirectFactoryMock->expects($this->once())
+ ->method('create')
+ ->willReturn($resultRedirect);
+ $this->formKeyValidatorMock->expects($this->once())
->method('validate')
->with($this->requestMock)
->willReturn(false);
- $this->assertEquals($resultRedirect, $this->removeItem->execute());
- }
-
- /**
- * Get any object property value.
- *
- * @param $object
- * @param $property
- * @return mixed
- * @deprecated
- */
- protected function getPropertyValue($object, $property)
- {
- $reflection = new \ReflectionClass(get_class($object));
- $reflectionProperty = $reflection->getProperty($property);
- $reflectionProperty->setAccessible(true);
-
- return $reflectionProperty->getValue($object);
- }
-
- /**
- * Set object property value.
- *
- * @param $object
- * @param $property
- * @param $value
- * @deprecated
- */
- protected function setPropertyValue(&$object, $property, $value)
- {
- $reflection = new \ReflectionClass(get_class($object));
- $reflectionProperty = $reflection->getProperty($property);
- $reflectionProperty->setAccessible(true);
- $reflectionProperty->setValue($object, $value);
- return $object;
+ $this->assertEquals($resultRedirect, $this->action->execute());
}
}
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsAssignedToCategoryTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsAssignedToCategoryTest.xml
index f57fc81294cbc..868690e19f6ba 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsAssignedToCategoryTest.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsAssignedToCategoryTest.xml
@@ -140,8 +140,7 @@
-
-
+
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml
index 977eb2bdba0fe..9335f49c9bc2e 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml
@@ -122,8 +122,7 @@
-
-
+
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductWithFileCustomOptionTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductWithFileCustomOptionTest.xml
index ac14b9b299b98..e983559fb6bcf 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductWithFileCustomOptionTest.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductWithFileCustomOptionTest.xml
@@ -40,8 +40,7 @@
-
-
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminCustomerSubscribeNewsletterPerWebsiteTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminCustomerSubscribeNewsletterPerWebsiteTest.xml
index affcf6ddbe6ca..a8391458a1a50 100644
--- a/app/code/Magento/Customer/Test/Mftf/Test/AdminCustomerSubscribeNewsletterPerWebsiteTest.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminCustomerSubscribeNewsletterPerWebsiteTest.xml
@@ -41,8 +41,7 @@
-
-
+
diff --git a/app/code/Magento/Downloadable/Model/Link/Builder.php b/app/code/Magento/Downloadable/Model/Link/Builder.php
index ff76f7eeda440..eefed4c5453ab 100644
--- a/app/code/Magento/Downloadable/Model/Link/Builder.php
+++ b/app/code/Magento/Downloadable/Model/Link/Builder.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Downloadable\Model\Link;
use Magento\Downloadable\Helper\File;
@@ -12,7 +13,8 @@
use Magento\Framework\DataObject\Copy;
/**
- * Class Builder
+ * Builder download link model for downloadable product
+ *
* @api
* @since 100.1.0
*/
@@ -116,7 +118,7 @@ public function build(\Magento\Downloadable\Api\Data\LinkInterface $link)
$link->setLinkFile($linkFileName);
$link->setLinkUrl(null);
}
-
+
if (isset($this->data['sample'])) {
$link = $this->buildSample($link, $this->data['sample']);
}
@@ -132,6 +134,12 @@ public function build(\Magento\Downloadable\Api\Data\LinkInterface $link)
if (isset($this->data['is_unlimited']) && $this->data['is_unlimited']) {
$link->setNumberOfDownloads(0);
}
+
+ $useDefaultTitle = $this->data['use_default_title'] ?? false;
+
+ if ($useDefaultTitle) {
+ $link->setTitle(null);
+ }
$this->resetData();
return $link;
diff --git a/app/code/Magento/Downloadable/Model/Sample/Builder.php b/app/code/Magento/Downloadable/Model/Sample/Builder.php
index 7cc7cb640ae74..368d190319766 100644
--- a/app/code/Magento/Downloadable/Model/Sample/Builder.php
+++ b/app/code/Magento/Downloadable/Model/Sample/Builder.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Downloadable\Model\Sample;
use Magento\Downloadable\Api\Data\SampleInterface;
@@ -14,7 +15,8 @@
use Magento\Framework\DataObject\Copy;
/**
- * Class Builder
+ * Builder download sample link model for downloadable product
+ *
* @api
* @since 100.1.0
*/
@@ -24,7 +26,7 @@ class Builder
* @var Sample
*/
private $component;
-
+
/**
* @var File
*/
@@ -71,6 +73,8 @@ public function __construct(
}
/**
+ * Init data for builder
+ *
* @param array $data
* @return $this;
* @since 100.1.0
@@ -82,6 +86,8 @@ public function setData(array $data)
}
/**
+ * Build sample link
+ *
* @param SampleInterface $sample
* @return SampleInterface
* @throws \Magento\Framework\Exception\LocalizedException
@@ -116,12 +122,20 @@ public function build(SampleInterface $sample)
if (!$sample->getSortOrder()) {
$sample->setSortOrder(1);
}
+
+ $useDefaultTitle = $this->data['use_default_title'] ?? false;
+
+ if ($useDefaultTitle) {
+ $sample->setTitle(null);
+ }
$this->resetData();
return $sample;
}
/**
+ * Reset data
+ *
* @return void
*/
private function resetData()
@@ -130,6 +144,8 @@ private function resetData()
}
/**
+ * Get component
+ *
* @return Sample
*/
private function getComponent()
diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductAndAssignItToCustomStoreTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductAndAssignItToCustomStoreTest.xml
index c4d1f57e10aea..2f43c6f8278cc 100644
--- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductAndAssignItToCustomStoreTest.xml
+++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductAndAssignItToCustomStoreTest.xml
@@ -77,8 +77,7 @@
-
-
+
diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Link/BuilderTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Link/BuilderTest.php
index 26c5ccd90c463..46f4ca0408c73 100644
--- a/app/code/Magento/Downloadable/Test/Unit/Model/Link/BuilderTest.php
+++ b/app/code/Magento/Downloadable/Test/Unit/Model/Link/BuilderTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Downloadable\Test\Unit\Model\Link;
use Magento\Downloadable\Api\Data\LinkInterface;
@@ -11,7 +12,7 @@
use Magento\Downloadable\Helper\Download;
/**
- * Class BuilderTest
+ * Unit test for downloadable products' builder link class
*/
class BuilderTest extends \PHPUnit\Framework\TestCase
{
@@ -68,7 +69,7 @@ protected function setUp()
$this->linkMock = $this->getMockBuilder(LinkInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
-
+
$this->service = $objectManagerHelper->getObject(
Builder::class,
[
@@ -160,6 +161,10 @@ public function testBuild($data, $expectedPrice)
if (isset($data['is_unlimited'])) {
$this->linkMock->expects($this->once())->method('setNumberOfDownloads')->with(0);
}
+ $useDefaultTitle = $data['use_default_title'] ?? false;
+ if ($useDefaultTitle) {
+ $this->linkMock->expects($this->once())->method('setTitle')->with(null);
+ }
if (isset($data['price'])) {
$this->linkMock->expects($this->once())->method('getPrice')->willReturn($data['price']);
} else {
@@ -219,6 +224,7 @@ public function buildProvider()
[
'file' => 'cXVlIHRhbA==',
'type' => 'file',
+ 'use_default_title' => '1',
'sample' => [
'file' => 'cXVlIHRhbA==',
'type' => 'file'
diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Sample/BuilderTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Sample/BuilderTest.php
index 28ffa6db05e0b..938082fa0aef3 100644
--- a/app/code/Magento/Downloadable/Test/Unit/Model/Sample/BuilderTest.php
+++ b/app/code/Magento/Downloadable/Test/Unit/Model/Sample/BuilderTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Downloadable\Test\Unit\Model\Sample;
use Magento\Downloadable\Api\Data\SampleInterface;
@@ -11,7 +12,7 @@
use Magento\Downloadable\Model\Sample\Builder;
/**
- * Class BuilderTest
+ * Unit test for downloadable products' builder sample class
*/
class BuilderTest extends \PHPUnit\Framework\TestCase
{
@@ -84,6 +85,7 @@ public function testBuild()
{
$data = [
'file' => 'cXVlIHRhbA==',
+ 'use_default_title' => '1',
'type' => 'file'
];
$downloadableData = ['sort_order' => 1];
@@ -122,8 +124,12 @@ public function testBuild()
)->willReturn($fileName);
$this->sampleMock->expects($this->once())->method('setSampleFile')->with($fileName);
$this->sampleMock->expects($this->once())->method('setSortOrder')->with(1);
+ $useDefaultTitle = $data['use_default_title'] ?? false;
+ if ($useDefaultTitle) {
+ $this->sampleMock->expects($this->once())->method('setTitle')->with(null);
+ }
$this->service->setData($data);
-
+
$this->service->build($this->sampleMock);
}
}
diff --git a/app/code/Magento/Elasticsearch/Test/Mftf/Test/StorefrontProductQuickSearchWithDecimalAttributeUsingElasticSearchTest.xml b/app/code/Magento/Elasticsearch/Test/Mftf/Test/StorefrontProductQuickSearchWithDecimalAttributeUsingElasticSearchTest.xml
index fc66db636bb17..d9988577009bc 100644
--- a/app/code/Magento/Elasticsearch/Test/Mftf/Test/StorefrontProductQuickSearchWithDecimalAttributeUsingElasticSearchTest.xml
+++ b/app/code/Magento/Elasticsearch/Test/Mftf/Test/StorefrontProductQuickSearchWithDecimalAttributeUsingElasticSearchTest.xml
@@ -79,8 +79,7 @@
-
-
+
@@ -96,4 +95,4 @@
-
\ No newline at end of file
+
diff --git a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearch6SearchInvalidValueTest.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearch6SearchInvalidValueTest.xml
index 93a2938d86f26..237562f256692 100644
--- a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearch6SearchInvalidValueTest.xml
+++ b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearch6SearchInvalidValueTest.xml
@@ -83,8 +83,7 @@
-
-
+
diff --git a/app/code/Magento/LayeredNavigation/Test/Mftf/Test/ShopByButtonInMobileTest.xml b/app/code/Magento/LayeredNavigation/Test/Mftf/Test/ShopByButtonInMobileTest.xml
index 6f2de31548ce0..d10564f1265bf 100644
--- a/app/code/Magento/LayeredNavigation/Test/Mftf/Test/ShopByButtonInMobileTest.xml
+++ b/app/code/Magento/LayeredNavigation/Test/Mftf/Test/ShopByButtonInMobileTest.xml
@@ -52,8 +52,7 @@
-
-
+
diff --git a/app/code/Magento/MediaStorage/Service/ImageResize.php b/app/code/Magento/MediaStorage/Service/ImageResize.php
index d061ddbd3dc46..d5ce1a7e20f98 100644
--- a/app/code/Magento/MediaStorage/Service/ImageResize.php
+++ b/app/code/Magento/MediaStorage/Service/ImageResize.php
@@ -15,17 +15,18 @@
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\NotFoundException;
use Magento\Framework\Filesystem;
+use Magento\Framework\Filesystem\Directory\WriteInterface;
use Magento\Framework\Image;
use Magento\Framework\Image\Factory as ImageFactory;
use Magento\Catalog\Model\Product\Media\ConfigInterface as MediaConfig;
use Magento\Framework\App\State;
use Magento\Framework\View\ConfigInterface as ViewConfig;
-use \Magento\Catalog\Model\ResourceModel\Product\Image as ProductImage;
+use Magento\Catalog\Model\ResourceModel\Product\Image as ProductImage;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Theme\Model\Config\Customization as ThemeCustomizationConfig;
-use Magento\Theme\Model\ResourceModel\Theme\Collection;
+use Magento\Theme\Model\ResourceModel\Theme\Collection as ThemeCollection;
use Magento\Framework\App\Filesystem\DirectoryList;
-use Magento\MediaStorage\Helper\File\Storage\Database;
+use Magento\MediaStorage\Helper\File\Storage\Database as FileStorageDatabase;
use Magento\Theme\Model\Theme;
/**
@@ -76,24 +77,20 @@ class ImageResize
private $themeCustomizationConfig;
/**
- * @var Collection
+ * @var ThemeCollection
*/
private $themeCollection;
/**
- * @var Filesystem
+ * @var WriteInterface
*/
private $mediaDirectory;
/**
- * @var Filesystem
- */
- private $filesystem;
-
- /**
- * @var Database
+ * @var FileStorageDatabase
*/
private $fileStorageDatabase;
+
/**
* @var StoreManagerInterface
*/
@@ -108,9 +105,9 @@ class ImageResize
* @param ViewConfig $viewConfig
* @param AssertImageFactory $assertImageFactory
* @param ThemeCustomizationConfig $themeCustomizationConfig
- * @param Collection $themeCollection
+ * @param ThemeCollection $themeCollection
* @param Filesystem $filesystem
- * @param Database $fileStorageDatabase
+ * @param FileStorageDatabase $fileStorageDatabase
* @param StoreManagerInterface $storeManager
* @throws \Magento\Framework\Exception\FileSystemException
* @internal param ProductImage $gallery
@@ -125,9 +122,9 @@ public function __construct(
ViewConfig $viewConfig,
AssertImageFactory $assertImageFactory,
ThemeCustomizationConfig $themeCustomizationConfig,
- Collection $themeCollection,
+ ThemeCollection $themeCollection,
Filesystem $filesystem,
- Database $fileStorageDatabase = null,
+ FileStorageDatabase $fileStorageDatabase = null,
StoreManagerInterface $storeManager = null
) {
$this->appState = $appState;
@@ -140,9 +137,8 @@ public function __construct(
$this->themeCustomizationConfig = $themeCustomizationConfig;
$this->themeCollection = $themeCollection;
$this->mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
- $this->filesystem = $filesystem;
$this->fileStorageDatabase = $fileStorageDatabase ?:
- ObjectManager::getInstance()->get(Database::class);
+ ObjectManager::getInstance()->get(FileStorageDatabase::class);
$this->storeManager = $storeManager ?? ObjectManager::getInstance()->get(StoreManagerInterface::class);
}
@@ -294,7 +290,7 @@ private function makeImage(string $originalImagePath, array $imageParams): Image
}
/**
- * Resize image.
+ * Resize image if not already resized before
*
* @param array $imageParams
* @param string $originalImagePath
@@ -303,13 +299,48 @@ private function makeImage(string $originalImagePath, array $imageParams): Image
private function resize(array $imageParams, string $originalImagePath, string $originalImageName)
{
unset($imageParams['id']);
- $image = $this->makeImage($originalImagePath, $imageParams);
$imageAsset = $this->assertImageFactory->create(
[
'miscParams' => $imageParams,
'filePath' => $originalImageName,
]
);
+ $imageAssetPath = $imageAsset->getPath();
+ $usingDbAsStorage = $this->fileStorageDatabase->checkDbUsage();
+ $mediaStorageFilename = $this->mediaDirectory->getRelativePath($imageAssetPath);
+
+ $alreadyResized = $usingDbAsStorage ?
+ $this->fileStorageDatabase->fileExists($mediaStorageFilename) :
+ $this->mediaDirectory->isFile($imageAssetPath);
+
+ if (!$alreadyResized) {
+ $this->generateResizedImage(
+ $imageParams,
+ $originalImagePath,
+ $imageAssetPath,
+ $usingDbAsStorage,
+ $mediaStorageFilename
+ );
+ }
+ }
+
+ /**
+ * Generate resized image
+ *
+ * @param array $imageParams
+ * @param string $originalImagePath
+ * @param string $imageAssetPath
+ * @param bool $usingDbAsStorage
+ * @param string $mediaStorageFilename
+ */
+ private function generateResizedImage(
+ array $imageParams,
+ string $originalImagePath,
+ string $imageAssetPath,
+ bool $usingDbAsStorage,
+ string $mediaStorageFilename
+ ) {
+ $image = $this->makeImage($originalImagePath, $imageParams);
if ($imageParams['image_width'] !== null && $imageParams['image_height'] !== null) {
$image->resize($imageParams['image_width'], $imageParams['image_height']);
@@ -335,11 +366,10 @@ private function resize(array $imageParams, string $originalImagePath, string $o
$image->watermark($this->getWatermarkFilePath($imageParams['watermark_file']));
}
- $image->save($imageAsset->getPath());
+ $image->save($imageAssetPath);
- if ($this->fileStorageDatabase->checkDbUsage()) {
- $mediastoragefilename = $this->mediaDirectory->getRelativePath($imageAsset->getPath());
- $this->fileStorageDatabase->saveFile($mediastoragefilename);
+ if ($usingDbAsStorage) {
+ $this->fileStorageDatabase->saveFile($mediaStorageFilename);
}
}
diff --git a/app/code/Magento/MediaStorage/Test/Unit/Service/ImageResizeTest.php b/app/code/Magento/MediaStorage/Test/Unit/Service/ImageResizeTest.php
index f0e1efa7806e4..29ab475948221 100644
--- a/app/code/Magento/MediaStorage/Test/Unit/Service/ImageResizeTest.php
+++ b/app/code/Magento/MediaStorage/Test/Unit/Service/ImageResizeTest.php
@@ -24,8 +24,6 @@
use Magento\Framework\App\Filesystem\DirectoryList;
/**
- * Class ImageResizeTest
- *
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
@@ -249,6 +247,9 @@ public function testResizeFromThemesMediaStorageDatabase()
$this->databaseMock->expects($this->any())
->method('checkDbUsage')
->will($this->returnValue(true));
+ $this->databaseMock->expects($this->any())
+ ->method('fileExists')
+ ->will($this->returnValue(false));
$this->productImageMock->expects($this->any())
->method('getCountUsedProductImages')
@@ -289,6 +290,9 @@ public function testResizeFromImageNameMediaStorageDatabase()
$this->databaseMock->expects($this->any())
->method('checkDbUsage')
->will($this->returnValue(true));
+ $this->databaseMock->expects($this->any())
+ ->method('fileExists')
+ ->will($this->returnValue(false));
$this->mediaDirectoryMock->expects($this->any())
->method('isFile')
@@ -318,4 +322,65 @@ public function testResizeFromImageNameMediaStorageDatabase()
$this->service->resizeFromImageName($this->testfilename);
}
+
+ public function testSkipResizingAlreadyResizedImageOnDisk()
+ {
+ $this->databaseMock->expects($this->any())
+ ->method('checkDbUsage')
+ ->will($this->returnValue(false));
+
+ $this->mediaDirectoryMock->expects($this->any())
+ ->method('isFile')
+ ->will($this->returnValue(true));
+
+ $this->themeCollectionMock->expects($this->any())
+ ->method('loadRegisteredThemes')
+ ->willReturn(
+ [ new DataObject(['id' => '0']) ]
+ );
+ $this->themeCustomizationConfigMock->expects($this->any())
+ ->method('getStoresByThemes')
+ ->willReturn(
+ ['0' => []]
+ );
+
+ $this->imageFactoryMock->expects($this->never())
+ ->method('create');
+
+ $this->service->resizeFromImageName($this->testfilename);
+ }
+
+ public function testSkipResizingAlreadyResizedImageInDatabase()
+ {
+ $this->databaseMock->expects($this->any())
+ ->method('checkDbUsage')
+ ->will($this->returnValue(true));
+ $this->databaseMock->expects($this->any())
+ ->method('fileExists')
+ ->will($this->returnValue(true));
+
+ $this->mediaDirectoryMock->expects($this->any())
+ ->method('isFile')
+ ->with($this->testfilepath)
+ ->willReturnOnConsecutiveCalls(
+ $this->returnValue(false),
+ $this->returnValue(true)
+ );
+
+ $this->themeCollectionMock->expects($this->any())
+ ->method('loadRegisteredThemes')
+ ->willReturn(
+ [ new DataObject(['id' => '0']) ]
+ );
+ $this->themeCustomizationConfigMock->expects($this->any())
+ ->method('getStoresByThemes')
+ ->willReturn(
+ ['0' => []]
+ );
+
+ $this->databaseMock->expects($this->never())
+ ->method('saveFile');
+
+ $this->service->resizeFromImageName($this->testfilename);
+ }
}
diff --git a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminNameEmptyForGuestTest.xml b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminNameEmptyForGuestTest.xml
index a90a035b25726..5e35f5aab60cd 100644
--- a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminNameEmptyForGuestTest.xml
+++ b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminNameEmptyForGuestTest.xml
@@ -26,8 +26,7 @@
-
-
+
diff --git a/app/code/Magento/Persistent/Test/Mftf/Test/ShippingQuotePersistedForGuestTest.xml b/app/code/Magento/Persistent/Test/Mftf/Test/ShippingQuotePersistedForGuestTest.xml
index eebadbeaa0eec..7c4e6948386f3 100644
--- a/app/code/Magento/Persistent/Test/Mftf/Test/ShippingQuotePersistedForGuestTest.xml
+++ b/app/code/Magento/Persistent/Test/Mftf/Test/ShippingQuotePersistedForGuestTest.xml
@@ -52,8 +52,7 @@
-
-
+
diff --git a/app/code/Magento/Search/Test/Mftf/Test/AdminMassDeleteSearchTermEntityTest.xml b/app/code/Magento/Search/Test/Mftf/Test/AdminMassDeleteSearchTermEntityTest.xml
index 9ff088fb25b82..f5bb414f59197 100644
--- a/app/code/Magento/Search/Test/Mftf/Test/AdminMassDeleteSearchTermEntityTest.xml
+++ b/app/code/Magento/Search/Test/Mftf/Test/AdminMassDeleteSearchTermEntityTest.xml
@@ -63,8 +63,7 @@
-
-
+
diff --git a/app/code/Magento/Store/Test/Mftf/ActionGroup/AssertStorefrontStoreNotVisibleInFooterActionGroup.xml b/app/code/Magento/Store/Test/Mftf/ActionGroup/AssertStorefrontStoreNotVisibleInFooterActionGroup.xml
index eb8012b7d0635..73f687669497e 100644
--- a/app/code/Magento/Store/Test/Mftf/ActionGroup/AssertStorefrontStoreNotVisibleInFooterActionGroup.xml
+++ b/app/code/Magento/Store/Test/Mftf/ActionGroup/AssertStorefrontStoreNotVisibleInFooterActionGroup.xml
@@ -15,7 +15,7 @@
-
+
diff --git a/app/code/Magento/Store/Test/Mftf/ActionGroup/AssertStorefrontStoreVisibleInFooterActionGroup.xml b/app/code/Magento/Store/Test/Mftf/ActionGroup/AssertStorefrontStoreVisibleInFooterActionGroup.xml
index 3ec1555735e99..f6ef11ad01111 100644
--- a/app/code/Magento/Store/Test/Mftf/ActionGroup/AssertStorefrontStoreVisibleInFooterActionGroup.xml
+++ b/app/code/Magento/Store/Test/Mftf/ActionGroup/AssertStorefrontStoreVisibleInFooterActionGroup.xml
@@ -15,7 +15,7 @@
-
+
diff --git a/app/code/Magento/Store/Test/Mftf/ActionGroup/AssertStorefrontStoreVisibleInHeaderActionGroup.xml b/app/code/Magento/Store/Test/Mftf/ActionGroup/AssertStorefrontStoreVisibleInHeaderActionGroup.xml
index f9c10a09c51c2..b7a5e1a76d072 100644
--- a/app/code/Magento/Store/Test/Mftf/ActionGroup/AssertStorefrontStoreVisibleInHeaderActionGroup.xml
+++ b/app/code/Magento/Store/Test/Mftf/ActionGroup/AssertStorefrontStoreVisibleInHeaderActionGroup.xml
@@ -15,7 +15,7 @@
-
+
diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreViewTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreViewTest.xml
index a197f88bafba2..c4e3f51e6138f 100644
--- a/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreViewTest.xml
+++ b/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreViewTest.xml
@@ -51,8 +51,7 @@
-
-
+
diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateStoreViewTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateStoreViewTest.xml
index 3b16767e60d55..f2e9e12821595 100644
--- a/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateStoreViewTest.xml
+++ b/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateStoreViewTest.xml
@@ -71,8 +71,7 @@
-
-
+
diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCheckUrlRewritesInCatalogCategoriesAfterChangingUrlKeyForStoreViewAndMovingCategoryTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCheckUrlRewritesInCatalogCategoriesAfterChangingUrlKeyForStoreViewAndMovingCategoryTest.xml
index f430fb8921f80..f4ff706b7c3cd 100644
--- a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCheckUrlRewritesInCatalogCategoriesAfterChangingUrlKeyForStoreViewAndMovingCategoryTest.xml
+++ b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCheckUrlRewritesInCatalogCategoriesAfterChangingUrlKeyForStoreViewAndMovingCategoryTest.xml
@@ -74,8 +74,7 @@
-
-
+
diff --git a/app/design/frontend/Magento/blank/Magento_Customer/web/css/source/_module.less b/app/design/frontend/Magento/blank/Magento_Customer/web/css/source/_module.less
index 0c2b1b4db83e6..adfcb117cc9d0 100644
--- a/app/design/frontend/Magento/blank/Magento_Customer/web/css/source/_module.less
+++ b/app/design/frontend/Magento/blank/Magento_Customer/web/css/source/_module.less
@@ -412,8 +412,10 @@
.block {
&:extend(.abs-blocks-2columns all);
- &.login {
+ .login {
.actions-toolbar {
+ margin-left: 0;
+
> .primary {
margin-bottom: 0;
margin-right: @indent__l;
@@ -428,6 +430,7 @@
.fieldset {
&:after {
+ margin-left: 0;
&:extend(.abs-margin-for-forms-desktop all);
}
@@ -435,6 +438,10 @@
> .control {
width: 80%;
}
+
+ .label {
+ text-align: left;
+ }
}
}
}
diff --git a/app/design/frontend/Magento/blank/Magento_Theme/layout/default.xml b/app/design/frontend/Magento/blank/Magento_Theme/layout/default.xml
new file mode 100644
index 0000000000000..76d9d319f955c
--- /dev/null
+++ b/app/design/frontend/Magento/blank/Magento_Theme/layout/default.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+ 170
+
+
+
+
diff --git a/app/design/frontend/Magento/blank/Magento_Theme/web/css/source/_module.less b/app/design/frontend/Magento/blank/Magento_Theme/web/css/source/_module.less
index 3faa8ca965410..8518b5bf76735 100644
--- a/app/design/frontend/Magento/blank/Magento_Theme/web/css/source/_module.less
+++ b/app/design/frontend/Magento/blank/Magento_Theme/web/css/source/_module.less
@@ -200,7 +200,7 @@
}
}
- .page-header,
+ .page-header .panel.wrapper,
.page-footer {
.switcher {
margin-right: 10px;
@@ -368,7 +368,7 @@
}
.logo {
- margin: -8px auto 25px 0;
+ margin: 0 auto 25px 0;
img {
max-height: inherit;
diff --git a/app/design/frontend/Magento/luma/Magento_Theme/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Theme/web/css/source/_module.less
index 438fb55d32e5c..ac2a2f249ac11 100644
--- a/app/design/frontend/Magento/luma/Magento_Theme/web/css/source/_module.less
+++ b/app/design/frontend/Magento/luma/Magento_Theme/web/css/source/_module.less
@@ -289,7 +289,7 @@
text-align: center;
}
- .page-header,
+ .page-header .panel.wrapper,
.page-footer {
.switcher {
.options {
@@ -331,7 +331,7 @@
}
}
}
- .page-header {
+ .page-header .panel.wrapper {
.switcher {
.options {
ul.dropdown {
diff --git a/dev/tests/acceptance/tests/_suite/WYSIWYGDisabledSuite.xml b/dev/tests/acceptance/tests/_suite/WYSIWYGDisabledSuite.xml
index 65c2bb7004503..924c712404dfe 100644
--- a/dev/tests/acceptance/tests/_suite/WYSIWYGDisabledSuite.xml
+++ b/dev/tests/acceptance/tests/_suite/WYSIWYGDisabledSuite.xml
@@ -5,7 +5,7 @@
* See COPYING.txt for license details.
*/
-->
-
+
@@ -20,4 +20,4 @@
-
\ No newline at end of file
+
diff --git a/dev/tests/acceptance/tests/_suite/suite.xml.sample b/dev/tests/acceptance/tests/_suite/suite.xml.sample
index 4c6a78afd40d0..30cf2eef05682 100644
--- a/dev/tests/acceptance/tests/_suite/suite.xml.sample
+++ b/dev/tests/acceptance/tests/_suite/suite.xml.sample
@@ -5,7 +5,7 @@
* See COPYING.txt for license details.
*/
-->
-
+
diff --git a/lib/internal/Magento/Framework/RequireJs/Config.php b/lib/internal/Magento/Framework/RequireJs/Config.php
index f158aa8b1ebce..67fdd00b3d919 100644
--- a/lib/internal/Magento/Framework/RequireJs/Config.php
+++ b/lib/internal/Magento/Framework/RequireJs/Config.php
@@ -155,22 +155,15 @@ public function getConfig()
{
$distributedConfig = '';
$customConfigFiles = $this->fileSource->getFiles($this->design->getDesignTheme(), self::CONFIG_FILE_NAME);
+
foreach ($customConfigFiles as $file) {
/** @var $fileReader \Magento\Framework\Filesystem\File\Read */
$fileReader = $this->readFactory->create($file->getFilename(), DriverPool::FILE);
$config = $fileReader->readAll($file->getName());
- $distributedConfig .= str_replace(
- ['%config%', '%context%'],
- [$config, $file->getModule()],
- self::PARTIAL_CONFIG_TEMPLATE
- );
+ $distributedConfig .= str_replace('%config%', $config, self::PARTIAL_CONFIG_TEMPLATE);
}
- $fullConfig = str_replace(
- ['%function%', '%usages%'],
- [$distributedConfig],
- self::FULL_CONFIG_TEMPLATE
- );
+ $fullConfig = str_replace(['%function%', '%usages%'], [$distributedConfig], self::FULL_CONFIG_TEMPLATE);
if ($this->minification->isEnabled('js')) {
$fullConfig = $this->minifyAdapter->minify($fullConfig);
diff --git a/lib/internal/Magento/Framework/RequireJs/Test/Unit/ConfigTest.php b/lib/internal/Magento/Framework/RequireJs/Test/Unit/ConfigTest.php
index 05f040e8f406d..b6b8203bef2bc 100644
--- a/lib/internal/Magento/Framework/RequireJs/Test/Unit/ConfigTest.php
+++ b/lib/internal/Magento/Framework/RequireJs/Test/Unit/ConfigTest.php
@@ -115,9 +115,6 @@ function ($file) {
$fileOne->expects($this->once())
->method('getName')
->will($this->returnValue('file_one.js'));
- $fileOne->expects($this->once())
- ->method('getModule')
- ->will($this->returnValue('Module_One'));
$fileTwo = $this->createMock(\Magento\Framework\View\File::class);
$fileTwo->expects($this->once())
->method('getFilename')
diff --git a/lib/internal/Magento/Framework/TestFramework/Unit/Listener/GarbageCleanup.php b/lib/internal/Magento/Framework/TestFramework/Unit/Listener/GarbageCleanup.php
index bee6c0d0d7d42..34a8963c198cc 100644
--- a/lib/internal/Magento/Framework/TestFramework/Unit/Listener/GarbageCleanup.php
+++ b/lib/internal/Magento/Framework/TestFramework/Unit/Listener/GarbageCleanup.php
@@ -5,98 +5,24 @@
*/
namespace Magento\Framework\TestFramework\Unit\Listener;
-use PHPUnit\Framework\Test;
-use PHPUnit\Framework\Warning;
+use PHPUnit\Framework\TestListener;
+use PHPUnit\Framework\TestSuite;
/**
* Listener of PHPUnit built-in events that enforces cleanup of cyclic object references
*
*/
-class GarbageCleanup implements \PHPUnit\Framework\TestListener
+class GarbageCleanup implements TestListener
{
- /**
- * {@inheritdoc}
- * @SuppressWarnings(PHPMD.ShortVariable)
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function addError(\PHPUnit\Framework\Test $test, \Exception $e, $time)
- {
- }
-
- /**
- * {@inheritdoc}
- * @SuppressWarnings(PHPMD.ShortVariable)
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function addFailure(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\AssertionFailedError $e, $time)
- {
- }
+ use \PHPUnit\Framework\TestListenerDefaultImplementation;
/**
- * {@inheritdoc}
- * @SuppressWarnings(PHPMD.ShortVariable)
+ * @inheritdoc
+ *
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
- public function addIncompleteTest(\PHPUnit\Framework\Test $test, \Exception $e, $time)
- {
- }
-
- /**
- * {@inheritdoc}
- * @SuppressWarnings(PHPMD.ShortVariable)
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function addRiskyTest(\PHPUnit\Framework\Test $test, \Exception $e, $time)
- {
- }
-
- /**
- * {@inheritdoc}
- * @SuppressWarnings(PHPMD.ShortVariable)
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function addSkippedTest(\PHPUnit\Framework\Test $test, \Exception $e, $time)
- {
- }
-
- /**
- * {@inheritdoc}
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function startTestSuite(\PHPUnit\Framework\TestSuite $suite)
- {
- }
-
- /**
- * {@inheritdoc}
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function endTestSuite(\PHPUnit\Framework\TestSuite $suite)
+ public function endTestSuite(TestSuite $suite): void
{
gc_collect_cycles();
}
-
- /**
- * {@inheritdoc}
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function startTest(\PHPUnit\Framework\Test $test)
- {
- }
-
- /**
- * {@inheritdoc}
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function endTest(\PHPUnit\Framework\Test $test, $time)
- {
- }
-
- /**
- * {@inheritdoc}
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function addWarning(Test $test, Warning $e, $time)
- {
- }
}
diff --git a/lib/internal/Magento/Framework/TestFramework/Unit/Listener/ReplaceObjectManager.php b/lib/internal/Magento/Framework/TestFramework/Unit/Listener/ReplaceObjectManager.php
index 79745599e8393..1d71263a100cb 100644
--- a/lib/internal/Magento/Framework/TestFramework/Unit/Listener/ReplaceObjectManager.php
+++ b/lib/internal/Magento/Framework/TestFramework/Unit/Listener/ReplaceObjectManager.php
@@ -7,12 +7,16 @@
use Magento\Framework\App\ObjectManager;
use Magento\Framework\ObjectManagerInterface;
+use PHPUnit\Framework\Test;
+use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\TestListener;
/**
* The event listener which instantiates ObjectManager before test run
*/
-class ReplaceObjectManager extends \PHPUnit\Framework\BaseTestListener
+class ReplaceObjectManager implements TestListener
{
+ use \PHPUnit\Framework\TestListenerDefaultImplementation;
/**
* Replaces ObjectManager before run for each test
*
@@ -21,13 +25,13 @@ class ReplaceObjectManager extends \PHPUnit\Framework\BaseTestListener
* This avoids the issue with a not initialized ObjectManager
* and makes working with ObjectManager predictable as it always contains clear mock for each test
*
- * @param \PHPUnit\Framework\Test $test
+ * @param Test $test
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
- public function startTest(\PHPUnit\Framework\Test $test)
+ public function startTest(Test $test): void
{
- if ($test instanceof \PHPUnit\Framework\TestCase) {
+ if ($test instanceof TestCase) {
$objectManagerMock = $test->getMockBuilder(ObjectManagerInterface::class)
->getMockForAbstractClass();
$createMockCallback = function ($type) use ($test) {