diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index 89aea7299855c..37b7bc2ca8c3a 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -31,7 +31,7 @@ If you are a new GitHub user, we recommend that you create your own [free github
This will allow you to collaborate with the Magento 2 development team, fork the Magento 2 project and send pull requests.
1. Search current [listed issues](https://github.com/magento/magento2/issues) (open or closed) for similar proposals of intended contribution before starting work on a new contribution.
-2. Review the [Contributor License Agreement](https://magento.com/legaldocuments/mca) if this is your first time contributing.
+2. Review the [Contributor License Agreement](https://opensource.adobe.com/cla.html) if this is your first time contributing.
3. Create and test your work.
4. Fork the Magento 2 repository according to the [Fork A Repository instructions](https://devdocs.magento.com/guides/v2.3/contributor-guide/contributing.html#fork) and when you are ready to send us a pull request – follow the [Create A Pull Request instructions](https://devdocs.magento.com/guides/v2.3/contributor-guide/contributing.html#pull_request).
5. Once your contribution is received the Magento 2 development team will review the contribution and collaborate with you as needed.
diff --git a/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/_Deprecated_ActionGroup.xml b/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/_Deprecated_ActionGroup.xml
deleted file mode 100644
index fc66f9fb0ef74..0000000000000
--- a/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/_Deprecated_ActionGroup.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/AdminAnalytics/Test/Mftf/Test/TrackingScriptTest.xml b/app/code/Magento/AdminAnalytics/Test/Mftf/Test/TrackingScriptTest.xml
index 58bcacc190cff..e02c34fd8868e 100644
--- a/app/code/Magento/AdminAnalytics/Test/Mftf/Test/TrackingScriptTest.xml
+++ b/app/code/Magento/AdminAnalytics/Test/Mftf/Test/TrackingScriptTest.xml
@@ -21,6 +21,6 @@
-
+
\ No newline at end of file
diff --git a/app/code/Magento/AdminAnalytics/Test/Unit/Condition/CanViewNotificationTest.php b/app/code/Magento/AdminAnalytics/Test/Unit/Condition/CanViewNotificationTest.php
index 7819f2f017a01..19c4e7a7327d0 100644
--- a/app/code/Magento/AdminAnalytics/Test/Unit/Condition/CanViewNotificationTest.php
+++ b/app/code/Magento/AdminAnalytics/Test/Unit/Condition/CanViewNotificationTest.php
@@ -11,28 +11,27 @@
use Magento\Framework\App\ProductMetadataInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Framework\App\CacheInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class CanViewNotificationTest
- */
-class CanViewNotificationTest extends \PHPUnit\Framework\TestCase
+class CanViewNotificationTest extends TestCase
{
/** @var CanViewNotification */
private $canViewNotification;
- /** @var Logger|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Logger|MockObject */
private $viewerLoggerMock;
- /** @var ProductMetadataInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ProductMetadataInterface|MockObject */
private $productMetadataMock;
- /** @var Log|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Log|MockObject */
private $logMock;
- /** @var $cacheStorageMock \PHPUnit_Framework_MockObject_MockObject|CacheInterface */
+ /** @var $cacheStorageMock MockObject|CacheInterface */
private $cacheStorageMock;
- public function setUp()
+ protected function setUp(): void
{
$this->cacheStorageMock = $this->getMockBuilder(CacheInterface::class)
->getMockForAbstractClass();
diff --git a/app/code/Magento/AdminNotification/Test/Mftf/Test/AdminSystemNotificationNavigateMenuTest.xml b/app/code/Magento/AdminNotification/Test/Mftf/Test/AdminSystemNotificationNavigateMenuTest.xml
index 81ad2858d5901..77c8f02bfb777 100644
--- a/app/code/Magento/AdminNotification/Test/Mftf/Test/AdminSystemNotificationNavigateMenuTest.xml
+++ b/app/code/Magento/AdminNotification/Test/Mftf/Test/AdminSystemNotificationNavigateMenuTest.xml
@@ -20,7 +20,7 @@
-
+
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/AdvancedSearch/Test/Mftf/ActionGroup/AdminFillSearchTermActionGroup.xml b/app/code/Magento/AdvancedSearch/Test/Mftf/ActionGroup/AdminFillSearchTermActionGroup.xml
new file mode 100644
index 0000000000000..e402ec0391c0a
--- /dev/null
+++ b/app/code/Magento/AdvancedSearch/Test/Mftf/ActionGroup/AdminFillSearchTermActionGroup.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+ Fills the search terms form with sample data.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/AdvancedSearch/Test/Mftf/ActionGroup/AdminOpenNewSearchTermsPageActionGroup.xml b/app/code/Magento/AdvancedSearch/Test/Mftf/ActionGroup/AdminOpenNewSearchTermsPageActionGroup.xml
new file mode 100644
index 0000000000000..2fbbab8a55721
--- /dev/null
+++ b/app/code/Magento/AdvancedSearch/Test/Mftf/ActionGroup/AdminOpenNewSearchTermsPageActionGroup.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+ Navigate to search terms form page.
+
+
+
+
+
diff --git a/app/code/Magento/AdvancedSearch/Test/Mftf/ActionGroup/AdminSaveSearchTermActionGroup.xml b/app/code/Magento/AdvancedSearch/Test/Mftf/ActionGroup/AdminSaveSearchTermActionGroup.xml
new file mode 100644
index 0000000000000..cac996d97a6bf
--- /dev/null
+++ b/app/code/Magento/AdvancedSearch/Test/Mftf/ActionGroup/AdminSaveSearchTermActionGroup.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+ Save a new search term from Magento admin.
+
+
+
+
+
diff --git a/app/code/Magento/AdvancedSearch/Test/Mftf/Data/SearchTermsData.xml b/app/code/Magento/AdvancedSearch/Test/Mftf/Data/SearchTermsData.xml
new file mode 100644
index 0000000000000..913784afe66ea
--- /dev/null
+++ b/app/code/Magento/AdvancedSearch/Test/Mftf/Data/SearchTermsData.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+ books
+ Default Store View
+ http://sample.com
+ 1
+
+
diff --git a/app/code/Magento/AdvancedSearch/Test/Mftf/Page/AdminSearchTermsFormPage.xml b/app/code/Magento/AdvancedSearch/Test/Mftf/Page/AdminSearchTermsFormPage.xml
new file mode 100644
index 0000000000000..b8997093de840
--- /dev/null
+++ b/app/code/Magento/AdvancedSearch/Test/Mftf/Page/AdminSearchTermsFormPage.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/AdvancedSearch/Test/Mftf/Section/AdminSearchTermsPageFormFieldsSection.xml b/app/code/Magento/AdvancedSearch/Test/Mftf/Section/AdminSearchTermsPageFormFieldsSection.xml
new file mode 100644
index 0000000000000..ba593b332bf8a
--- /dev/null
+++ b/app/code/Magento/AdvancedSearch/Test/Mftf/Section/AdminSearchTermsPageFormFieldsSection.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/AdvancedSearch/Test/Mftf/Test/AdminAddSearchTermTest.xml b/app/code/Magento/AdvancedSearch/Test/Mftf/Test/AdminAddSearchTermTest.xml
new file mode 100644
index 0000000000000..88c04263a1bc5
--- /dev/null
+++ b/app/code/Magento/AdvancedSearch/Test/Mftf/Test/AdminAddSearchTermTest.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Amqp/Test/Unit/Setup/ConfigOptionsListTest.php b/app/code/Magento/Amqp/Test/Unit/Setup/ConfigOptionsListTest.php
index 5b19ba055d059..57d9372dc0f0d 100644
--- a/app/code/Magento/Amqp/Test/Unit/Setup/ConfigOptionsListTest.php
+++ b/app/code/Magento/Amqp/Test/Unit/Setup/ConfigOptionsListTest.php
@@ -6,12 +6,16 @@
namespace Magento\Amqp\Test\Unit\Setup;
+use Magento\Amqp\Setup\ConnectionValidator;
+use Magento\Framework\Config\Data\ConfigData;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Amqp\Setup\ConfigOptionsList;
use Magento\Framework\Setup\Option\TextConfigOption;
use Magento\Framework\App\DeploymentConfig;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ConfigOptionsListTest extends \PHPUnit\Framework\TestCase
+class ConfigOptionsListTest extends TestCase
{
/**
* @var ObjectManager
@@ -24,12 +28,12 @@ class ConfigOptionsListTest extends \PHPUnit\Framework\TestCase
private $model;
/**
- * @var \Magento\Amqp\Setup\ConnectionValidator|\PHPUnit_Framework_MockObject_MockObject
+ * @var ConnectionValidator|MockObject
*/
private $connectionValidatorMock;
/**
- * @var \Magento\Framework\App\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject
+ * @var DeploymentConfig|MockObject
*/
private $deploymentConfigMock;
@@ -38,7 +42,7 @@ class ConfigOptionsListTest extends \PHPUnit\Framework\TestCase
*/
private $options;
- protected function setUp()
+ protected function setUp(): void
{
$this->options = [
ConfigOptionsList::INPUT_KEY_QUEUE_AMQP_HOST => 'host',
@@ -51,18 +55,18 @@ protected function setUp()
];
$this->objectManager = new ObjectManager($this);
- $this->connectionValidatorMock = $this->getMockBuilder(\Magento\Amqp\Setup\ConnectionValidator::class)
+ $this->connectionValidatorMock = $this->getMockBuilder(ConnectionValidator::class)
->disableOriginalConstructor()
->setMethods([])
->getMock();
- $this->deploymentConfigMock = $this->getMockBuilder(\Magento\Framework\App\DeploymentConfig::class)
+ $this->deploymentConfigMock = $this->getMockBuilder(DeploymentConfig::class)
->disableOriginalConstructor()
->setMethods([])
->getMock();
$this->model = $this->objectManager->getObject(
- \Magento\Amqp\Setup\ConfigOptionsList::class,
+ ConfigOptionsList::class,
[
'connectionValidator' => $this->connectionValidatorMock,
]
@@ -135,9 +139,9 @@ public function testCreateConfig($options, $expectedConfigData)
$result = $this->model->createConfig($options, $this->deploymentConfigMock);
$this->assertInternalType('array', $result);
$this->assertNotEmpty($result);
- /** @var \Magento\Framework\Config\Data\ConfigData $configData */
+ /** @var ConfigData $configData */
$configData = $result[0];
- $this->assertInstanceOf(\Magento\Framework\Config\Data\ConfigData::class, $configData);
+ $this->assertInstanceOf(ConfigData::class, $configData);
$this->assertEquals($expectedConfigData, $configData->getData());
}
diff --git a/app/code/Magento/Analytics/Cron/SignUp.php b/app/code/Magento/Analytics/Cron/SignUp.php
index 8f97b839ec8ee..2588b87e84c1c 100644
--- a/app/code/Magento/Analytics/Cron/SignUp.php
+++ b/app/code/Magento/Analytics/Cron/SignUp.php
@@ -7,6 +7,7 @@
use Magento\Analytics\Model\Config\Backend\Enabled\SubscriptionHandler;
use Magento\Analytics\Model\Connector;
+use Magento\Framework\Exception\NotFoundException;
use Magento\Framework\FlagManager;
use Magento\Framework\App\Config\ReinitableConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;
@@ -57,22 +58,24 @@ public function __construct(
}
/**
- * Execute scheduled subscription operation
+ * Execute scheduled subscription operation.
+ *
* In case of failure writes message to notifications inbox
*
* @return bool
+ * @throws NotFoundException
*/
public function execute()
{
- $attemptsCount = $this->flagManager->getFlagData(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE);
+ $attemptsCount = (int)$this->flagManager->getFlagData(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE);
- if (($attemptsCount === null) || ($attemptsCount <= 0)) {
+ if ($attemptsCount <= 0) {
$this->deleteAnalyticsCronExpr();
$this->flagManager->deleteFlag(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE);
return false;
}
- $attemptsCount -= 1;
+ $attemptsCount--;
$this->flagManager->saveFlag(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE, $attemptsCount);
$signUpResult = $this->connector->execute('signUp');
if ($signUpResult === false) {
diff --git a/app/code/Magento/Analytics/Cron/Update.php b/app/code/Magento/Analytics/Cron/Update.php
index 9062a7bac7551..b5e4b82a0777e 100644
--- a/app/code/Magento/Analytics/Cron/Update.php
+++ b/app/code/Magento/Analytics/Cron/Update.php
@@ -8,6 +8,7 @@
use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\Config\Backend\Baseurl\SubscriptionUpdateHandler;
use Magento\Analytics\Model\Connector;
+use Magento\Framework\Exception\NotFoundException;
use Magento\Framework\FlagManager;
use Magento\Framework\App\Config\ReinitableConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;
@@ -67,26 +68,37 @@ public function __construct(
* Execute scheduled update operation
*
* @return bool
+ * @throws NotFoundException
*/
public function execute()
{
$result = false;
- $attemptsCount = $this->flagManager
+ $attemptsCount = (int)$this->flagManager
->getFlagData(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE);
- if ($attemptsCount) {
- $attemptsCount -= 1;
+ if (($attemptsCount > 0) && $this->analyticsToken->isTokenExist()) {
+ $attemptsCount--;
+ $this->flagManager
+ ->saveFlag(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE, $attemptsCount);
$result = $this->connector->execute('update');
}
if ($result || ($attemptsCount <= 0) || (!$this->analyticsToken->isTokenExist())) {
- $this->flagManager
- ->deleteFlag(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE);
- $this->flagManager->deleteFlag(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE);
- $this->configWriter->delete(SubscriptionUpdateHandler::UPDATE_CRON_STRING_PATH);
- $this->reinitableConfig->reinit();
+ $this->exitFromUpdateProcess();
}
return $result;
}
+
+ /**
+ * Clean-up flags and refresh configuration
+ */
+ private function exitFromUpdateProcess(): void
+ {
+ $this->flagManager
+ ->deleteFlag(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE);
+ $this->flagManager->deleteFlag(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE);
+ $this->configWriter->delete(SubscriptionUpdateHandler::UPDATE_CRON_STRING_PATH);
+ $this->reinitableConfig->reinit();
+ }
}
diff --git a/app/code/Magento/Analytics/Setup/Patch/Data/ActivateDataCollection.php b/app/code/Magento/Analytics/Setup/Patch/Data/ActivateDataCollection.php
new file mode 100644
index 0000000000000..dd60d74b53d09
--- /dev/null
+++ b/app/code/Magento/Analytics/Setup/Patch/Data/ActivateDataCollection.php
@@ -0,0 +1,95 @@
+scopeConfig = $scopeConfig;
+ $this->subscriptionStatusProvider = $subscriptionStatusProvider;
+ $this->collectionTimeBackendModel = $collectionTimeBackendModel;
+ }
+
+ /**
+ * @inheritDoc
+ *
+ * @throws LocalizedException
+ */
+ public function apply()
+ {
+ $subscriptionStatus = $this->subscriptionStatusProvider->getStatus();
+ $isCollectionProcessActivated = $this->scopeConfig->getValue(CollectionTime::CRON_SCHEDULE_PATH);
+ if ($subscriptionStatus !== $this->subscriptionStatusProvider->getStatusForDisabledSubscription()
+ && !$isCollectionProcessActivated
+ ) {
+ $this->collectionTimeBackendModel
+ ->setValue($this->scopeConfig->getValue($this->analyticsCollectionTimeConfigPath));
+ $this->collectionTimeBackendModel->setPath($this->analyticsCollectionTimeConfigPath);
+ $this->collectionTimeBackendModel->afterSave();
+ }
+
+ return $this;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public static function getDependencies()
+ {
+ return [
+ PrepareInitialConfig::class,
+ ];
+ }
+}
diff --git a/app/code/Magento/Analytics/Setup/Patch/Data/PrepareInitialConfig.php b/app/code/Magento/Analytics/Setup/Patch/Data/PrepareInitialConfig.php
index a352854a8b77b..97ac340f9d491 100644
--- a/app/code/Magento/Analytics/Setup/Patch/Data/PrepareInitialConfig.php
+++ b/app/code/Magento/Analytics/Setup/Patch/Data/PrepareInitialConfig.php
@@ -4,17 +4,18 @@
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Setup\Patch\Data;
use Magento\Analytics\Model\Config\Backend\Enabled\SubscriptionHandler;
+use Magento\Config\Model\Config\Source\Enabledisable;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
/**
- * Initial patch.
- *
- * @package Magento\Analytics\Setup\Patch
+ * Active subscription process for Advanced Reporting
*/
class PrepareInitialConfig implements DataPatchInterface, PatchVersionInterface
{
@@ -24,50 +25,47 @@ class PrepareInitialConfig implements DataPatchInterface, PatchVersionInterface
private $moduleDataSetup;
/**
- * PrepareInitialConfig constructor.
+ * @var SubscriptionHandler
+ */
+ private $subscriptionHandler;
+
+ /**
+ * @var string
+ */
+ private $subscriptionEnabledConfigPath = 'analytics/subscription/enabled';
+
+ /**
* @param ModuleDataSetupInterface $moduleDataSetup
+ * @param SubscriptionHandler $subscriptionHandler
*/
public function __construct(
- ModuleDataSetupInterface $moduleDataSetup
+ ModuleDataSetupInterface $moduleDataSetup,
+ SubscriptionHandler $subscriptionHandler
) {
$this->moduleDataSetup = $moduleDataSetup;
+ $this->subscriptionHandler = $subscriptionHandler;
}
/**
- * {@inheritdoc}
+ * @inheritDoc
*/
public function apply()
{
- $this->moduleDataSetup->getConnection()->insertMultiple(
+ $this->moduleDataSetup->getConnection()->insert(
$this->moduleDataSetup->getTable('core_config_data'),
[
- [
- 'scope' => 'default',
- 'scope_id' => 0,
- 'path' => 'analytics/subscription/enabled',
- 'value' => 1
- ],
- [
- 'scope' => 'default',
- 'scope_id' => 0,
- 'path' => SubscriptionHandler::CRON_STRING_PATH,
- 'value' => join(' ', SubscriptionHandler::CRON_EXPR_ARRAY)
- ]
+ 'path' => $this->subscriptionEnabledConfigPath,
+ 'value' => Enabledisable::ENABLE_VALUE,
]
);
- $this->moduleDataSetup->getConnection()->insert(
- $this->moduleDataSetup->getTable('flag'),
- [
- 'flag_code' => SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE,
- 'state' => 0,
- 'flag_data' => 24,
- ]
- );
+ $this->subscriptionHandler->processEnabled();
+
+ return $this;
}
/**
- * {@inheritdoc}
+ * @inheritDoc
*/
public static function getDependencies()
{
@@ -75,7 +73,7 @@ public static function getDependencies()
}
/**
- * {@inheritdoc}
+ * @inheritDoc
*/
public static function getVersion()
{
@@ -83,7 +81,7 @@ public static function getVersion()
}
/**
- * {@inheritdoc}
+ * @inheritDoc
*/
public function getAliases()
{
diff --git a/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingButtonTest.xml b/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingButtonTest.xml
index 5da7ccd3c9823..cbcbb3a5dd64c 100644
--- a/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingButtonTest.xml
+++ b/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingButtonTest.xml
@@ -22,7 +22,7 @@
-
+
diff --git a/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingNavigateMenuTest.xml b/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingNavigateMenuTest.xml
index c742248b32cc3..ee25e80fcab30 100644
--- a/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingNavigateMenuTest.xml
+++ b/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingNavigateMenuTest.xml
@@ -20,7 +20,7 @@
-
+
diff --git a/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationPermissionTest.xml b/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationPermissionTest.xml
index 93ee464a17efa..40f80ce52c2de 100644
--- a/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationPermissionTest.xml
+++ b/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationPermissionTest.xml
@@ -35,8 +35,9 @@
-
+
+
diff --git a/app/code/Magento/Analytics/Test/Unit/Cron/UpdateTest.php b/app/code/Magento/Analytics/Test/Unit/Cron/UpdateTest.php
index aa3011ffc94f6..fa007268474c4 100644
--- a/app/code/Magento/Analytics/Test/Unit/Cron/UpdateTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Cron/UpdateTest.php
@@ -11,6 +11,7 @@
use Magento\Analytics\Model\Connector;
use Magento\Framework\App\Config\ReinitableConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;
+use Magento\Framework\Exception\NotFoundException;
use Magento\Framework\FlagManager;
class UpdateTest extends \PHPUnit\Framework\TestCase
@@ -45,6 +46,9 @@ class UpdateTest extends \PHPUnit\Framework\TestCase
*/
private $update;
+ /**
+ * @inheritDoc
+ */
protected function setUp()
{
$this->connectorMock = $this->getMockBuilder(Connector::class)
@@ -74,6 +78,7 @@ protected function setUp()
/**
* @return void
+ * @throws NotFoundException
*/
public function testExecuteWithoutToken()
{
@@ -82,12 +87,12 @@ public function testExecuteWithoutToken()
->with(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE)
->willReturn(10);
$this->connectorMock
- ->expects($this->once())
+ ->expects($this->never())
->method('execute')
->with('update')
->willReturn(false);
$this->analyticsTokenMock
- ->expects($this->once())
+ ->expects($this->any())
->method('isTokenExist')
->willReturn(false);
$this->addFinalOutputAsserts();
@@ -120,6 +125,7 @@ private function addFinalOutputAsserts(bool $isExecuted = true)
* @param $counterData
* @return void
* @dataProvider executeWithEmptyReverseCounterDataProvider
+ * @throws NotFoundException
*/
public function testExecuteWithEmptyReverseCounter($counterData)
{
@@ -159,6 +165,7 @@ public function executeWithEmptyReverseCounterDataProvider()
* @param bool $functionResult
* @return void
* @dataProvider executeRegularScenarioDataProvider
+ * @throws NotFoundException
*/
public function testExecuteRegularScenario(
int $reverseCount,
@@ -170,6 +177,10 @@ public function testExecuteRegularScenario(
->method('getFlagData')
->with(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE)
->willReturn($reverseCount);
+ $this->flagManagerMock
+ ->expects($this->once())
+ ->method('saveFlag')
+ ->with(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE, $reverseCount - 1);
$this->connectorMock
->expects($this->once())
->method('execute')
diff --git a/app/code/Magento/Analytics/etc/adminhtml/system.xml b/app/code/Magento/Analytics/etc/adminhtml/system.xml
index 999d565353329..0aba6e4dd00ed 100644
--- a/app/code/Magento/Analytics/etc/adminhtml/system.xml
+++ b/app/code/Magento/Analytics/etc/adminhtml/system.xml
@@ -28,6 +28,9 @@
Time of day to send data
Magento\Analytics\Block\Adminhtml\System\Config\CollectionTimeLabel
Magento\Analytics\Model\Config\Backend\CollectionTime
+
+ 1
+
Industry Data
@@ -36,9 +39,9 @@
Magento\Analytics\Model\Config\Source\Vertical
Magento\Analytics\Model\Config\Backend\Vertical
Magento\Analytics\Block\Adminhtml\System\Config\Vertical
-
- 1
-
+
+ 1
+