diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
deleted file mode 100644
index 00763eb56e0c6..0000000000000
--- a/.github/CODEOWNERS
+++ /dev/null
@@ -1,206 +0,0 @@
-/app/code/Magento/AdminNotification/ @paliarush
-/app/code/Magento/Backend/ @paliarush
-/app/code/Magento/User/ @paliarush
-/lib/internal/Magento/Framework/App/ @buskamuza
-/lib/internal/Magento/Framework/Controller/ @buskamuza
-/lib/internal/Magento/Framework/Flag/ @buskamuza
-/lib/internal/Magento/Framework/HTTP/ @buskamuza
-/lib/internal/Magento/Framework/Logger/ @buskamuza
-/lib/internal/Magento/Framework/Message/ @buskamuza
-/lib/internal/Magento/Framework/Notification/ @buskamuza
-/lib/internal/Magento/Framework/Session/ @buskamuza
-/lib/internal/Magento/Framework/Url/ @buskamuza
-/app/code/Magento/Cms/ @melnikovi
-/app/code/Magento/CmsUrlRewrite/ @melnikovi
-/app/code/Magento/Contact/ @melnikovi
-/app/code/Magento/Email/ @melnikovi
-/app/code/Magento/Variable/ @melnikovi
-/app/code/Magento/Widget/ @melnikovi
-/lib/internal/Magento/Framework/Cache/ @kokoc
-/app/code/Magento/CacheInvalidate/ @kokoc
-/app/code/Magento/CatalogInventory/ @tariqjawed83 @maghamed
-/app/code/Magento/Bundle/ @akaplya
-/app/code/Magento/BundleImportExport/ @akaplya
-/app/code/Magento/Catalog/ @akaplya
-/app/code/Magento/CatalogAnalytics/ @akaplya
-/app/code/Magento/CatalogImportExport/ @akaplya
-/app/code/Magento/CatalogSearch/ @kokoc
-/app/code/Magento/CatalogUrlRewrite/ @akaplya
-/app/code/Magento/ConfigurableImportExport/ @akaplya
-/app/code/Magento/ConfigurableProduct/ @akaplya
-/app/code/Magento/Downloadable/ @akaplya
-/app/code/Magento/DownloadableImportExport/ @akaplya
-/app/code/Magento/GroupedImportExport/ @akaplya
-/app/code/Magento/GroupedProduct/ @akaplya
-/app/code/Magento/LayeredNavigation/ @kokoc
-/app/code/Magento/ProductVideo/ @akaplya
-/app/code/Magento/Review/ @akaplya
-/app/code/Magento/Swatches/ @akaplya
-/app/code/Magento/SwatchesLayeredNavigation/ @kokoc
-/app/code/Magento/Checkout/ @paliarush
-/app/code/Magento/CheckoutAgreements/ @paliarush
-/app/code/Magento/GiftMessage/ @paliarush
-/app/code/Magento/InstantPurchase/ @paliarush
-/app/code/Magento/Multishipping/ @joni-jones
-/app/code/Magento/Quote/ @paliarush
-/app/code/Magento/QuoteAnalytics/ @paliarush
-/lib/internal/Magento/Framework/Code/ @joni-jones
-/lib/internal/Magento/Framework/Reflection/ @joni-jones
-/lib/internal/Magento/Framework/Component/ @buskamuza
-/app/code/Magento/Version/ @buskamuza
-/lib/internal/Magento/Framework/Config/ @paliarush
-/app/code/Magento/Config/ @paliarush
-/lib/internal/Magento/Framework/Console/ @joni-jones
-/lib/internal/Magento/Framework/Process/ @joni-jones
-/lib/internal/Magento/Framework/Shell/ @joni-jones
-/app/code/Magento/Cookie/ @kokoc
-/lib/internal/Magento/Framework/Crontab/ @tariqjawed83 @buskamuza
-/app/code/Magento/Cron/ @tariqjawed83 @buskamuza
-/app/code/Magento/Customer/ @paliarush
-/app/code/Magento/CustomerAnalytics/ @paliarush
-/app/code/Magento/CustomerImportExport/ @paliarush
-/app/code/Magento/Persistent/ @paliarush
-/app/code/Magento/Wishlist/ @paliarush
-/lib/internal/Magento/Framework/DB/ @akaplya
-/lib/internal/Magento/Framework/EntityManager/ @akaplya
-/lib/internal/Magento/Framework/Indexer/ @akaplya
-/lib/internal/Magento/Framework/Model/ @akaplya
-/lib/internal/Magento/Framework/Mview/ @akaplya
-/app/code/Magento/Eav/ @akaplya
-/app/code/Magento/Indexer/ @akaplya
-/lib/internal/Magento/Framework/Archive/ @joni-jones
-/lib/internal/Magento/Framework/Convert/ @joni-jones
-/lib/internal/Magento/Framework/Data/ @joni-jones
-/lib/internal/Magento/Framework/DomDocument/ @joni-jones
-/lib/internal/Magento/Framework/Json/ @joni-jones
-/lib/internal/Magento/Framework/Math/ @joni-jones
-/lib/internal/Magento/Framework/Parse/ @joni-jones
-/lib/internal/Magento/Framework/Serialize/ @joni-jones
-/lib/internal/Magento/Framework/Simplexml/ @joni-jones
-/lib/internal/Magento/Framework/Stdlib/ @joni-jones
-/lib/internal/Magento/Framework/Unserialize/ @joni-jones
-/lib/internal/Magento/Framework/Xml/ @joni-jones
-/lib/internal/Magento/Framework/XsltProcessor/ @joni-jones
-/app/code/Magento/Deploy/ @kandy @buskamuza
-/lib/internal/Magento/Framework/Profiler/ @kandy
-/app/code/Magento/Developer/ @buskamuza
-/app/code/Magento/Directory/ @buskamuza
-/lib/internal/Magento/Framework/Exception/ @paliarush
-/lib/internal/Magento/Framework/File/ @buskamuza
-/lib/internal/Magento/Framework/Filesystem/ @buskamuza
-/lib/internal/Magento/Framework/System/ @buskamuza
-/lib/internal/Magento/Framework/Css/ @DrewML
-/lib/internal/Magento/Framework/Option/ @DrewML
-/lib/internal/Magento/Framework/RequireJs/ @DrewML
-/lib/internal/Magento/Framework/View/ @melnikovi
-/dev/tests/js/ @DrewML
-/app/code/Magento/RequireJs/ @DrewML
-/app/code/Magento/Theme/ @melnikovi
-/app/code/Magento/Ui/ @melnikovi
-/lib/internal/Magento/Framework/Intl/ @melnikovi
-/lib/internal/Magento/Framework/Locale/ @melnikovi
-/lib/internal/Magento/Framework/Phrase/ @melnikovi
-/lib/internal/Magento/Framework/Translate/ @melnikovi
-/app/code/Magento/Translation/ @melnikovi
-/app/code/Magento/ImportExport/ @akaplya
-/app/code/Magento/GoogleAdwords/ @buskamuza @melnikovi
-/app/code/Magento/Newsletter/ @buskamuza @melnikovi
-/app/code/Magento/ProductAlert/ @buskamuza @melnikovi
-/app/code/Magento/Rss/ @buskamuza @melnikovi
-/app/code/Magento/SendFriend/ @buskamuza @melnikovi
-/app/code/Magento/Marketplace/ @buskamuza
-/app/code/Magento/MediaStorage/ @buskamuza
-/lib/internal/Magento/Framework/Amqp/ @tariqjawed83 @paliarush
-/lib/internal/Magento/Framework/Bulk/ @tariqjawed83 @paliarush
-/lib/internal/Magento/Framework/Communication/ @tariqjawed83 @paliarush
-/app/code/Magento/Amqp/ @tariqjawed83 @paliarush
-/app/code/Magento/AsynchronousOperations/ @tariqjawed83 @paliarush
-/app/code/Magento/MessageQueue/ @tariqjawed83 @paliarush
-/app/code/Magento/MysqlMq/ @tariqjawed83 @paliarush
-/app/code/Magento/Sales/ @joni-jones
-/app/code/Magento/SalesInventory/ @joni-jones
-/app/code/Magento/SalesSequence/ @joni-jones
-/lib/internal/Magento/Framework/Event/ @buskamuza @kandy
-/lib/internal/Magento/Framework/Interception/ @buskamuza @kandy
-/lib/internal/Magento/Framework/ObjectManager/ @buskamuza @kandy
-/app/code/Magento/PageCache/ @Andrey @kokoc @paliarush
-/app/code/Magento/Authorizenet/ @joni-jones
-/app/code/Magento/Braintree/ @joni-jones
-/app/code/Magento/OfflinePayments/ @joni-jones
-/app/code/Magento/Payment/ @joni-jones
-/app/code/Magento/Paypal/ @joni-jones
-/app/code/Magento/Signifyd/ @joni-jones
-/app/code/Magento/Vault/ @joni-jones
-/lib/internal/Magento/Framework/Pricing/ @akaplya
-/app/code/Magento/AdvancedPricingImportExport/ @akaplya
-/app/code/Magento/CurrencySymbol/ @akaplya
-/app/code/Magento/Msrp/ @akaplya
-/app/code/Magento/Tax/ @akaplya
-/app/code/Magento/TaxImportExport/ @akaplya
-/app/code/Magento/Weee/ @akaplya
-/app/code/Magento/CatalogRule/ @kokoc
-/app/code/Magento/CatalogRuleConfigurable/ @kokoc
-/app/code/Magento/CatalogWidget/ @kokoc
-/app/code/Magento/Rule/ @kokoc
-/app/code/Magento/SalesRule/ @akaplya
-/app/code/Magento/ReleaseNotification/ @paliarush
-/app/code/Magento/Analytics/ @tariqjawed83 @buskamuza
-/app/code/Magento/GoogleAnalytics/ @tariqjawed83 @buskamuza
-/app/code/Magento/NewRelicReporting/ @tariqjawed83 @buskamuza
-/app/code/Magento/Reports/ @tariqjawed83 @buskamuza
-/app/code/Magento/ReviewAnalytics/ @tariqjawed83 @buskamuza
-/app/code/Magento/SalesAnalytics/ @tariqjawed83 @buskamuza
-/app/code/Magento/WishlistAnalytics/ @tariqjawed83 @buskamuza
-/app/code/Magento/GoogleOptimizer/ @paliarush
-/app/code/Magento/Robots/ @paliarush
-/app/code/Magento/Sitemap/ @paliarush
-/lib/internal/Magento/Framework/Search/ @kokoc
-/app/code/Magento/AdvancedSearch/ @kokoc
-/app/code/Magento/Elasticsearch/ @kokoc
-/app/code/Magento/Search/ @kokoc
-/lib/internal/Magento/Framework/Acl/ @kokoc
-/lib/internal/Magento/Framework/Authorization/ @kokoc
-/lib/internal/Magento/Framework/Encryption/ @kokoc
-/app/code/Magento/Authorization/ @kokoc
-/app/code/Magento/Captcha/ @kokoc
-/app/code/Magento/EncryptionKey/ @kokoc
-/app/code/Magento/Security/ @kokoc
-/lib/internal/Magento/Framework/Autoload/ @buskamuza
-/lib/internal/Magento/Framework/Backup/ @buskamuza
-/lib/internal/Magento/Framework/Composer/ @buskamuza
-/lib/internal/Magento/Framework/Setup/ @buskamuza
-/app/code/Magento/Backup/ @buskamuza
-/setup/ @buskamuza
-/app/code/Magento/Dhl/ @joni-jones
-/app/code/Magento/Fedex/ @joni-jones
-/app/code/Magento/OfflineShipping/ @joni-jones
-/app/code/Magento/Shipping/ @joni-jones
-/app/code/Magento/Ups/ @joni-jones
-/app/code/Magento/Usps/ @joni-jones
-/app/code/Magento/Store/ @akaplya
-/lib/internal/Magento/Framework/TestFramework/ @paliarush
-/dev/tests/integration/framework/ @buskamuza
-/dev/tests/setup-integration/framework/ @paliarush
-/dev/tests/static/framework/ @paliarush
-/dev/tests/unit/ @paliarush
-/dev/tests/api-functional/ @paliarush
-/app/code/Magento/UrlRewrite/ @kokoc
-/lib/internal/Magento/Framework/Image/ @buskamuza
-/lib/internal/Magento/Framework/Mail/ @melnikovi
-/lib/internal/Magento/Framework/Filter/ @melnikovi
-/lib/internal/Magento/Framework/Validation/ @melnikovi
-/lib/internal/Magento/Framework/Validator/ @melnikovi
-/lib/internal/Magento/Framework/Api/ @paliarush
-/lib/internal/Magento/Framework/GraphQL/ @paliarush
-/lib/internal/Magento/Framework/Oauth/ @paliarush
-/lib/internal/Magento/Framework/Webapi/ @paliarush
-/app/code/Magento/GraphQL/ @paliarush
-/app/code/Magento/Integration/ @paliarush
-/app/code/Magento/Swagger/ @paliarush
-/app/code/Magento/Webapi/ @paliarush
-/app/code/Magento/WebapiSecurity/ @paliarush
-
-composer.json @buskamuza
-*.js @DrewML
-.htaccess* @akaplya
-nginx.conf* @akaplya
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/.github/ISSUE_TEMPLATE/developer-experience-issue.md b/.github/ISSUE_TEMPLATE/developer-experience-issue.md
index 423d4818fb31c..713ce410a16e1 100644
--- a/.github/ISSUE_TEMPLATE/developer-experience-issue.md
+++ b/.github/ISSUE_TEMPLATE/developer-experience-issue.md
@@ -1,6 +1,7 @@
---
name: Developer experience issue
about: Issues related to customization, extensibility, modularity
+labels: 'Triage: Dev.Experience'
---
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
index f64185773cab4..7b6a8d199f28f 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -1,6 +1,7 @@
---
name: Feature request
about: Please consider reporting directly to https://github.com/magento/community-features
+labels: 'feature request'
---
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 11da06ee704c6..5d6620ce19228 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -15,6 +15,9 @@
Letting us know what has changed and why it needed changing will help us validate this pull request.
-->
+### Related Pull Requests
+
+
### Fixed Issues (if relevant)
+
+
+
+
+
+
diff --git a/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/LoginAdminWithCredentialsActionGroup.xml b/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/LoginAdminWithCredentialsActionGroup.xml
deleted file mode 100644
index d9f5e5dbcb106..0000000000000
--- a/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/LoginAdminWithCredentialsActionGroup.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/LoginAsAdminActionGroup.xml b/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/LoginAsAdminActionGroup.xml
deleted file mode 100644
index 5cf7be8a6fe11..0000000000000
--- a/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/LoginAsAdminActionGroup.xml
+++ /dev/null
@@ -1,14 +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/Block/System/Messages.php b/app/code/Magento/AdminNotification/Block/System/Messages.php
index b950f5583e599..c9b3a0b8844cc 100644
--- a/app/code/Magento/AdminNotification/Block/System/Messages.php
+++ b/app/code/Magento/AdminNotification/Block/System/Messages.php
@@ -5,45 +5,54 @@
*/
namespace Magento\AdminNotification\Block\System;
-class Messages extends \Magento\Backend\Block\Template
+use Magento\AdminNotification\Model\ResourceModel\System\Message\Collection\Synchronized;
+use Magento\Backend\Block\Template;
+use Magento\Backend\Block\Template\Context as TemplateContext;
+use Magento\Framework\Json\Helper\Data as JsonDataHelper;
+use Magento\Framework\Notification\MessageInterface;
+use Magento\Framework\Serialize\Serializer\Json as JsonSerializer;
+
+/**
+ * AdminNotification Messages class
+ */
+class Messages extends Template
{
/**
- * Message list
+ * Synchronized Message collection
*
- * @var \Magento\AdminNotification\Model\ResourceModel\System\Message\Collection\Synchronized
+ * @var Synchronized
*/
protected $_messages;
/**
- * @var \Magento\Framework\Json\Helper\Data
+ * @var JsonDataHelper
* @deprecated
*/
protected $jsonHelper;
/**
- * @var \Magento\Framework\Serialize\Serializer\Json
+ * @var JsonSerializer
*/
private $serializer;
/**
- * @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\AdminNotification\Model\ResourceModel\System\Message\Collection\Synchronized $messages
- * @param \Magento\Framework\Json\Helper\Data $jsonHelper
+ * @param TemplateContext $context
+ * @param Synchronized $messages
+ * @param JsonDataHelper $jsonHelper
+ * @param JsonSerializer $serializer
* @param array $data
- * @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
*/
public function __construct(
- \Magento\Backend\Block\Template\Context $context,
- \Magento\AdminNotification\Model\ResourceModel\System\Message\Collection\Synchronized $messages,
- \Magento\Framework\Json\Helper\Data $jsonHelper,
- array $data = [],
- \Magento\Framework\Serialize\Serializer\Json $serializer = null
+ TemplateContext $context,
+ Synchronized $messages,
+ JsonDataHelper $jsonHelper,
+ JsonSerializer $serializer,
+ array $data = []
) {
$this->jsonHelper = $jsonHelper;
parent::__construct($context, $data);
$this->_messages = $messages;
- $this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
- ->get(\Magento\Framework\Serialize\Serializer\Json::class);
+ $this->serializer = $serializer;
}
/**
@@ -62,16 +71,14 @@ protected function _toHtml()
/**
* Retrieve message list
*
- * @return \Magento\Framework\Notification\MessageInterface[]
+ * @return MessageInterface[]|null
*/
public function getLastCritical()
{
$items = array_values($this->_messages->getItems());
- if (isset(
- $items[0]
- ) && $items[0]->getSeverity() == \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL
- ) {
- return $items[0];
+
+ if (!empty($items) && current($items)->getSeverity() === MessageInterface::SEVERITY_CRITICAL) {
+ return current($items);
}
return null;
}
@@ -83,9 +90,7 @@ public function getLastCritical()
*/
public function getCriticalCount()
{
- return $this->_messages->getCountBySeverity(
- \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL
- );
+ return $this->_messages->getCountBySeverity(MessageInterface::SEVERITY_CRITICAL);
}
/**
@@ -95,9 +100,7 @@ public function getCriticalCount()
*/
public function getMajorCount()
{
- return $this->_messages->getCountBySeverity(
- \Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR
- );
+ return $this->_messages->getCountBySeverity(MessageInterface::SEVERITY_MAJOR);
}
/**
diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/AjaxMarkAsRead.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/AjaxMarkAsRead.php
index da797fe12e75a..be128435b62a1 100644
--- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/AjaxMarkAsRead.php
+++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/AjaxMarkAsRead.php
@@ -1,33 +1,34 @@
notificationService = $notificationService?: \Magento\Framework\App\ObjectManager::getInstance()
- ->get(\Magento\AdminNotification\Model\NotificationService::class);
+ $this->notificationService = $notificationService;
}
/**
diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsRead.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsRead.php
index 6b5e0681139cf..7b3f99ae8e2c1 100644
--- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsRead.php
+++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsRead.php
@@ -1,12 +1,20 @@
notificationService = $notificationService;
+ }
+
+ /**
+ * @inheritdoc
*/
public function execute()
{
$notificationId = (int)$this->getRequest()->getParam('id');
if ($notificationId) {
try {
- $this->_objectManager->create(
- \Magento\AdminNotification\Model\NotificationService::class
- )->markAsRead(
- $notificationId
- );
+ $this->notificationService->markAsRead($notificationId);
$this->messageManager->addSuccessMessage(__('The message has been marked as Read.'));
- } catch (\Magento\Framework\Exception\LocalizedException $e) {
+ } catch (LocalizedException $e) {
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addExceptionMessage(
@@ -38,9 +57,8 @@ public function execute()
);
}
- $this->getResponse()->setRedirect($this->_redirect->getRedirectUrl($this->getUrl('*')));
- return;
+ return $this->getResponse()->setRedirect($this->_redirect->getRedirectUrl($this->getUrl('*')));
}
- $this->_redirect('adminhtml/*/');
+ return $this->_redirect('adminhtml/*/');
}
}
diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php
index 9ae4a7cdac0b9..12198d05f6ae7 100644
--- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php
+++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php
@@ -1,14 +1,20 @@
inboxModelFactory = $inboxModelFactory;
+ }
+
+ /**
+ * @inheritdoc
*/
public function execute()
{
@@ -27,7 +48,7 @@ public function execute()
} else {
try {
foreach ($ids as $id) {
- $model = $this->_objectManager->create(\Magento\AdminNotification\Model\Inbox::class)->load($id);
+ $model = $this->inboxModelFactory->create()->load($id);
if ($model->getId()) {
$model->setIsRead(1)->save();
}
@@ -44,6 +65,6 @@ public function execute()
);
}
}
- $this->_redirect('adminhtml/*/');
+ return $this->_redirect('adminhtml/*/');
}
}
diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php
index 06659b8452cab..0ca114ac4021c 100644
--- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php
+++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php
@@ -1,12 +1,19 @@
inboxModelFactory = $inboxModelFactory;
+ }
/**
- * @return void
+ * @inheritdoc
*/
public function execute()
{
@@ -27,7 +48,7 @@ public function execute()
} else {
try {
foreach ($ids as $id) {
- $model = $this->_objectManager->create(\Magento\AdminNotification\Model\Inbox::class)->load($id);
+ $model = $this->inboxModelFactory->create()->load($id);
if ($model->getId()) {
$model->setIsRemove(1)->save();
}
@@ -42,6 +63,6 @@ public function execute()
);
}
}
- $this->_redirect('adminhtml/*/');
+ return $this->_redirect('adminhtml/*/');
}
}
diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php
index f0724a9587c50..fe699cd692160 100644
--- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php
+++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php
@@ -1,14 +1,20 @@
inboxModelFactory = $inboxModelFactory;
+ }
+
+ /**
+ * @inheritdoc
*/
public function execute()
{
if ($id = $this->getRequest()->getParam('id')) {
- $model = $this->_objectManager->create(\Magento\AdminNotification\Model\Inbox::class)->load($id);
+ $model = $this->inboxModelFactory->create()->load($id);
if (!$model->getId()) {
- $this->_redirect('adminhtml/*/');
- return;
+ return $this->_redirect('adminhtml/*/');
}
try {
@@ -41,9 +61,8 @@ public function execute()
);
}
- $this->_redirect('adminhtml/*/');
- return;
+ return $this->_redirect('adminhtml/*/');
}
- $this->_redirect('adminhtml/*/');
+ return $this->_redirect('adminhtml/*/');
}
}
diff --git a/app/code/Magento/AdminNotification/Test/Mftf/Test/AdminSystemNotificationNavigateMenuTest.xml b/app/code/Magento/AdminNotification/Test/Mftf/Test/AdminSystemNotificationNavigateMenuTest.xml
index 75dceb4028622..77c8f02bfb777 100644
--- a/app/code/Magento/AdminNotification/Test/Mftf/Test/AdminSystemNotificationNavigateMenuTest.xml
+++ b/app/code/Magento/AdminNotification/Test/Mftf/Test/AdminSystemNotificationNavigateMenuTest.xml
@@ -20,10 +20,10 @@
-
+
-
+
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/AdminNotification/Test/Unit/Observer/PredispatchAdminActionControllerObserverTest.php b/app/code/Magento/AdminNotification/Test/Unit/Observer/PredispatchAdminActionControllerObserverTest.php
new file mode 100644
index 0000000000000..3209572ab0d70
--- /dev/null
+++ b/app/code/Magento/AdminNotification/Test/Unit/Observer/PredispatchAdminActionControllerObserverTest.php
@@ -0,0 +1,134 @@
+objectManager = new ObjectManager($this);
+ $this->observerMock = $this->createMock(Observer::class);
+
+ $this->backendAuthSessionMock = $this->getMockBuilder(Session::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['isLoggedIn'])
+ ->getMock();
+
+ $this->feedMock = $this->getMockBuilder(Feed::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['checkUpdate'])
+ ->getMock();
+
+ $this->feedFactoryMock = $this->getMockBuilder(FeedFactory::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['create'])
+ ->getMock();
+
+ $this->observer = $this->objectManager->getObject(
+ PredispatchAdminActionControllerObserver::class,
+ [
+ '_feedFactory' => $this->feedFactoryMock,
+ '_backendAuthSession' => $this->backendAuthSessionMock,
+ ]
+ );
+ }
+
+ /**
+ * Test observer when admin user is logged in
+ */
+ public function testPredispatchObserverWhenAdminLoggedIn()
+ {
+ $this->backendAuthSessionMock
+ ->expects($this->once())
+ ->method('isLoggedIn')
+ ->willReturn(self::STATUS_ADMIN_LOGGED_IN);
+
+ $this->feedFactoryMock
+ ->expects($this->once())
+ ->method('create')
+ ->willReturn($this->feedMock);
+
+ $this->feedMock
+ ->expects($this->once())
+ ->method('checkUpdate')
+ ->willReturn($this->feedMock);
+
+ $this->observer->execute($this->observerMock);
+ }
+
+ /**
+ * Test observer when admin user is not logged in
+ */
+ public function testPredispatchObserverWhenAdminIsNotLoggedIn()
+ {
+ $this->backendAuthSessionMock
+ ->expects($this->once())
+ ->method('isLoggedIn')
+ ->willReturn(self::STATUS_ADMIN_IS_NOT_LOGGED);
+
+ $this->feedFactoryMock
+ ->expects($this->never())
+ ->method('create');
+
+ $this->feedMock
+ ->expects($this->never())
+ ->method('checkUpdate');
+
+ $this->observer->execute($this->observerMock);
+ }
+}
diff --git a/app/code/Magento/AdvancedPricingImportExport/etc/module.xml b/app/code/Magento/AdvancedPricingImportExport/etc/module.xml
index 230fb17ae5544..ac7e6f860382b 100644
--- a/app/code/Magento/AdvancedPricingImportExport/etc/module.xml
+++ b/app/code/Magento/AdvancedPricingImportExport/etc/module.xml
@@ -6,6 +6,5 @@
*/
-->
-
-
+
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/Block/Adminhtml/System/Config/CollectionTimeLabel.php b/app/code/Magento/Analytics/Block/Adminhtml/System/Config/CollectionTimeLabel.php
index 34f2b7d53d9be..664278debd655 100644
--- a/app/code/Magento/Analytics/Block/Adminhtml/System/Config/CollectionTimeLabel.php
+++ b/app/code/Magento/Analytics/Block/Adminhtml/System/Config/CollectionTimeLabel.php
@@ -3,42 +3,47 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Block\Adminhtml\System\Config;
-use Magento\Framework\App\ObjectManager;
+use Magento\Backend\Block\Template\Context;
+use Magento\Config\Block\System\Config\Form\Field;
+use Magento\Framework\Data\Form\Element\AbstractElement;
+use Magento\Framework\Locale\ResolverInterface;
/**
* Provides label with default Time Zone
*/
-class CollectionTimeLabel extends \Magento\Config\Block\System\Config\Form\Field
+class CollectionTimeLabel extends Field
{
/**
- * @var \Magento\Framework\Locale\ResolverInterface
+ * @var ResolverInterface
*/
private $localeResolver;
/**
- * @param \Magento\Backend\Block\Template\Context $context
+ * @param Context $context
+ * @param ResolverInterface $localeResolver
* @param array $data
- * @param \Magento\Framework\Locale\ResolverInterface|null $localeResolver
*/
public function __construct(
- \Magento\Backend\Block\Template\Context $context,
- array $data = [],
- \Magento\Framework\Locale\ResolverInterface $localeResolver = null
+ Context $context,
+ ResolverInterface $localeResolver,
+ array $data = []
) {
- $this->localeResolver = $localeResolver ?:
- ObjectManager::getInstance()->get(\Magento\Framework\Locale\ResolverInterface::class);
parent::__construct($context, $data);
+ $this->localeResolver = $localeResolver;
}
/**
* Add current time zone to comment, properly translated according to locale
*
- * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
+ * @param AbstractElement $element
+ *
* @return string
*/
- public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
+ public function render(AbstractElement $element): string
{
$timeZoneCode = $this->_localeDate->getConfigTimezone();
$locale = $this->localeResolver->getLocale();
@@ -46,7 +51,7 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele
->getDisplayName(false, \IntlTimeZone::DISPLAY_LONG, $locale);
$element->setData(
'comment',
- sprintf("%s (%s)", $getLongTimeZoneName, $timeZoneCode)
+ sprintf('%s (%s)', $getLongTimeZoneName, $timeZoneCode)
);
return parent::render($element);
}
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/Model/Connector.php b/app/code/Magento/Analytics/Model/Connector.php
index 23b0ffa213b6e..c48f7f6b41946 100644
--- a/app/code/Magento/Analytics/Model/Connector.php
+++ b/app/code/Magento/Analytics/Model/Connector.php
@@ -53,7 +53,7 @@ public function __construct(
public function execute($commandName)
{
if (!array_key_exists($commandName, $this->commands)) {
- throw new NotFoundException(__('Command was not found.'));
+ throw new NotFoundException(__('Command "%1" was not found.', $commandName));
}
/** @var \Magento\Analytics\Model\Connector\CommandInterface $command */
diff --git a/app/code/Magento/Analytics/ReportXml/QueryFactory.php b/app/code/Magento/Analytics/ReportXml/QueryFactory.php
index 5da7adf794215..285ddb1f99e29 100644
--- a/app/code/Magento/Analytics/ReportXml/QueryFactory.php
+++ b/app/code/Magento/Analytics/ReportXml/QueryFactory.php
@@ -3,14 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Analytics\ReportXml;
use Magento\Analytics\ReportXml\DB\SelectBuilderFactory;
use Magento\Framework\App\CacheInterface;
+use Magento\Framework\DB\Select;
use Magento\Framework\ObjectManagerInterface;
+use Magento\Framework\Serialize\Serializer\Json;
/**
* Creates Query object according to configuration
+ *
* Factory for @see \Magento\Analytics\ReportXml\Query
*/
class QueryFactory
@@ -45,6 +49,11 @@ class QueryFactory
*/
private $selectHydrator;
+ /**
+ * @var Json
+ */
+ private $jsonSerializer;
+
/**
* QueryFactory constructor.
*
@@ -54,6 +63,7 @@ class QueryFactory
* @param SelectBuilderFactory $selectBuilderFactory
* @param Config $config
* @param array $assemblers
+ * @param Json $jsonSerializer
*/
public function __construct(
CacheInterface $queryCache,
@@ -61,7 +71,8 @@ public function __construct(
ObjectManagerInterface $objectManager,
SelectBuilderFactory $selectBuilderFactory,
Config $config,
- array $assemblers
+ array $assemblers,
+ Json $jsonSerializer
) {
$this->config = $config;
$this->selectBuilderFactory = $selectBuilderFactory;
@@ -69,6 +80,7 @@ public function __construct(
$this->queryCache = $queryCache;
$this->objectManager = $objectManager;
$this->selectHydrator = $selectHydrator;
+ $this->jsonSerializer = $jsonSerializer;
}
/**
@@ -101,14 +113,10 @@ private function constructQuery($queryName)
$selectBuilder = $assembler->assemble($selectBuilder, $queryConfig);
}
$select = $selectBuilder->create();
- return $this->objectManager->create(
- Query::class,
- [
- 'select' => $select,
- 'selectHydrator' => $this->selectHydrator,
- 'connectionName' => $selectBuilder->getConnectionName(),
- 'config' => $queryConfig
- ]
+ return $this->createQueryObject(
+ $select,
+ $selectBuilder->getConnectionName(),
+ $queryConfig
);
}
@@ -122,19 +130,42 @@ public function create($queryName)
{
$cached = $this->queryCache->load($queryName);
if ($cached) {
- $queryData = json_decode($cached, true);
- return $this->objectManager->create(
- Query::class,
- [
- 'select' => $this->selectHydrator->recreate($queryData['select_parts']),
- 'selectHydrator' => $this->selectHydrator,
- 'connectionName' => $queryData['connectionName'],
- 'config' => $queryData['config']
- ]
+ $queryData = $this->jsonSerializer->unserialize($cached);
+ return $this->createQueryObject(
+ $this->selectHydrator->recreate($queryData['select_parts']),
+ $queryData['connectionName'],
+ $queryData['config']
);
}
$query = $this->constructQuery($queryName);
- $this->queryCache->save(json_encode($query), $queryName);
+ $this->queryCache->save(
+ $this->jsonSerializer->serialize($query),
+ $queryName
+ );
return $query;
}
+
+ /**
+ * Create query class using objectmanger
+ *
+ * @param Select $select
+ * @param string $connection
+ * @param array $queryConfig
+ * @return Query
+ */
+ private function createQueryObject(
+ Select $select,
+ string $connection,
+ array $queryConfig
+ ) {
+ return $this->objectManager->create(
+ Query::class,
+ [
+ 'select' => $select,
+ 'selectHydrator' => $this->selectHydrator,
+ 'connectionName' => $connection,
+ 'config' => $queryConfig
+ ]
+ );
+ }
}
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 e660a2eb8d428..cbcbb3a5dd64c 100644
--- a/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingButtonTest.xml
+++ b/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingButtonTest.xml
@@ -22,10 +22,10 @@
-
+
-
+
@@ -35,4 +35,4 @@
-
\ No newline at end of file
+
diff --git a/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingNavigateMenuTest.xml b/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingNavigateMenuTest.xml
index d400bcf5f22fc..ee25e80fcab30 100644
--- a/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingNavigateMenuTest.xml
+++ b/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingNavigateMenuTest.xml
@@ -20,10 +20,10 @@
-
+
-
+
diff --git a/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationBlankIndustryTest.xml b/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationBlankIndustryTest.xml
index 914cb59b64e4e..17d463030d91c 100644
--- a/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationBlankIndustryTest.xml
+++ b/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationBlankIndustryTest.xml
@@ -18,9 +18,9 @@
-
+
-
+
diff --git a/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationEnableDisableAnalyticsTest.xml b/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationEnableDisableAnalyticsTest.xml
index 1c1a3b27b06af..b03488c240604 100644
--- a/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationEnableDisableAnalyticsTest.xml
+++ b/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationEnableDisableAnalyticsTest.xml
@@ -18,9 +18,9 @@
-
+
-
+
diff --git a/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationIndustryTest.xml b/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationIndustryTest.xml
index bb682c4468012..c19fddc6aa0ce 100644
--- a/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationIndustryTest.xml
+++ b/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationIndustryTest.xml
@@ -19,7 +19,7 @@
-
+
diff --git a/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationPermissionTest.xml b/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationPermissionTest.xml
index 58e809ec45c4a..40f80ce52c2de 100644
--- a/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationPermissionTest.xml
+++ b/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationPermissionTest.xml
@@ -21,10 +21,10 @@
-
+
-
+
@@ -35,8 +35,9 @@
-
+
+
@@ -51,7 +52,7 @@
-
+
diff --git a/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationTimeToSendDataTest.xml b/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationTimeToSendDataTest.xml
index 8ebd8cb594bee..6231b17c17b02 100644
--- a/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationTimeToSendDataTest.xml
+++ b/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationTimeToSendDataTest.xml
@@ -19,9 +19,9 @@
-
+
-
+
diff --git a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/CollectionTimeLabelTest.php b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/CollectionTimeLabelTest.php
index 08ee3c356937a..3a98fd6acbf4d 100644
--- a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/CollectionTimeLabelTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/CollectionTimeLabelTest.php
@@ -3,17 +3,25 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Block\Adminhtml\System\Config;
use Magento\Analytics\Block\Adminhtml\System\Config\CollectionTimeLabel;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\Data\Form;
use Magento\Framework\Data\Form\Element\AbstractElement;
+use Magento\Framework\Escaper;
use Magento\Framework\Locale\ResolverInterface;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class CollectionTimeLabelTest extends \PHPUnit\Framework\TestCase
+/**
+ * Test class for \Magento\Analytics\Block\Adminhtml\System\Config\CollectionTimeLabel
+ */
+class CollectionTimeLabelTest extends TestCase
{
/**
* @var CollectionTimeLabel
@@ -21,25 +29,33 @@ class CollectionTimeLabelTest extends \PHPUnit\Framework\TestCase
private $collectionTimeLabel;
/**
- * @var Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
private $contextMock;
/**
- * @var TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResolverInterface|MockObject
+ */
+ private $localeResolverMock;
+
+ /**
+ * @var Form|MockObject
+ */
+ private $formMock;
+
+ /**
+ * @var TimezoneInterface|MockObject
*/
private $timeZoneMock;
/**
- * @var AbstractElement|\PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractElement|MockObject
*/
private $abstractElementMock;
/**
- * @var ResolverInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @inheritDoc
*/
- private $localeResolver;
-
protected function setUp()
{
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)
@@ -48,7 +64,7 @@ protected function setUp()
->getMock();
$objectManager = new ObjectManager($this);
- $escaper = $objectManager->getObject(\Magento\Framework\Escaper::class);
+ $escaper = $objectManager->getObject(Escaper::class);
$reflection = new \ReflectionClass($this->abstractElementMock);
$reflection_property = $reflection->getProperty('_escaper');
$reflection_property->setAccessible(true);
@@ -64,35 +80,35 @@ protected function setUp()
$this->timeZoneMock = $this->getMockBuilder(TimezoneInterface::class)
->disableOriginalConstructor()
->getMock();
- $this->contextMock->expects($this->any())
- ->method('getLocaleDate')
+ $this->contextMock->method('getLocaleDate')
->willReturn($this->timeZoneMock);
- $this->localeResolver = $this->getMockBuilder(ResolverInterface::class)
+ $this->localeResolverMock = $this->getMockBuilder(ResolverInterface::class)
->disableOriginalConstructor()
->setMethods(['getLocale'])
->getMockForAbstractClass();
- $objectManager = new ObjectManager($this);
$this->collectionTimeLabel = $objectManager->getObject(
CollectionTimeLabel::class,
[
'context' => $this->contextMock,
- 'localeResolver' => $this->localeResolver
+ 'localeResolver' => $this->localeResolverMock
]
);
}
+ /**
+ * Test for \Magento\Analytics\Block\Adminhtml\System\Config\CollectionTimeLabel::render()
+ */
public function testRender()
{
- $timeZone = "America/New_York";
+ $timeZone = 'America/New_York';
$this->abstractElementMock->setForm($this->formMock);
$this->timeZoneMock->expects($this->once())
->method('getConfigTimezone')
->willReturn($timeZone);
- $this->abstractElementMock->expects($this->any())
- ->method('getComment')
+ $this->abstractElementMock->method('getComment')
->willReturn('Eastern Standard Time (America/New_York)');
- $this->localeResolver->expects($this->once())
+ $this->localeResolverMock->expects($this->once())
->method('getLocale')
->willReturn('en_US');
$this->assertRegExp(
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/Test/Unit/Model/ConnectorTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ConnectorTest.php
index 714d0daf5c419..90f6fa1643660 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/ConnectorTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/ConnectorTest.php
@@ -57,9 +57,13 @@ public function testExecute()
}
/**
+ * Executing non-existing command
+ *
* @expectedException \Magento\Framework\Exception\NotFoundException
+ * @expectedExceptionMessage Command "register" was not found.
+ * @return void
*/
- public function testExecuteCommandNotFound()
+ public function testExecuteCommandNotFound(): void
{
$commandName = 'register';
$this->connector->execute($commandName);
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryFactoryTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryFactoryTest.php
index 9a3805a50f167..032ef1e107825 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryFactoryTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryFactoryTest.php
@@ -3,161 +3,171 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\ReportXml;
+use Magento\Analytics\ReportXml\QueryFactory;
+use Magento\Analytics\ReportXml\Query;
+use Magento\Analytics\ReportXml\Config;
+use Magento\Framework\DB\Select;
+use Magento\Analytics\ReportXml\DB\Assembler\AssemblerInterface;
+use Magento\Framework\App\CacheInterface;
+use Magento\Framework\ObjectManagerInterface;
+use Magento\Analytics\ReportXml\SelectHydrator;
+use Magento\Analytics\ReportXml\DB\SelectBuilder;
+use Magento\Analytics\ReportXml\DB\SelectBuilderFactory;
+use Magento\Framework\Serialize\Serializer\Json;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* A unit test for testing of the query factory.
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class QueryFactoryTest extends \PHPUnit\Framework\TestCase
+class QueryFactoryTest extends TestCase
{
+ const STUB_QUERY_NAME = 'test_query';
+ const STUB_CONNECTION = 'default';
+
/**
- * @var \Magento\Analytics\ReportXml\QueryFactory
+ * @var QueryFactory
*/
private $subject;
/**
- * @var \Magento\Analytics\ReportXml\Query|\PHPUnit_Framework_MockObject_MockObject
+ * @var Query|MockObject
*/
private $queryMock;
/**
- * @var \Magento\Analytics\ReportXml\Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
private $configMock;
/**
- * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject
+ * @var Select|MockObject
*/
private $selectMock;
/**
- * @var \Magento\Analytics\ReportXml\DB\Assembler\AssemblerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AssemblerInterface|MockObject
*/
private $assemblerMock;
/**
- * @var \Magento\Framework\App\CacheInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var CacheInterface|MockObject
*/
private $queryCacheMock;
/**
- * @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ObjectManagerInterface|MockObject
*/
private $objectManagerMock;
/**
- * @var \Magento\Analytics\ReportXml\SelectHydrator|\PHPUnit_Framework_MockObject_MockObject
+ * @var SelectHydrator|MockObject
*/
private $selectHydratorMock;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManagerHelper
*/
private $objectManagerHelper;
/**
- * @var \Magento\Analytics\ReportXml\DB\SelectBuilderFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var SelectBuilderFactory|MockObject
*/
private $selectBuilderFactoryMock;
+ /**
+ * @var Json|MockObject
+ */
+ private $jsonSerializerMock;
+
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->queryMock = $this->getMockBuilder(
- \Magento\Analytics\ReportXml\Query::class
- )
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->configMock = $this->getMockBuilder(
- \Magento\Analytics\ReportXml\Config::class
- )
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->selectMock = $this->getMockBuilder(
- \Magento\Framework\DB\Select::class
- )
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->assemblerMock = $this->getMockBuilder(
- \Magento\Analytics\ReportXml\DB\Assembler\AssemblerInterface::class
- )
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->queryCacheMock = $this->getMockBuilder(
- \Magento\Framework\App\CacheInterface::class
- )
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->objectManagerMock = $this->getMockBuilder(
- \Magento\Framework\ObjectManagerInterface::class
- )
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->selectHydratorMock = $this->getMockBuilder(
- \Magento\Analytics\ReportXml\SelectHydrator::class
- )
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->selectBuilderFactoryMock = $this->getMockBuilder(
- \Magento\Analytics\ReportXml\DB\SelectBuilderFactory::class
- )
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->objectManagerHelper =
- new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->queryMock = $this->getMockBuilder(Query::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->configMock = $this->getMockBuilder(Config::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->selectMock = $this->getMockBuilder(Select::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->assemblerMock = $this->getMockBuilder(AssemblerInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->queryCacheMock = $this->getMockBuilder(CacheInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->selectHydratorMock = $this->getMockBuilder(SelectHydrator::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->selectBuilderFactoryMock = $this->getMockBuilder(SelectBuilderFactory::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->jsonSerializerMock = $this->createMock(Json::class);
+
+ $this->objectManagerHelper = new ObjectManagerHelper($this);
$this->subject = $this->objectManagerHelper->getObject(
- \Magento\Analytics\ReportXml\QueryFactory::class,
+ QueryFactory::class,
[
- 'config' => $this->configMock,
- 'selectBuilderFactory' => $this->selectBuilderFactoryMock,
- 'assemblers' => [$this->assemblerMock],
'queryCache' => $this->queryCacheMock,
+ 'selectHydrator' => $this->selectHydratorMock,
'objectManager' => $this->objectManagerMock,
- 'selectHydrator' => $this->selectHydratorMock
+ 'selectBuilderFactory' => $this->selectBuilderFactoryMock,
+ 'config' => $this->configMock,
+ 'assemblers' => [$this->assemblerMock],
+ 'jsonSerializer' => $this->jsonSerializerMock
]
);
}
/**
+ * Test create() if query cached
+ *
* @return void
+ * @dataProvider queryDataProvider
*/
- public function testCreateCached()
+ public function testCreateIfQueryCached(array $queryDataMock, string $jsonEncodeData): void
{
- $queryName = 'test_query';
+ $queryConfigMock = $queryDataMock['config'];
+ $queryName = $queryConfigMock['name'];
$this->queryCacheMock->expects($this->any())
->method('load')
->with($queryName)
- ->willReturn('{"connectionName":"sales","config":{},"select_parts":{}}');
+ ->willReturn($jsonEncodeData);
+
+ $this->jsonSerializerMock->expects($this->once())
+ ->method('unserialize')
+ ->willReturn($queryDataMock);
$this->selectHydratorMock->expects($this->any())
->method('recreate')
->with([])
->willReturn($this->selectMock);
- $this->objectManagerMock->expects($this->once())
- ->method('create')
- ->with(
- \Magento\Analytics\ReportXml\Query::class,
- [
- 'select' => $this->selectMock,
- 'selectHydrator' => $this->selectHydratorMock,
- 'connectionName' => 'sales',
- 'config' => []
- ]
- )
- ->willReturn($this->queryMock);
+ $this->createQueryObjectMock($queryDataMock);
$this->queryCacheMock->expects($this->never())
->method('save');
@@ -169,22 +179,19 @@ public function testCreateCached()
}
/**
+ * Test create() if query not cached
+ *
* @return void
+ * @dataProvider queryDataProvider
*/
- public function testCreateNotCached()
+ public function testCreateIfQueryNotCached(array $queryDataMock, string $jsonEncodeData): void
{
- $queryName = 'test_query';
-
- $queryConfigMock = [
- 'name' => 'test_query',
- 'connection' => 'sales'
- ];
+ $queryConfigMock = $queryDataMock['config'];
+ $queryName = $queryConfigMock['name'];
- $selectBuilderMock = $this->getMockBuilder(
- \Magento\Analytics\ReportXml\DB\SelectBuilder::class
- )
- ->disableOriginalConstructor()
- ->getMock();
+ $selectBuilderMock = $this->getMockBuilder(SelectBuilder::class)
+ ->disableOriginalConstructor()
+ ->getMock();
$selectBuilderMock->expects($this->once())
->method('setConnectionName')
->with($queryConfigMock['connection']);
@@ -214,26 +221,65 @@ public function testCreateNotCached()
->with($selectBuilderMock, $queryConfigMock)
->willReturn($selectBuilderMock);
+ $this->createQueryObjectMock($queryDataMock);
+
+ $this->jsonSerializerMock->expects($this->once())
+ ->method('serialize')
+ ->willReturn($jsonEncodeData);
+
+ $this->queryCacheMock->expects($this->once())
+ ->method('save')
+ ->with($jsonEncodeData, $queryName);
+
+ $this->assertEquals(
+ $this->queryMock,
+ $this->subject->create($queryName)
+ );
+ }
+
+ /**
+ * Get Query Data Provider
+ *
+ * @return array
+ */
+ public function queryDataProvider(): array
+ {
+ return [
+ [
+ 'getQueryDataMock' => [
+ 'connectionName' => self::STUB_CONNECTION,
+ 'config' => [
+ 'name' => self::STUB_QUERY_NAME,
+ 'connection' => self::STUB_CONNECTION
+ ],
+ 'select_parts' => []
+ ],
+ 'getQueryDataJsonEncodeMock' => '{"connectionName":"default",'.
+ '"config":{"name":"test_query",'.
+ '"connection":"default"},"select_parts":[]}'
+ ]
+ ];
+ }
+
+ /**
+ * ObjectManager Mock with Query class
+ *
+ * @param array $queryDataMock
+ * @return void
+ */
+ private function createQueryObjectMock($queryDataMock): void
+ {
$this->objectManagerMock->expects($this->once())
->method('create')
->with(
- \Magento\Analytics\ReportXml\Query::class,
+ Query::class,
[
'select' => $this->selectMock,
'selectHydrator' => $this->selectHydratorMock,
- 'connectionName' => $queryConfigMock['connection'],
- 'config' => $queryConfigMock
+ 'connectionName' => $queryDataMock['connectionName'],
+ 'config' => $queryDataMock['config']
]
)
->willReturn($this->queryMock);
-
- $this->queryCacheMock->expects($this->once())
- ->method('save')
- ->with(json_encode($this->queryMock), $queryName);
-
- $this->assertEquals(
- $this->queryMock,
- $this->subject->create($queryName)
- );
}
}
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 @@
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
+
diff --git a/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertOrderGraphImageOnDashboardActionGroup.xml b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertOrderGraphImageOnDashboardActionGroup.xml
index 3e3b0bc6a8a43..4be01fda862f8 100644
--- a/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertOrderGraphImageOnDashboardActionGroup.xml
+++ b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertOrderGraphImageOnDashboardActionGroup.xml
@@ -10,6 +10,6 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
-
+
diff --git a/app/code/Magento/Backend/Test/Mftf/ActionGroup/LoginActionGroup.xml b/app/code/Magento/Backend/Test/Mftf/ActionGroup/LoginActionGroup.xml
deleted file mode 100644
index 7068478bb4790..0000000000000
--- a/app/code/Magento/Backend/Test/Mftf/ActionGroup/LoginActionGroup.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
- Login to Backend Admin using ENV Admin credentials. PLEASE NOTE: This Action Group does NOT validate that you are Logged In.
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Backend/Test/Mftf/ActionGroup/LoginAdminWithCredentialsActionGroup.xml b/app/code/Magento/Backend/Test/Mftf/ActionGroup/LoginAdminWithCredentialsActionGroup.xml
deleted file mode 100644
index 995a5e7130e0a..0000000000000
--- a/app/code/Magento/Backend/Test/Mftf/ActionGroup/LoginAdminWithCredentialsActionGroup.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
- Login to Backend Admin using provided Admin credentials. PLEASE NOTE: This Action Group does NOT validate that you are Logged In.
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Backend/Test/Mftf/ActionGroup/LoginAsAdminActionGroup.xml b/app/code/Magento/Backend/Test/Mftf/ActionGroup/LoginAsAdminActionGroup.xml
deleted file mode 100644
index 7e1dfe4cf381b..0000000000000
--- a/app/code/Magento/Backend/Test/Mftf/ActionGroup/LoginAsAdminActionGroup.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
- Login to Backend Admin using provided User Data. PLEASE NOTE: This Action Group does NOT validate that you are Logged In.
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Backend/Test/Mftf/ActionGroup/LogoutActionGroup.xml b/app/code/Magento/Backend/Test/Mftf/ActionGroup/LogoutActionGroup.xml
deleted file mode 100644
index 4c265d08dd041..0000000000000
--- a/app/code/Magento/Backend/Test/Mftf/ActionGroup/LogoutActionGroup.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
- Logout of the Backend Admin. PLEASE NOTE: This Action Group does NOT validate that you are Logged Out.
-
-
-
-
-
diff --git a/app/code/Magento/Backend/Test/Mftf/Data/AdminGeneralStoreInfomationConfigData.xml b/app/code/Magento/Backend/Test/Mftf/Data/AdminGeneralStoreInfomationConfigData.xml
index a8db2f94d69ab..2c50bc0fc75f4 100644
--- a/app/code/Magento/Backend/Test/Mftf/Data/AdminGeneralStoreInfomationConfigData.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Data/AdminGeneralStoreInfomationConfigData.xml
@@ -30,4 +30,11 @@
general/store_information/street_line2
+
+ general/store_information/region_id
+
+
+ general/store_information/hours
+ 8AM-8PM
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Page/AdminConfigurationPersistentShoppingCartPage.xml b/app/code/Magento/Backend/Test/Mftf/Page/AdminConfigurationPersistentShoppingCartPage.xml
new file mode 100644
index 0000000000000..f7e579c57e21c
--- /dev/null
+++ b/app/code/Magento/Backend/Test/Mftf/Page/AdminConfigurationPersistentShoppingCartPage.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Page/AdminConfigurationStoresPage.xml b/app/code/Magento/Backend/Test/Mftf/Page/AdminConfigurationStoresPage.xml
deleted file mode 100644
index 8afc2c5bbb32f..0000000000000
--- a/app/code/Magento/Backend/Test/Mftf/Page/AdminConfigurationStoresPage.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Backend/Test/Mftf/Page/AdminConfigurationStoresPage/ConfigurationStoresPage.xml b/app/code/Magento/Backend/Test/Mftf/Page/AdminConfigurationStoresPage/ConfigurationStoresPage.xml
new file mode 100644
index 0000000000000..81eb04692cc57
--- /dev/null
+++ b/app/code/Magento/Backend/Test/Mftf/Page/AdminConfigurationStoresPage/ConfigurationStoresPage.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Page/AdminConfigurationStoresPage/GeneralConfigurationPage.xml b/app/code/Magento/Backend/Test/Mftf/Page/AdminConfigurationStoresPage/GeneralConfigurationPage.xml
new file mode 100644
index 0000000000000..59b461fb08a4d
--- /dev/null
+++ b/app/code/Magento/Backend/Test/Mftf/Page/AdminConfigurationStoresPage/GeneralConfigurationPage.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Page/AdminConfigurationStoresPage/WebConfigurationPage.xml b/app/code/Magento/Backend/Test/Mftf/Page/AdminConfigurationStoresPage/WebConfigurationPage.xml
new file mode 100644
index 0000000000000..b5429b091d755
--- /dev/null
+++ b/app/code/Magento/Backend/Test/Mftf/Page/AdminConfigurationStoresPage/WebConfigurationPage.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Page/AdminSetupWizardPage.xml b/app/code/Magento/Backend/Test/Mftf/Page/AdminSetupWizardPage.xml
new file mode 100644
index 0000000000000..40076ccd42b3a
--- /dev/null
+++ b/app/code/Magento/Backend/Test/Mftf/Page/AdminSetupWizardPage.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Section/AdminDashboardSection.xml b/app/code/Magento/Backend/Test/Mftf/Section/AdminDashboardSection.xml
index 61fe7ffa48e23..e67025cfa68d5 100644
--- a/app/code/Magento/Backend/Test/Mftf/Section/AdminDashboardSection.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Section/AdminDashboardSection.xml
@@ -10,7 +10,7 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
-
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Section/AdminMenuSection.xml b/app/code/Magento/Backend/Test/Mftf/Section/AdminMenuSection.xml
index 8498ad8c52e41..e6782dca897d7 100644
--- a/app/code/Magento/Backend/Test/Mftf/Section/AdminMenuSection.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Section/AdminMenuSection.xml
@@ -9,6 +9,7 @@
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml b/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml
index bb1123d01c867..7983554051f89 100644
--- a/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml
@@ -9,6 +9,8 @@
+
+
@@ -16,8 +18,7 @@
-
-
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminAttributeTextSwatchesCanBeFiledTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminAttributeTextSwatchesCanBeFiledTest.xml
index 2c061e54f5509..8ac7af096da0a 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminAttributeTextSwatchesCanBeFiledTest.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminAttributeTextSwatchesCanBeFiledTest.xml
@@ -22,7 +22,7 @@
-
+
@@ -58,7 +58,7 @@
-
+
@@ -110,7 +110,11 @@
-
-
+
+ $grabSwatchForAdmin
+
+
+ $grabDescriptionForAdmin
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminCheckLocaleAndDeveloperConfigInDeveloperModeTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminCheckLocaleAndDeveloperConfigInDeveloperModeTest.xml
index 47b8715b5541c..cbe0f0b5f4fe9 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminCheckLocaleAndDeveloperConfigInDeveloperModeTest.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminCheckLocaleAndDeveloperConfigInDeveloperModeTest.xml
@@ -21,7 +21,7 @@
-
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminCheckLocaleAndDeveloperConfigInProductionModeTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminCheckLocaleAndDeveloperConfigInProductionModeTest.xml
index ae7722b225cdd..323ae324d4950 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminCheckLocaleAndDeveloperConfigInProductionModeTest.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminCheckLocaleAndDeveloperConfigInProductionModeTest.xml
@@ -21,14 +21,16 @@
-
+
-
+
+
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminContentScheduleNavigateMenuTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminContentScheduleNavigateMenuTest.xml
index bead59653eee8..8ae6d6de79c0b 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminContentScheduleNavigateMenuTest.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminContentScheduleNavigateMenuTest.xml
@@ -20,10 +20,10 @@
-
+
-
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardNavigateMenuTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardNavigateMenuTest.xml
index 6434d74b28754..efcc6da30199a 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardNavigateMenuTest.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardNavigateMenuTest.xml
@@ -20,10 +20,10 @@
-
+
-
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardWithChartsChart.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardWithChartsChart.xml
index 3ba965f746722..972947656cd3d 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardWithChartsChart.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardWithChartsChart.xml
@@ -28,6 +28,7 @@
John1
Doe1
+
@@ -37,11 +38,11 @@
-
+
-
+
@@ -82,8 +83,8 @@
-
-
+
+
@@ -94,8 +95,7 @@
-
-
+
@@ -120,6 +120,9 @@
-
+
+ $grabEndQuantity
+ $grabStartQuantity
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireAdminSessionTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireAdminSessionTest.xml
index 88d26c052b59b..2469151337bfe 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireAdminSessionTest.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireAdminSessionTest.xml
@@ -27,7 +27,7 @@
-
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireCustomerSessionTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireCustomerSessionTest.xml
index 88646401e3a99..0e3bf07d32441 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireCustomerSessionTest.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireCustomerSessionTest.xml
@@ -24,10 +24,10 @@
-
+
-
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginAfterChangeCookieDomainTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginAfterChangeCookieDomainTest.xml
index 93d411c8827ed..be734205e1f5b 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginAfterChangeCookieDomainTest.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginAfterChangeCookieDomainTest.xml
@@ -27,8 +27,8 @@
-
+
-
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginAfterJSMinificationTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginAfterJSMinificationTest.xml
index 5550e3b317b0d..d2c628ed13701 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginAfterJSMinificationTest.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginAfterJSMinificationTest.xml
@@ -22,11 +22,11 @@
-
+
-
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginFailedTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginFailedTest.xml
new file mode 100644
index 0000000000000..1239fc471f59e
--- /dev/null
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginFailedTest.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginSuccessfulTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginSuccessfulTest.xml
new file mode 100644
index 0000000000000..a8de04f4342de
--- /dev/null
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginSuccessfulTest.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginTest.xml
deleted file mode 100644
index ce33f01c60141..0000000000000
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginTest.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginWithRestrictPermissionTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginWithRestrictPermissionTest.xml
index e664a4a5f3e2f..b3797b0720400 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginWithRestrictPermissionTest.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginWithRestrictPermissionTest.xml
@@ -20,16 +20,16 @@
-
+
-
+
-
+
@@ -39,8 +39,8 @@
-
-
+
+
@@ -52,9 +52,10 @@
-
-
-
+
+
+
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminMenuNavigationWithSecretKeysTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminMenuNavigationWithSecretKeysTest.xml
index c9a3b8089cc1d..812158948d85f 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminMenuNavigationWithSecretKeysTest.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminMenuNavigationWithSecretKeysTest.xml
@@ -21,12 +21,12 @@
-
+
-
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminPersistentShoppingCartSettingsTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminPersistentShoppingCartSettingsTest.xml
new file mode 100644
index 0000000000000..cf1ed2d63034f
--- /dev/null
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminPersistentShoppingCartSettingsTest.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminPrivacyPolicyTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminPrivacyPolicyTest.xml
index 4f215d20a7a36..b0fbdb8b5b596 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminPrivacyPolicyTest.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminPrivacyPolicyTest.xml
@@ -21,7 +21,7 @@
-
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminRedirectToAdminPanelOnLogoClickFromWizardPageTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminRedirectToAdminPanelOnLogoClickFromWizardPageTest.xml
new file mode 100644
index 0000000000000..bf74674a2c9c8
--- /dev/null
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminRedirectToAdminPanelOnLogoClickFromWizardPageTest.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminStoresAllStoresNavigateMenuTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminStoresAllStoresNavigateMenuTest.xml
index 7758b387e393b..97fdcdf9596a3 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminStoresAllStoresNavigateMenuTest.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminStoresAllStoresNavigateMenuTest.xml
@@ -20,10 +20,10 @@
-
+
-
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminStoresConfigurationNavigateMenuTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminStoresConfigurationNavigateMenuTest.xml
index a54269b186ba0..39b08eeb2e42a 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminStoresConfigurationNavigateMenuTest.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminStoresConfigurationNavigateMenuTest.xml
@@ -20,10 +20,10 @@
-
+
-
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminSystemCacheManagementNavigateMenuTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminSystemCacheManagementNavigateMenuTest.xml
index 516631c1bd166..81fef1afc282c 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminSystemCacheManagementNavigateMenuTest.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminSystemCacheManagementNavigateMenuTest.xml
@@ -20,10 +20,10 @@
-
+
-
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminUserLoginWithStoreCodeInUrlTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminUserLoginWithStoreCodeInUrlTest.xml
index df5ca6d037813..e9050fa3ccd6e 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminUserLoginWithStoreCodeInUrlTest.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminUserLoginWithStoreCodeInUrlTest.xml
@@ -26,7 +26,7 @@
-
+
diff --git a/app/code/Magento/Backend/Test/Unit/App/Area/FrontNameResolverTest.php b/app/code/Magento/Backend/Test/Unit/App/Area/FrontNameResolverTest.php
index ba0b01d4055de..9483de741f169 100644
--- a/app/code/Magento/Backend/Test/Unit/App/Area/FrontNameResolverTest.php
+++ b/app/code/Magento/Backend/Test/Unit/App/Area/FrontNameResolverTest.php
@@ -29,7 +29,7 @@ class FrontNameResolverTest extends \PHPUnit\Framework\TestCase
protected $scopeConfigMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Zend\Uri\Uri
+ * @var \PHPUnit_Framework_MockObject_MockObject|\Laminas\Uri\Uri
*/
protected $uri;
@@ -51,7 +51,7 @@ protected function setUp()
->method('get')
->with(ConfigOptionsList::CONFIG_PATH_BACKEND_FRONTNAME)
->will($this->returnValue($this->_defaultFrontName));
- $this->uri = $this->createMock(\Zend\Uri\Uri::class);
+ $this->uri = $this->createMock(\Laminas\Uri\Uri::class);
$this->request = $this->createMock(\Magento\Framework\App\Request\Http::class);
diff --git a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/TunnelTest.php b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/TunnelTest.php
deleted file mode 100644
index b7713078863cb..0000000000000
--- a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/TunnelTest.php
+++ /dev/null
@@ -1,196 +0,0 @@
-_request = $this->createMock(\Magento\Framework\App\Request\Http::class);
- $this->_response = $this->createMock(\Magento\Framework\App\Response\Http::class);
- $this->_objectManager = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
- }
-
- protected function tearDown()
- {
- $this->_request = null;
- $this->_response = null;
- $this->_objectManager = null;
- }
-
- public function testTunnelAction()
- {
- $fixture = uniqid();
- $this->_request->expects($this->at(0))
- ->method('getParam')
- ->with('ga')
- ->will($this->returnValue(urlencode(base64_encode(json_encode([1])))));
- $this->_request->expects($this->at(1))->method('getParam')->with('h')->will($this->returnValue($fixture));
- $tunnelResponse = $this->createMock(\Magento\Framework\App\Response\Http::class);
- $httpClient = $this->createPartialMock(
- \Magento\Framework\HTTP\ZendClient::class,
- ['setUri', 'setParameterGet', 'setConfig', 'request', 'getHeaders']
- );
- /** @var $helper \Magento\Backend\Helper\Dashboard\Data|\PHPUnit_Framework_MockObject_MockObject */
- $helper = $this->createPartialMock(\Magento\Backend\Helper\Dashboard\Data::class, ['getChartDataHash']);
- $helper->expects($this->any())->method('getChartDataHash')->will($this->returnValue($fixture));
-
- $this->_objectManager->expects($this->at(0))
- ->method('get')
- ->with(\Magento\Backend\Helper\Dashboard\Data::class)
- ->will($this->returnValue($helper));
- $this->_objectManager->expects($this->at(1))
- ->method('create')
- ->with(\Magento\Framework\HTTP\ZendClient::class)
- ->will($this->returnValue($httpClient));
- $httpClient->expects($this->once())->method('setUri')->will($this->returnValue($httpClient));
- $httpClient->expects($this->once())->method('setParameterGet')->will($this->returnValue($httpClient));
- $httpClient->expects($this->once())->method('setConfig')->will($this->returnValue($httpClient));
- $httpClient->expects($this->once())->method('request')->with('GET')->will($this->returnValue($tunnelResponse));
- $tunnelResponse->expects($this->any())->method('getHeaders')
- ->will($this->returnValue(['Content-type' => 'test_header']));
- $tunnelResponse->expects($this->any())->method('getBody')->will($this->returnValue('success_msg'));
- $this->_response->expects($this->any())->method('getBody')->will($this->returnValue('success_msg'));
-
- $controller = $this->_factory($this->_request, $this->_response);
- $this->resultRaw->expects($this->once())
- ->method('setHeader')
- ->with('Content-type', 'test_header')
- ->willReturnSelf();
- $this->resultRaw->expects($this->once())
- ->method('setContents')
- ->with('success_msg')
- ->willReturnSelf();
-
- $controller->execute();
- $this->assertEquals('success_msg', $controller->getResponse()->getBody());
- }
-
- public function testTunnelAction400()
- {
- $controller = $this->_factory($this->_request, $this->_response);
-
- $this->resultRaw->expects($this->once())
- ->method('setHeader')
- ->willReturnSelf();
- $this->resultRaw->expects($this->once())
- ->method('setHttpResponseCode')
- ->with(400)
- ->willReturnSelf();
- $this->resultRaw->expects($this->once())
- ->method('setContents')
- ->with('Service unavailable: invalid request')
- ->willReturnSelf();
-
- $controller->execute();
- }
-
- public function testTunnelAction503()
- {
- $fixture = uniqid();
- $this->_request->expects($this->at(0))
- ->method('getParam')
- ->with('ga')
- ->will($this->returnValue(urlencode(base64_encode(json_encode([1])))));
- $this->_request->expects($this->at(1))->method('getParam')->with('h')->will($this->returnValue($fixture));
- /** @var $helper \Magento\Backend\Helper\Dashboard\Data|\PHPUnit_Framework_MockObject_MockObject */
- $helper = $this->createPartialMock(\Magento\Backend\Helper\Dashboard\Data::class, ['getChartDataHash']);
- $helper->expects($this->any())->method('getChartDataHash')->will($this->returnValue($fixture));
-
- $this->_objectManager->expects($this->at(0))
- ->method('get')
- ->with(\Magento\Backend\Helper\Dashboard\Data::class)
- ->will($this->returnValue($helper));
- $exceptionMock = new \Exception();
- $this->_objectManager->expects($this->at(1))
- ->method('create')
- ->with(\Magento\Framework\HTTP\ZendClient::class)
- ->will($this->throwException($exceptionMock));
- $loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class);
- $loggerMock->expects($this->once())->method('critical')->with($exceptionMock);
- $this->_objectManager->expects($this->at(2))
- ->method('get')
- ->with(\Psr\Log\LoggerInterface::class)
- ->will($this->returnValue($loggerMock));
-
- $controller = $this->_factory($this->_request, $this->_response);
-
- $this->resultRaw->expects($this->once())
- ->method('setHeader')
- ->willReturnSelf();
- $this->resultRaw->expects($this->once())
- ->method('setHttpResponseCode')
- ->with(503)
- ->willReturnSelf();
- $this->resultRaw->expects($this->once())
- ->method('setContents')
- ->with('Service unavailable: see error log for details')
- ->willReturnSelf();
-
- $controller->execute();
- }
-
- /**
- * Create the tested object
- *
- * @param \Magento\Framework\App\Request\Http $request
- * @param \Magento\Framework\App\Response\Http|null $response
- * @return \Magento\Backend\Controller\Adminhtml\Dashboard|\PHPUnit_Framework_MockObject_MockObject
- */
- protected function _factory($request, $response = null)
- {
- if (!$response) {
- /** @var $response \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject */
- $response = $this->createMock(\Magento\Framework\App\Response\Http::class);
- $response->headersSentThrowsException = false;
- }
- $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $varienFront = $helper->getObject(\Magento\Framework\App\FrontController::class);
-
- $arguments = [
- 'request' => $request,
- 'response' => $response,
- 'objectManager' => $this->_objectManager,
- 'frontController' => $varienFront,
- ];
- $this->resultRaw = $this->getMockBuilder(\Magento\Framework\Controller\Result\Raw::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $resultRawFactory = $this->getMockBuilder(\Magento\Framework\Controller\Result\RawFactory::class)
- ->disableOriginalConstructor()
- ->setMethods(['create'])
- ->getMock();
- $resultRawFactory->expects($this->atLeastOnce())
- ->method('create')
- ->willReturn($this->resultRaw);
- $context = $helper->getObject(\Magento\Backend\App\Action\Context::class, $arguments);
- return new \Magento\Backend\Controller\Adminhtml\Dashboard\Tunnel($context, $resultRawFactory);
- }
-}
diff --git a/app/code/Magento/Backend/Test/Unit/Helper/Dashboard/DataTest.php b/app/code/Magento/Backend/Test/Unit/Helper/Dashboard/DataTest.php
index 21c72cb6b4477..7943c5e7fdcb1 100644
--- a/app/code/Magento/Backend/Test/Unit/Helper/Dashboard/DataTest.php
+++ b/app/code/Magento/Backend/Test/Unit/Helper/Dashboard/DataTest.php
@@ -3,7 +3,6 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-
declare(strict_types=1);
namespace Magento\Backend\Test\Unit\Helper\Dashboard;
@@ -31,7 +30,7 @@ class DataTest extends TestCase
private const STUB_CHART_DATA_HASH = '52870842b23068a78220e01eb9d4404d';
/**
- * @var \Magento\Backend\Helper\Dashboard\Data
+ * @var HelperData
*/
private $helper;
@@ -54,7 +53,7 @@ protected function setUp()
$this->deploymentConfigMock = $this->createMock(DeploymentConfig::class);
$this->deploymentConfigMock->expects($this->once())->method('get')
->with(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE)
- ->will($this->returnValue(self::STUB_PATH_INSTALL));
+ ->willReturn(self::STUB_PATH_INSTALL);
$objectManager = new ObjectManager($this);
$this->helper = $objectManager->getObject(
@@ -81,23 +80,6 @@ public function testGetStoresWhenStoreAttributeIsNull()
$this->assertEquals($storeCollectionMock, $this->helper->getStores());
}
- /**
- * Test getDatePeriods() method
- */
- public function testGetDatePeriods()
- {
- $this->assertEquals(
- [
- '24h' => (string)__('Last 24 Hours'),
- '7d' => (string)__('Last 7 Days'),
- '1m' => (string)__('Current Month'),
- '1y' => (string)__('YTD'),
- '2y' => (string)__('2YTD')
- ],
- $this->helper->getDatePeriods()
- );
- }
-
/**
* Test getChartDataHash() method
*/
diff --git a/app/code/Magento/Backend/Test/Unit/Model/Dashboard/ChartTest.php b/app/code/Magento/Backend/Test/Unit/Model/Dashboard/ChartTest.php
new file mode 100644
index 0000000000000..fadd9e170e0b0
--- /dev/null
+++ b/app/code/Magento/Backend/Test/Unit/Model/Dashboard/ChartTest.php
@@ -0,0 +1,203 @@
+objectManagerHelper = new ObjectManager($this);
+
+ $this->dateRetrieverMock = $this->getMockBuilder(DateRetriever::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->orderHelperMock = $this->getMockBuilder(OrderHelper::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->collectionMock = $this->getMockBuilder(Collection::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->orderHelperMock->method('getCollection')
+ ->willReturn($this->collectionMock);
+
+ $period = $this->objectManagerHelper->getObject(Period::class);
+
+ $this->model = $this->objectManagerHelper->getObject(
+ Chart::class,
+ [
+ 'dateRetriever' => $this->dateRetrieverMock,
+ 'orderHelper' => $this->orderHelperMock,
+ 'period' => $period
+ ]
+ );
+ }
+
+ /**
+ * @param string $period
+ * @param string $chartParam
+ * @param array $result
+ * @dataProvider getByPeriodDataProvider
+ */
+ public function testGetByPeriod($period, $chartParam, $result)
+ {
+ $this->orderHelperMock->expects($this->at(0))
+ ->method('setParam')
+ ->with('store', null);
+ $this->orderHelperMock->expects($this->at(1))
+ ->method('setParam')
+ ->with('website', null);
+ $this->orderHelperMock->expects($this->at(2))
+ ->method('setParam')
+ ->with('group', null);
+ $this->orderHelperMock->expects($this->at(3))
+ ->method('setParam')
+ ->with('period', $period);
+
+ $this->dateRetrieverMock->expects($this->once())
+ ->method('getByPeriod')
+ ->with($period)
+ ->willReturn(array_map(static function ($item) {
+ return $item['x'];
+ }, $result));
+
+ $this->collectionMock->method('count')
+ ->willReturn(2);
+
+ $valueMap = [];
+ foreach ($result as $resultItem) {
+ $dataObjectMock = $this->getMockBuilder(DataObject::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $dataObjectMock->method('getData')
+ ->with($chartParam)
+ ->willReturn($resultItem['y']);
+
+ $valueMap[] = [
+ 'range',
+ $resultItem['x'],
+ $dataObjectMock
+ ];
+ }
+ $this->collectionMock->method('getItemByColumnValue')
+ ->willReturnMap($valueMap);
+
+ $this->assertEquals(
+ $result,
+ $this->model->getByPeriod($period, $chartParam)
+ );
+ }
+
+ public function getByPeriodDataProvider(): array
+ {
+ return [
+ [
+ Period::PERIOD_7_DAYS,
+ 'revenue',
+ [
+ [
+ 'x' => '2020-01-21',
+ 'y' => 0
+ ],
+ [
+ 'x' => '2020-01-22',
+ 'y' => 2
+ ],
+ [
+ 'x' => '2020-01-23',
+ 'y' => 0
+ ],
+ [
+ 'x' => '2020-01-24',
+ 'y' => 7
+ ]
+ ]
+ ],
+ [
+ Period::PERIOD_1_MONTH,
+ 'quantity',
+ [
+ [
+ 'x' => '2020-01-21',
+ 'y' => 0
+ ],
+ [
+ 'x' => '2020-01-22',
+ 'y' => 2
+ ],
+ [
+ 'x' => '2020-01-23',
+ 'y' => 0
+ ],
+ [
+ 'x' => '2020-01-24',
+ 'y' => 7
+ ]
+ ]
+ ],
+ [
+ Period::PERIOD_1_YEAR,
+ 'quantity',
+ [
+ [
+ 'x' => '2020-01',
+ 'y' => 0
+ ],
+ [
+ 'x' => '2020-02',
+ 'y' => 2
+ ],
+ [
+ 'x' => '2020-03',
+ 'y' => 0
+ ],
+ [
+ 'x' => '2020-04',
+ 'y' => 7
+ ]
+ ]
+ ]
+ ];
+ }
+}
diff --git a/app/code/Magento/Backend/Test/Unit/Model/Dashboard/PeriodTest.php b/app/code/Magento/Backend/Test/Unit/Model/Dashboard/PeriodTest.php
new file mode 100644
index 0000000000000..5c71afdde3109
--- /dev/null
+++ b/app/code/Magento/Backend/Test/Unit/Model/Dashboard/PeriodTest.php
@@ -0,0 +1,49 @@
+model = $objectManager->getObject(
+ Period::class,
+ []
+ );
+ }
+
+ /**
+ * Test getDatePeriods() method
+ */
+ public function testGetDatePeriods()
+ {
+ $this->assertEquals(
+ [
+ Period::PERIOD_24_HOURS => (string)__('Last 24 Hours'),
+ Period::PERIOD_7_DAYS => (string)__('Last 7 Days'),
+ Period::PERIOD_1_MONTH => (string)__('Current Month'),
+ Period::PERIOD_1_YEAR => (string)__('YTD'),
+ Period::PERIOD_2_YEARS => (string)__('2YTD')
+ ],
+ $this->model->getDatePeriods()
+ );
+ }
+}
diff --git a/app/code/Magento/Backend/ViewModel/ChartDisabled.php b/app/code/Magento/Backend/ViewModel/ChartDisabled.php
new file mode 100644
index 0000000000000..f71a2d26441ef
--- /dev/null
+++ b/app/code/Magento/Backend/ViewModel/ChartDisabled.php
@@ -0,0 +1,77 @@
+ Configuration section
+ */
+ private const ROUTE_SYSTEM_CONFIG = 'adminhtml/system_config/edit';
+
+ /**
+ * @var UrlInterface
+ */
+ private $urlBuilder;
+
+ /**
+ * @var ScopeConfigInterface
+ */
+ private $scopeConfig;
+
+ /**
+ * @param UrlInterface $urlBuilder
+ * @param ScopeConfigInterface $scopeConfig
+ */
+ public function __construct(
+ UrlInterface $urlBuilder,
+ ScopeConfigInterface $scopeConfig
+ ) {
+ $this->urlBuilder = $urlBuilder;
+ $this->scopeConfig = $scopeConfig;
+ }
+
+ /**
+ * Get url to dashboard chart configuration
+ *
+ * @return string
+ */
+ public function getConfigUrl(): string
+ {
+ return $this->urlBuilder->getUrl(
+ static::ROUTE_SYSTEM_CONFIG,
+ ['section' => 'admin', '_fragment' => 'admin_dashboard-link']
+ );
+ }
+
+ /**
+ * Check if dashboard chart is enabled
+ *
+ * @return bool
+ */
+ public function isChartEnabled(): bool
+ {
+ return $this->scopeConfig->isSetFlag(
+ static::XML_PATH_ENABLE_CHARTS,
+ ScopeInterface::SCOPE_STORE
+ );
+ }
+}
diff --git a/app/code/Magento/Backend/ViewModel/ChartsPeriod.php b/app/code/Magento/Backend/ViewModel/ChartsPeriod.php
new file mode 100644
index 0000000000000..effce0dc60585
--- /dev/null
+++ b/app/code/Magento/Backend/ViewModel/ChartsPeriod.php
@@ -0,0 +1,60 @@
+period = $period;
+ $this->serializer = $serializer;
+ }
+
+ /**
+ * Get chart date periods
+ *
+ * @return array
+ */
+ public function getDatePeriods(): array
+ {
+ return $this->period->getDatePeriods();
+ }
+
+ /**
+ * Get json-encoded chart period units
+ *
+ * @return string
+ */
+ public function getPeriodUnits(): string
+ {
+ return $this->serializer->serialize($this->period->getPeriodChartUnits());
+ }
+}
diff --git a/app/code/Magento/Backend/etc/adminhtml/di.xml b/app/code/Magento/Backend/etc/adminhtml/di.xml
index 5f566396ab500..1bfc504cf50e9 100644
--- a/app/code/Magento/Backend/etc/adminhtml/di.xml
+++ b/app/code/Magento/Backend/etc/adminhtml/di.xml
@@ -60,8 +60,9 @@
-
-
+
+
+
diff --git a/app/code/Magento/Backend/etc/adminhtml/system.xml b/app/code/Magento/Backend/etc/adminhtml/system.xml
index 3a2b3554cc4a0..1e8ec226d6b88 100644
--- a/app/code/Magento/Backend/etc/adminhtml/system.xml
+++ b/app/code/Magento/Backend/etc/adminhtml/system.xml
@@ -115,7 +115,7 @@
Magento\Config\Model\Config\Source\Yesno
-
+
1
@@ -123,7 +123,7 @@
Magento\Config\Model\Config\Source\Yesno
Use URL parameter to enable template path hints for Storefront
-
+
1
diff --git a/app/code/Magento/Backend/i18n/en_US.csv b/app/code/Magento/Backend/i18n/en_US.csv
index 51fe8bfe542a2..53f7fe90cbbe5 100644
--- a/app/code/Magento/Backend/i18n/en_US.csv
+++ b/app/code/Magento/Backend/i18n/en_US.csv
@@ -461,3 +461,5 @@ Pagination,Pagination
"Alternative text for the next pages link in the pagination menu. If empty, default arrow image is used.","Alternative text for the next pages link in the pagination menu. If empty, default arrow image is used."
"Anchor Text for Next","Anchor Text for Next"
"Theme Name","Theme Name"
+"Use URL parameter to enable template path hints for Storefront","Use URL parameter to enable template path hints for Storefront"
+"Add the following parameter to the URL to show template hints ?templatehints=[parameter_value]","Add the following parameter to the URL to show template hints ?templatehints=[parameter_value]"
diff --git a/app/code/Magento/Backend/view/adminhtml/layout/adminhtml_dashboard_index.xml b/app/code/Magento/Backend/view/adminhtml/layout/adminhtml_dashboard_index.xml
index 803eb1dbe903b..4a255134ab062 100644
--- a/app/code/Magento/Backend/view/adminhtml/layout/adminhtml_dashboard_index.xml
+++ b/app/code/Magento/Backend/view/adminhtml/layout/adminhtml_dashboard_index.xml
@@ -17,7 +17,68 @@
-
+
+
+
+
+
+
+
+
+
+ Magento\Backend\ViewModel\ChartDisabled
+
+
+
+
+ diagram_tab
+
+
+ diagram_tab_content
+
+
+ orders
+ orders
+
+
+ amounts
+ amounts
+
+
+
+ orders
+ Orders
+ Orders
+ adminhtml/dashboard_chart/orders
+ Magento\Backend\ViewModel\ChartsPeriod
+
+
+
+
+ 2
+ amounts
+ Amounts
+ Amounts
+ adminhtml/dashboard_chart/amounts
+ Magento\Backend\ViewModel\ChartsPeriod
+
+
+
+
+
+ Magento\Backend\ViewModel\ChartsPeriod
+
+
+