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/.htaccess b/.htaccess
index 71a5cf708dbc5..e07a564bc0ab6 100644
--- a/.htaccess
+++ b/.htaccess
@@ -37,29 +37,6 @@
DirectoryIndex index.php
-
-############################################
-## adjust memory limit
-
- php_value memory_limit 756M
- php_value max_execution_time 18000
-
-############################################
-## disable automatic session start
-## before autoload was initialized
-
- php_flag session.auto_start off
-
-############################################
-## enable resulting html compression
-
- #php_flag zlib.output_compression on
-
-###########################################
-## disable user agent verification to not break multiple image upload
-
- php_flag suhosin.session.cryptua off
-
############################################
## adjust memory limit
diff --git a/.travis.yml.sample b/.travis.yml.sample
deleted file mode 100644
index 76885ebab2896..0000000000000
--- a/.travis.yml.sample
+++ /dev/null
@@ -1,68 +0,0 @@
-sudo: required
-dist: trusty
-group: edge
-addons:
- apt:
- packages:
- - mysql-server-5.6
- - mysql-client-core-5.6
- - mysql-client-5.6
- - postfix
- firefox: "46.0"
- hosts:
- - magento2.travis
-services:
- - rabbitmq
- - elasticsearch
-language: php
-php:
- - 7.1
- - 7.2
-env:
- global:
- - COMPOSER_BIN_DIR=~/bin
- - INTEGRATION_SETS=3
- - NODE_JS_VERSION=8
- - MAGENTO_HOST_NAME="magento2.travis"
- matrix:
- - TEST_SUITE=unit
- - TEST_SUITE=static
- - TEST_SUITE=js GRUNT_COMMAND=spec
- - TEST_SUITE=js GRUNT_COMMAND=static
- - TEST_SUITE=integration INTEGRATION_INDEX=1
- - TEST_SUITE=integration INTEGRATION_INDEX=2
- - TEST_SUITE=integration INTEGRATION_INDEX=3
- - TEST_SUITE=functional
- - TEST_SUITE=graphql-api-functional
-matrix:
- exclude:
- - php: 7.1
- env: TEST_SUITE=static
- - php: 7.1
- env: TEST_SUITE=js GRUNT_COMMAND=spec
- - php: 7.1
- env: TEST_SUITE=js GRUNT_COMMAND=static
- - php: 7.1
- env: TEST_SUITE=functional
- - php: 7.1
- env: TEST_SUITE=graphql-api-functional
-cache:
- apt: true
- directories:
- - $HOME/.composer/cache
- - $HOME/.nvm
- - $HOME/node_modules
- - $HOME/yarn.lock
-before_install:
- - ./dev/travis/before_install.sh
-install: composer install --no-interaction
-before_script: ./dev/travis/before_script.sh
-script:
- # Set arguments for variants of phpunit based tests; '|| true' prevents failing script when leading test fails
- - test $TEST_SUITE = "functional" && TEST_FILTER='dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests.php' || true
-
- # The scripts for grunt/phpunit type tests
- - if [ $TEST_SUITE == "functional" ]; then dev/tests/functional/vendor/phpunit/phpunit/phpunit -c dev/tests/$TEST_SUITE $TEST_FILTER; fi
- - if [ $TEST_SUITE != "functional" ] && [ $TEST_SUITE != "js" ] && [ $TEST_SUITE != "graphql-api-functional" ]; then phpunit -c dev/tests/$TEST_SUITE $TEST_FILTER; fi
- - if [ $TEST_SUITE == "js" ]; then grunt $GRUNT_COMMAND; fi
- - if [ $TEST_SUITE == "graphql-api-functional" ]; then phpunit -c dev/tests/api-functional; fi
diff --git a/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/_Deprecated_ActionGroup.xml b/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/_Deprecated_ActionGroup.xml
deleted file mode 100644
index fc66f9fb0ef74..0000000000000
--- a/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/_Deprecated_ActionGroup.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/AdminAnalytics/Test/Mftf/Test/TrackingScriptTest.xml b/app/code/Magento/AdminAnalytics/Test/Mftf/Test/TrackingScriptTest.xml
index 58bcacc190cff..e02c34fd8868e 100644
--- a/app/code/Magento/AdminAnalytics/Test/Mftf/Test/TrackingScriptTest.xml
+++ b/app/code/Magento/AdminAnalytics/Test/Mftf/Test/TrackingScriptTest.xml
@@ -21,6 +21,6 @@
-
+
\ No newline at end of file
diff --git a/app/code/Magento/AdminAnalytics/Test/Unit/Condition/CanViewNotificationTest.php b/app/code/Magento/AdminAnalytics/Test/Unit/Condition/CanViewNotificationTest.php
index 7819f2f017a01..07ef6d6c4fe74 100644
--- a/app/code/Magento/AdminAnalytics/Test/Unit/Condition/CanViewNotificationTest.php
+++ b/app/code/Magento/AdminAnalytics/Test/Unit/Condition/CanViewNotificationTest.php
@@ -3,47 +3,43 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\AdminAnalytics\Test\Unit\Condition;
use Magento\AdminAnalytics\Model\Condition\CanViewNotification;
use Magento\AdminAnalytics\Model\ResourceModel\Viewer\Logger;
use Magento\AdminAnalytics\Model\Viewer\Log;
+use Magento\Framework\App\CacheInterface;
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 MockObject|CacheInterface $cacheStorageMock */
private $cacheStorageMock;
- public function setUp()
+ protected function setUp(): void
{
$this->cacheStorageMock = $this->getMockBuilder(CacheInterface::class)
->getMockForAbstractClass();
- $this->logMock = $this->getMockBuilder(Log::class)
- ->getMock();
- $this->viewerLoggerMock = $this->getMockBuilder(Logger::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->productMetadataMock = $this->getMockBuilder(ProductMetadataInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->logMock = $this->createMock(Log::class);
+ $this->viewerLoggerMock = $this->createMock(Logger::class);
+ $this->productMetadataMock = $this->getMockForAbstractClass(ProductMetadataInterface::class);
$objectManager = new ObjectManager($this);
$this->canViewNotification = $objectManager->getObject(
CanViewNotification::class,
diff --git a/app/code/Magento/AdminAnalytics/composer.json b/app/code/Magento/AdminAnalytics/composer.json
index 0b977a23ad3ca..cf60b1d88ae55 100644
--- a/app/code/Magento/AdminAnalytics/composer.json
+++ b/app/code/Magento/AdminAnalytics/composer.json
@@ -5,7 +5,7 @@
"sort-packages": true
},
"require": {
- "php": "~7.1.3||~7.2.0||~7.3.0",
+ "php": "~7.3.0||~7.4.0",
"magento/framework": "*",
"magento/module-backend": "*",
"magento/module-config": "*",
@@ -18,12 +18,11 @@
"AFL-3.0"
],
"autoload": {
- "files": [
- "registration.php"
- ],
- "psr-4": {
- "Magento\\AdminAnalytics\\": ""
- }
+ "files": [
+ "registration.php"
+ ],
+ "psr-4": {
+ "Magento\\AdminAnalytics\\": ""
+ }
}
}
-
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 81ad2858d5901..77c8f02bfb777 100644
--- a/app/code/Magento/AdminNotification/Test/Mftf/Test/AdminSystemNotificationNavigateMenuTest.xml
+++ b/app/code/Magento/AdminNotification/Test/Mftf/Test/AdminSystemNotificationNavigateMenuTest.xml
@@ -20,7 +20,7 @@
-
+
diff --git a/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/ActionsTest.php b/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/ActionsTest.php
index 781734186ce6b..9cc600681b13d 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
@@ -28,25 +29,25 @@ class ActionsTest extends TestCase
*/
private $sut;
- protected function setUp() : void
+ protected function setUp(): void
{
parent::setUp();
- /** @var Escaper | \PHPUnit_Framework_MockObject_MockObject $escaperMock */
- $escaperMock = $this->getMockBuilder(Escaper::class)->disableOriginalConstructor()->getMock();
+ /** @var Escaper|MockObject $escaperMock */
+ $escaperMock = $this->createMock(Escaper::class);
$escaperMock->expects($this->once())->method('escapeUrl')->willReturn('https://magento.com');
- /** @var UrlInterface | \PHPUnit_Framework_MockObject_MockObject $urlBuilder */
- $urlBuilder = $this->getMockBuilder(UrlInterface::class)->getMock();
+ /** @var UrlInterface|MockObject $urlBuilder */
+ $urlBuilder = $this->getMockForAbstractClass(UrlInterface::class);
$urlBuilder->expects($this->once())->method('getUrl')->willReturn('http://magento.com');
- /** @var Context | \PHPUnit_Framework_MockObject_MockObject $contextMock */
- $contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
+ /** @var Context|MockObject $contextMock */
+ $contextMock = $this->createMock(Context::class);
$contextMock->expects($this->once())->method('getEscaper')->willReturn($escaperMock);
$contextMock->expects($this->once())->method('getUrlBuilder')->willReturn($urlBuilder);
- /** @var Data | \PHPUnit_Framework_MockObject_MockObject $urlHelperMock */
- $urlHelperMock = $this->getMockBuilder(Data::class)->disableOriginalConstructor()->getMock();
+ /** @var Data|MockObject $urlHelperMock */
+ $urlHelperMock = $this->createMock(Data::class);
$urlHelperMock->expects($this->once())->method('getEncodedUrl')->willReturn('http://magento.com');
$this->sut = new Actions($contextMock, $urlHelperMock);
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..73fcea20db4b2 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
@@ -12,9 +12,10 @@
namespace Magento\AdminNotification\Test\Unit\Block\Grid\Renderer;
use Magento\AdminNotification\Block\Grid\Renderer\Notice;
+use Magento\Backend\Block\Context;
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
@@ -26,16 +27,16 @@ class NoticeTest extends TestCase
*/
private $sut;
- protected function setUp() : void
+ protected function setUp(): void
{
parent::setUp();
- /** @var Escaper | \PHPUnit_Framework_MockObject_MockObject $escaperMock */
- $escaperMock = $this->getMockBuilder(Escaper::class)->disableOriginalConstructor()->getMock();
+ /** @var Escaper|MockObject $escaperMock */
+ $escaperMock = $this->createMock(Escaper::class);
$escaperMock->expects($this->exactly(2))->method('escapeHtml')->willReturn('Some random html
');
- /** @var Context | \PHPUnit_Framework_MockObject_MockObject $contextMock */
- $contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
+ /** @var Context|MockObject $contextMock */
+ $contextMock = $this->createMock(Context::class);
$contextMock->expects($this->once())->method('getEscaper')->willReturn($escaperMock);
$this->sut = new Notice($contextMock);
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..c21d83353324c 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
@@ -16,7 +16,7 @@
use Magento\Backend\Block\Context;
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
@@ -28,22 +28,22 @@ class SeverityTest extends TestCase
*/
private $sut;
- protected function setUp() : void
+ protected function setUp(): void
{
parent::setUp();
- /** @var Inbox |\PHPUnit_Framework_MockObject_MockObject $inboxMock */
- $inboxMock = $this->getMockBuilder(Inbox::class)->disableOriginalConstructor()->getMock();
+ /** @var Inbox|MockObject $inboxMock */
+ $inboxMock = $this->createMock(Inbox::class);
- /** @var Context | \PHPUnit_Framework_MockObject_MockObject $contextMock */
- $contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
+ /** @var Context|MockObject $contextMock */
+ $contextMock = $this->createMock(Context::class);
$this->sut = new Severity($contextMock, $inboxMock);
}
public function testShouldRenderSeverity() : void
{
- /** @var Column | \PHPUnit_Framework_MockObject_MockObject $columnMock */
+ /** @var Column|MockObject $columnMock */
$columnMock = $this->getMockBuilder(Column::class)
->disableOriginalConstructor()
->setMethods(['getIndex'])
diff --git a/app/code/Magento/AdminNotification/Test/Unit/Block/ToolbarEntryTest.php b/app/code/Magento/AdminNotification/Test/Unit/Block/ToolbarEntryTest.php
index 2afa9eced1d95..00c6f795c0a08 100644
--- a/app/code/Magento/AdminNotification/Test/Unit/Block/ToolbarEntryTest.php
+++ b/app/code/Magento/AdminNotification/Test/Unit/Block/ToolbarEntryTest.php
@@ -3,32 +3,38 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
/**
* Test class for \Magento\AdminNotification\Block\ToolbarEntry
*/
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));
+ $notificationList->method('getSize')->willReturn($unreadNotifications);
$block = $objectManagerHelper->getObject(
- \Magento\AdminNotification\Block\ToolbarEntry::class,
+ ToolbarEntry::class,
['notificationList' => $notificationList]
);
@@ -44,26 +50,21 @@ 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
- )
- ->disableOriginalConstructor()
- ->getMock();
+ $notificationList = $this->createMock(Unread::class);
- /** @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)
- ->will($this->returnSelf());
+ ->with(ToolbarEntry::NOTIFICATIONS_NUMBER)->willReturnSelf();
// 3. Run tested method
$result = $model->getLatestUnreadNotifications();
diff --git a/app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php b/app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php
index 2b3eb6247e899..bce2c084b2736 100644
--- a/app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php
+++ b/app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php
@@ -3,69 +3,82 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
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)
- ->disableOriginalConstructor()->getMock();
- $this->appState = $this->createPartialMock(\Magento\Framework\App\State::class, ['getInstallDate']);
- $this->inboxModel = $this->createPartialMock(\Magento\AdminNotification\Model\Inbox::class, [
- '__wakeup',
- 'parse'
- ]);
+ $this->curlFactory = $this->createPartialMock(CurlFactory::class, ['create']);
+ $this->curl = $this->createMock(Curl::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,16 @@ protected function setUp()
]
);
- $this->deploymentConfig = $this->getMockBuilder(\Magento\Framework\App\DeploymentConfig::class)
- ->disableOriginalConstructor()->getMock();
+ $this->deploymentConfig = $this->createMock(DeploymentConfig::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
- $this->productMetadata = $this->getMockBuilder(\Magento\Framework\App\ProductMetadata::class)
- ->disableOriginalConstructor()->getMock();
+ $this->productMetadata = $this->createMock(ProductMetadata::class);
- $this->urlBuilder = $this->createMock(\Magento\Framework\UrlInterface::class);
+ $this->urlBuilder = $this->getMockForAbstractClass(UrlInterface::class);
$this->feed = $this->objectManagerHelper->getObject(
- \Magento\AdminNotification\Model\Feed::class,
+ Feed::class,
[
'backendConfig' => $this->backendConfig,
'cacheManager' => $this->cacheManager,
@@ -132,20 +143,20 @@ public function testCheckUpdate($callInbox, $curlRequest)
];
$lastUpdate = 0;
- $this->cacheManager->expects($this->once())->method('load')->will(($this->returnValue($lastUpdate)));
- $this->curlFactory->expects($this->at(0))->method('create')->will($this->returnValue($this->curl));
+ $this->cacheManager->expects($this->once())->method('load')->willReturn($lastUpdate);
+ $this->curlFactory->expects($this->at(0))->method('create')->willReturn($this->curl);
$this->curl->expects($this->once())->method('setConfig')->with($configValues)->willReturnSelf();
- $this->curl->expects($this->once())->method('read')->will($this->returnValue($curlRequest));
- $this->backendConfig->expects($this->at(0))->method('getValue')->will($this->returnValue('1'));
- $this->backendConfig->expects($this->once())->method('isSetFlag')->will($this->returnValue(false));
+ $this->curl->expects($this->once())->method('read')->willReturn($curlRequest);
+ $this->backendConfig->expects($this->at(0))->method('getValue')->willReturn('1');
+ $this->backendConfig->expects($this->once())->method('isSetFlag')->willReturn(false);
$this->backendConfig->expects($this->at(1))->method('getValue')
- ->will($this->returnValue('http://feed.magento.com'));
+ ->willReturn('http://feed.magento.com');
$this->deploymentConfig->expects($this->once())->method('get')
->with(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE)
- ->will($this->returnValue('Sat, 6 Sep 2014 16:46:11 UTC'));
+ ->willReturn('Sat, 6 Sep 2014 16:46:11 UTC');
if ($callInbox) {
$this->inboxFactory->expects($this->once())->method('create')
- ->will($this->returnValue($this->inboxModel));
+ ->willReturn($this->inboxModel);
$this->inboxModel->expects($this->once())
->method('parse')
->with(
@@ -165,7 +176,7 @@ function ($initialValue, $item) use ($data) {
}
)
)
- ->will($this->returnSelf());
+ ->willReturnSelf();
} else {
$this->inboxFactory->expects($this->never())->method('create');
$this->inboxModel->expects($this->never())->method('parse');
diff --git a/app/code/Magento/AdminNotification/Test/Unit/Model/NotificationServiceTest.php b/app/code/Magento/AdminNotification/Test/Unit/Model/NotificationServiceTest.php
index f8485847ccae2..2dbdebb7b8b43 100644
--- a/app/code/Magento/AdminNotification/Test/Unit/Model/NotificationServiceTest.php
+++ b/app/code/Magento/AdminNotification/Test/Unit/Model/NotificationServiceTest.php
@@ -3,45 +3,53 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
/**
* Test class for \Magento\AdminNotification\Model\NotificationService
*/
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 MockObject|InboxFactory $notificationFactory
*/
$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']
- );
- $notification->expects($this->once())->method('load')->with($notificationId)->will($this->returnSelf());
- $notification->expects($this->once())->method('getId')->will($this->returnValue($notificationId));
+ $notification = $this->getMockBuilder(Inbox::class)
+ ->addMethods(['setIsRead'])
+ ->onlyMethods(['load', 'getId', 'save', 'setData', '__sleep', '__wakeup'])
+ ->disableOriginalConstructor()
+ ->getMock();
+ $notification->expects($this->once())->method('load')->with($notificationId)->willReturnSelf();
+ $notification->expects($this->once())->method('getId')->willReturn($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('save')->willReturnSelf();
+ $notification->expects($this->once())->method('setIsRead')->with(1)->willReturnSelf();
}
- $notificationFactory->expects($this->once())->method('create')->will($this->returnValue($notification));
- return new \Magento\AdminNotification\Model\NotificationService($notificationFactory);
+ $notificationFactory->expects($this->once())->method('create')->willReturn($notification);
+ return new NotificationService($notificationFactory);
}
public function testMarkAsRead()
@@ -51,12 +59,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..6130b092e5af3 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
@@ -3,44 +3,54 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
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->getMockForAbstractClass(AuthorizationInterface::class);
+ $this->_urlInterfaceMock = $this->getMockForAbstractClass(UrlInterface::class);
+ $this->_cacheTypeListMock = $this->getMockForAbstractClass(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
);
}
@@ -52,12 +62,10 @@ protected function setUp()
*/
public function testGetIdentity($expectedSum, $cacheTypes)
{
- $this->_cacheTypeListMock->expects(
- $this->any()
- )->method(
+ $this->_cacheTypeListMock->method(
'getInvalidated'
- )->will(
- $this->returnValue($cacheTypes)
+ )->willReturn(
+ $cacheTypes
);
$this->assertEquals($expectedSum, $this->_messageModel->getIdentity());
}
@@ -67,11 +75,15 @@ public function testGetIdentity($expectedSum, $cacheTypes)
*/
public function getIdentityDataProvider()
{
- $cacheTypeMock1 = $this->createPartialMock(\stdClass::class, ['getCacheType']);
- $cacheTypeMock1->expects($this->any())->method('getCacheType')->will($this->returnValue('Simple'));
+ $cacheTypeMock1 = $this->getMockBuilder(\stdClass::class)->addMethods(['getCacheType'])
+ ->disableOriginalConstructor()
+ ->getMock();
+ $cacheTypeMock1->method('getCacheType')->willReturn('Simple');
- $cacheTypeMock2 = $this->createPartialMock(\stdClass::class, ['getCacheType']);
- $cacheTypeMock2->expects($this->any())->method('getCacheType')->will($this->returnValue('Advanced'));
+ $cacheTypeMock2 = $this->getMockBuilder(\stdClass::class)->addMethods(['getCacheType'])
+ ->disableOriginalConstructor()
+ ->getMock();
+ $cacheTypeMock2->method('getCacheType')->willReturn('Advanced');
return [
['c13cfaddc2c53e8d32f59bfe89719beb', [$cacheTypeMock1]],
@@ -87,13 +99,11 @@ public function getIdentityDataProvider()
*/
public function testIsDisplayed($expected, $allowed, $cacheTypes)
{
- $this->_authorizationMock->expects($this->once())->method('isAllowed')->will($this->returnValue($allowed));
- $this->_cacheTypeListMock->expects(
- $this->any()
- )->method(
+ $this->_authorizationMock->expects($this->once())->method('isAllowed')->willReturn($allowed);
+ $this->_cacheTypeListMock->method(
'getInvalidated'
- )->will(
- $this->returnValue($cacheTypes)
+ )->willReturn(
+ $cacheTypes
);
$this->assertEquals($expected, $this->_messageModel->isDisplayed());
}
@@ -103,8 +113,10 @@ public function testIsDisplayed($expected, $allowed, $cacheTypes)
*/
public function isDisplayedDataProvider()
{
- $cacheTypesMock = $this->createPartialMock(\stdClass::class, ['getCacheType']);
- $cacheTypesMock->expects($this->any())->method('getCacheType')->will($this->returnValue('someVal'));
+ $cacheTypesMock = $this->getMockBuilder(\stdClass::class)->addMethods(['getCacheType'])
+ ->disableOriginalConstructor()
+ ->getMock();
+ $cacheTypesMock->method('getCacheType')->willReturn('someVal');
$cacheTypes = [$cacheTypesMock, $cacheTypesMock];
return [
[false, false, []],
@@ -118,15 +130,15 @@ public function testGetText()
{
$messageText = 'One or more of the Cache Types are invalidated';
- $this->_cacheTypeListMock->expects($this->any())->method('getInvalidated')->will($this->returnValue([]));
- $this->_urlInterfaceMock->expects($this->once())->method('getUrl')->will($this->returnValue('someURL'));
- $this->assertContains($messageText, $this->_messageModel->getText());
+ $this->_cacheTypeListMock->method('getInvalidated')->willReturn([]);
+ $this->_urlInterfaceMock->expects($this->once())->method('getUrl')->willReturn('someURL');
+ $this->assertStringContainsString($messageText, $this->_messageModel->getText());
}
public function testGetLink()
{
$url = 'backend/admin/cache';
- $this->_urlInterfaceMock->expects($this->once())->method('getUrl')->will($this->returnValue($url));
+ $this->_urlInterfaceMock->expects($this->once())->method('getUrl')->willReturn($url);
$this->assertEquals($url, $this->_messageModel->getLink());
}
}
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..d9312ac71c792 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
@@ -3,39 +3,48 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
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->expects($this->any())->method('loadSelf')->will($this->returnValue($this->_syncFlagMock));
+ $this->_fileStorage = $this->createMock(Flag::class);
+ $this->_fileStorage->method('loadSelf')->willReturn($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,8 +52,7 @@ protected function setUp()
public function testGetText()
{
$messageText = 'We were unable to synchronize one or more media files.';
-
- $this->assertContains($messageText, (string)$this->_model->getText());
+ $this->assertStringContainsString($messageText, (string)$this->_model->getText());
}
/**
@@ -55,17 +63,16 @@ 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 Error $model */
$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));
+ $this->_syncFlagMock->method('save');
+ $this->_syncFlagMock->method('getFlagData')->willReturn($data);
//check first call
$this->assertEquals($expectedFirstRun, $model->isDisplayed());
//check second call(another branch of if operator)
@@ -92,7 +99,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..ade7fb3b32b81 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
@@ -3,53 +3,59 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
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->getMockForAbstractClass(CacheInterface::class);
+ $this->scopeConfigMock = $this->getMockForAbstractClass(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 +70,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->method('load')->willReturn($cached);
+ $this->cacheMock->method('save')->willReturn(null);
- $httpAdapterMock = $this->createMock(\Magento\Framework\HTTP\Adapter\Curl::class);
- $httpAdapterMock->expects($this->any())->method('read')->will($this->returnValue($response));
- $this->_curlFactoryMock->expects($this->any())->method('create')->will($this->returnValue($httpAdapterMock));
+ $httpAdapterMock = $this->createMock(Curl::class);
+ $httpAdapterMock->method('read')->willReturn($response);
+ $this->curlFactoryMock->method('create')->willReturn($httpAdapterMock);
- $this->_scopeConfigMock->expects($this->any())->method('getValue')->will($this->returnValue(null));
+ $this->scopeConfigMock->method('getValue')->willReturn(null);
- $this->assertEquals($expectedResult, $this->_messageModel->isDisplayed());
+ $this->assertEquals($expectedResult, $this->messageModel->isDisplayed());
}
/**
@@ -92,6 +98,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
index 3209572ab0d70..a2bf527078983 100644
--- a/app/code/Magento/AdminNotification/Test/Unit/Observer/PredispatchAdminActionControllerObserverTest.php
+++ b/app/code/Magento/AdminNotification/Test/Unit/Observer/PredispatchAdminActionControllerObserverTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\AdminNotification\Test\Unit\Observer;
use Magento\AdminNotification\Model\Feed;
@@ -59,7 +61,7 @@ class PredispatchAdminActionControllerObserverTest extends TestCase
/**
* @inheritdoc
*/
- protected function setUp() : void
+ protected function setUp(): void
{
$this->objectManager = new ObjectManager($this);
$this->observerMock = $this->createMock(Observer::class);
diff --git a/app/code/Magento/AdminNotification/composer.json b/app/code/Magento/AdminNotification/composer.json
index ea1e3ca10f2d3..d421fc869621b 100644
--- a/app/code/Magento/AdminNotification/composer.json
+++ b/app/code/Magento/AdminNotification/composer.json
@@ -5,7 +5,7 @@
"sort-packages": true
},
"require": {
- "php": "~7.1.3||~7.2.0||~7.3.0",
+ "php": "~7.3.0||~7.4.0",
"lib-libxml": "*",
"magento/framework": "*",
"magento/module-backend": "*",
diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Export/AdvancedPricingTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Export/AdvancedPricingTest.php
index 57ceb7f5af275..14a5a7e1a7ae0 100644
--- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Export/AdvancedPricingTest.php
+++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Export/AdvancedPricingTest.php
@@ -3,140 +3,167 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\AdvancedPricingImportExport\Test\Unit\Model\Export;
+use Magento\AdvancedPricingImportExport\Model\Export\AdvancedPricing;
+use Magento\Catalog\Model\Product\LinkTypeProvider;
+use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
+use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
+use Magento\Catalog\Model\ResourceModel\ProductFactory;
+use Magento\CatalogImportExport\Model\Export\Product;
+use Magento\CatalogImportExport\Model\Export\Product\Type\Factory;
+use Magento\CatalogImportExport\Model\Export\RowCustomizer\Composite;
+use Magento\CatalogImportExport\Model\Import\Product\StoreResolver;
+use Magento\CatalogInventory\Model\ResourceModel\Stock\ItemFactory;
+use Magento\Customer\Api\GroupRepositoryInterface;
+use Magento\Eav\Model\Config;
+use Magento\Eav\Model\Entity\Collection\AbstractCollection;
+use Magento\Eav\Model\Entity\Type;
+use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory as AttributeSetCollectionFactory;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\Logger\Monolog;
+use Magento\Framework\Stdlib\DateTime\Timezone;
+use Magento\ImportExport\Model\Export\Adapter\AbstractAdapter;
+use Magento\ImportExport\Model\Export\ConfigInterface;
use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManager;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+use Psr\Log\LoggerInterface;
/**
* @SuppressWarnings(PHPMD)
*/
-class AdvancedPricingTest extends \PHPUnit\Framework\TestCase
+class AdvancedPricingTest extends TestCase
{
/**
- * @var \Magento\Framework\Stdlib\DateTime\Timezone|\PHPUnit_Framework_MockObject_MockObject
+ * @var Timezone|MockObject
*/
protected $localeDate;
/**
- * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
protected $config;
/**
- * @var \Magento\Framework\App\ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResourceConnection|MockObject
*/
protected $resource;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
protected $storeManager;
/**
- * @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var LoggerInterface|MockObject
*/
protected $logger;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CollectionFactory|MockObject
*/
protected $collection;
/**
- * @var \Magento\Eav\Model\Entity\Collection\AbstractCollection|\PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractCollection|MockObject
*/
protected $abstractCollection;
/**
- * @var \Magento\ImportExport\Model\Export\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ConfigInterface|MockObject
*/
protected $exportConfig;
/**
- * @var \Magento\Catalog\Model\ResourceModel\ProductFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductFactory|MockObject
*/
protected $productFactory;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $attrSetColFactory;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CategoryCollectionFactory|MockObject
*/
protected $categoryColFactory;
/**
- * @var \Magento\CatalogInventory\Model\ResourceModel\Stock\ItemFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ItemFactory|MockObject
*/
protected $itemFactory;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $optionColFactory;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $attributeColFactory;
/**
- * @var \Magento\CatalogImportExport\Model\Export\Product\Type\Factory|\PHPUnit_Framework_MockObject_MockObject
+ * @var Factory|MockObject
*/
protected $typeFactory;
/**
- * @var \Magento\Catalog\Model\Product\LinkTypeProvider|\PHPUnit_Framework_MockObject_MockObject
+ * @var LinkTypeProvider|MockObject
*/
protected $linkTypeProvider;
/**
- * @var \Magento\CatalogImportExport\Model\Export\RowCustomizer\Composite|\PHPUnit_Framework_MockObject_MockObject
+ * @var Composite|MockObject
*/
protected $rowCustomizer;
/**
- * @var \Magento\CatalogImportExport\Model\Import\Product\StoreResolver|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreResolver|MockObject
*/
protected $storeResolver;
/**
- * @var \Magento\Customer\Api\GroupRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var GroupRepositoryInterface|MockObject
*/
protected $groupRepository;
/**
- * @var \Magento\ImportExport\Model\Export\Adapter\AbstractAdapter| \PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractAdapter|MockObject
*/
protected $writer;
/**
- * @var \Magento\AdvancedPricingImportExport\Model\Export\AdvancedPricing|\PHPUnit_Framework_MockObject_MockObject
+ * @var AdvancedPricing|MockObject
*/
protected $advancedPricing;
/**
- * @var StubProduct|\Magento\CatalogImportExport\Model\Export\Product
+ * @var StubProduct|Product
*/
protected $object;
/**
* Set Up
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->localeDate = $this->createMock(\Magento\Framework\Stdlib\DateTime\Timezone::class);
- $this->config = $this->createPartialMock(\Magento\Eav\Model\Config::class, ['getEntityType']);
- $type = $this->createMock(\Magento\Eav\Model\Entity\Type::class);
+ $this->localeDate = $this->createMock(Timezone::class);
+ $this->config = $this->createPartialMock(Config::class, ['getEntityType']);
+ $type = $this->createMock(Type::class);
$this->config->expects($this->once())->method('getEntityType')->willReturn($type);
- $this->resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
- $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManager::class);
- $this->logger = $this->createMock(\Magento\Framework\Logger\Monolog::class);
- $this->collection = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class);
+ $this->resource = $this->createMock(ResourceConnection::class);
+ $this->storeManager = $this->createMock(StoreManager::class);
+ $this->logger = $this->createMock(Monolog::class);
+ $this->collection = $this->createMock(CollectionFactory::class);
$this->abstractCollection = $this->getMockForAbstractClass(
- \Magento\Eav\Model\Entity\Collection\AbstractCollection::class,
+ AbstractCollection::class,
[],
'',
false,
@@ -151,49 +178,43 @@ protected function setUp()
]
);
$this->exportConfig = $this->createMock(\Magento\ImportExport\Model\Export\Config::class);
- $this->productFactory = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\ProductFactory::class,
- [
- 'create',
- 'getTypeId',
- ]
- );
- $this->attrSetColFactory = $this->createPartialMock(
- \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory::class,
- [
- 'create',
- 'setEntityTypeFilter',
- ]
- );
- $this->categoryColFactory = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory::class,
- [
- 'create',
- 'addNameToResult',
- ]
- );
- $this->itemFactory = $this->createMock(\Magento\CatalogInventory\Model\ResourceModel\Stock\ItemFactory::class);
+ $this->productFactory = $this->getMockBuilder(ProductFactory::class)
+ ->addMethods(['getTypeId'])
+ ->onlyMethods(['create'])
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->attrSetColFactory = $this->getMockBuilder(AttributeSetCollectionFactory::class)
+ ->addMethods(['setEntityTypeFilter'])
+ ->onlyMethods(['create'])
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->categoryColFactory = $this->getMockBuilder(CategoryCollectionFactory::class)
+ ->addMethods(['addNameToResult'])
+ ->onlyMethods(['create'])
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->itemFactory = $this->createMock(ItemFactory::class);
$this->optionColFactory = $this->createMock(
\Magento\Catalog\Model\ResourceModel\Product\Option\CollectionFactory::class
);
$this->attributeColFactory = $this->createMock(
\Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class
);
- $this->typeFactory = $this->createMock(\Magento\CatalogImportExport\Model\Export\Product\Type\Factory::class);
- $this->linkTypeProvider = $this->createMock(\Magento\Catalog\Model\Product\LinkTypeProvider::class);
+ $this->typeFactory = $this->createMock(Factory::class);
+ $this->linkTypeProvider = $this->createMock(LinkTypeProvider::class);
$this->rowCustomizer = $this->createMock(
- \Magento\CatalogImportExport\Model\Export\RowCustomizer\Composite::class
+ Composite::class
);
$this->storeResolver = $this->createMock(
- \Magento\CatalogImportExport\Model\Import\Product\StoreResolver::class
+ StoreResolver::class
);
- $this->groupRepository = $this->createMock(\Magento\Customer\Api\GroupRepositoryInterface::class);
+ $this->groupRepository = $this->getMockForAbstractClass(GroupRepositoryInterface::class);
$this->writer = $this->createPartialMock(
- \Magento\ImportExport\Model\Export\Adapter\AbstractAdapter::class,
+ AbstractAdapter::class,
[
- 'setHeaderCols',
- 'writeRow',
- 'getContents',
+ 'setHeaderCols',
+ 'writeRow',
+ 'getContents',
]
);
$constructorMethods = [
@@ -220,13 +241,13 @@ protected function setUp()
'correctExportData'
]);
$this->advancedPricing = $this->getMockBuilder(
- \Magento\AdvancedPricingImportExport\Model\Export\AdvancedPricing::class
+ AdvancedPricing::class
)
->setMethods($mockMethods)
->disableOriginalConstructor()
->getMock();
foreach ($constructorMethods as $method) {
- $this->advancedPricing->expects($this->once())->method($method)->will($this->returnSelf());
+ $this->advancedPricing->expects($this->once())->method($method)->willReturnSelf();
}
$this->advancedPricing->__construct(
$this->localeDate,
@@ -307,12 +328,12 @@ public function testExportCurrentPageCalls()
$this->abstractCollection->expects($this->once())->method('getCurPage')->willReturn($curPage);
$this->abstractCollection->expects($this->once())->method('getLastPageNumber')->willReturn($lastPage);
$headers = ['headers'];
- $this->advancedPricing->expects($this->any())->method('_getHeaderColumns')->willReturn($headers);
- $this->writer->expects($this->any())->method('setHeaderCols')->with($headers);
+ $this->advancedPricing->method('_getHeaderColumns')->willReturn($headers);
+ $this->writer->method('setHeaderCols')->with($headers);
$webSite = 'All Websites [USD]';
$userGroup = 'General';
- $this->advancedPricing->expects($this->any())->method('_getWebsiteCode')->willReturn($webSite);
- $this->advancedPricing->expects($this->any())->method('_getCustomerGroupById')->willReturn($userGroup);
+ $this->advancedPricing->method('_getWebsiteCode')->willReturn($webSite);
+ $this->advancedPricing->method('_getCustomerGroupById')->willReturn($userGroup);
$data = [
[
'sku' => 'simpletest',
@@ -331,7 +352,6 @@ public function testExportCurrentPageCalls()
'tier_price' => '23',
];
$this->advancedPricing
- ->expects($this->any())
->method('correctExportData')
->willReturn($exportData);
$this->writer->expects($this->once())->method('writeRow')->with($exportData);
@@ -342,7 +362,7 @@ public function testExportCurrentPageCalls()
/**
* tearDown
*/
- protected function tearDown()
+ protected function tearDown(): void
{
unset($this->object);
}
diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTest.php
index 2c930237da831..db3a341a8199e 100644
--- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTest.php
+++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTest.php
@@ -3,50 +3,67 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\AdvancedPricingImportExport\Test\Unit\Model\Import\AdvancedPricing\Validator;
use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing as AdvancedPricing;
+use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator;
+use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\TierPrice;
+use Magento\CatalogImportExport\Model\Import\Product;
+use Magento\CatalogImportExport\Model\Import\Product\StoreResolver;
+use Magento\Customer\Api\Data\GroupInterface;
+use Magento\Customer\Api\Data\GroupSearchResultsInterface;
+use Magento\Customer\Api\GroupRepositoryInterface;
+use Magento\Eav\Model\Config;
+use Magento\Framework\Api\SearchCriteria;
+use Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\Json\Helper\Data;
+use Magento\Framework\Stdlib\StringUtils;
+use Magento\ImportExport\Model\ResourceModel\Helper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD)
*/
-class TierPriceTest extends \PHPUnit\Framework\TestCase
+class TierPriceTest extends TestCase
{
/**
- * @var \Magento\Customer\Api\GroupRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var GroupRepositoryInterface|MockObject
*/
protected $groupRepository;
/**
- * @var \Magento\Framework\Api\SearchCriteriaBuilder|\PHPUnit_Framework_MockObject_MockObject
+ * @var SearchCriteriaBuilder|MockObject
*/
protected $searchCriteriaBuilder;
/**
- * @var \Magento\CatalogImportExport\Model\Import\Product\StoreResolver|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreResolver|MockObject
*/
protected $storeResolver;
/**
- * @var AdvancedPricing\Validator\TierPrice|\PHPUnit_Framework_MockObject_MockObject
+ * @var AdvancedPricing\Validator\TierPrice|MockObject
*/
protected $tierPrice;
- protected function setUp()
+ protected function setUp(): void
{
- $this->groupRepository = $this->getMockBuilder(\Magento\Customer\Api\GroupRepositoryInterface::class)
+ $this->groupRepository = $this->getMockBuilder(GroupRepositoryInterface::class)
->disableOriginalConstructor()
->setMethods(['getList'])
->getMockForAbstractClass();
- $this->searchCriteriaBuilder = $this->createMock(\Magento\Framework\Api\SearchCriteriaBuilder::class);
+ $this->searchCriteriaBuilder = $this->createMock(SearchCriteriaBuilder::class);
$this->storeResolver = $this->createMock(
- \Magento\CatalogImportExport\Model\Import\Product\StoreResolver::class
+ StoreResolver::class
);
$this->tierPrice = $this->getMockBuilder(
- \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\TierPrice::class
+ TierPrice::class
)
->setMethods(['isValidValueAndLength', 'hasEmptyColumns', '_addMessages'])
->setConstructorArgs([$this->groupRepository, $this->searchCriteriaBuilder, $this->storeResolver])
@@ -55,49 +72,47 @@ protected function setUp()
public function testInitInternalCalls()
{
- $searchCriteria = $this->createMock(\Magento\Framework\Api\SearchCriteria::class);
- $this->searchCriteriaBuilder->expects($this->any())->method('create')->willReturn($searchCriteria);
+ $searchCriteria = $this->createMock(SearchCriteria::class);
+ $this->searchCriteriaBuilder->method('create')->willReturn($searchCriteria);
$groupSearchResult = $this->getMockForAbstractClass(
- \Magento\Customer\Api\Data\GroupSearchResultsInterface::class,
+ GroupSearchResultsInterface::class,
[],
'',
false
);
$this->groupRepository
- ->expects($this->any())
->method('getList')
->with($searchCriteria)
->willReturn($groupSearchResult);
- $groupTest = $this->getMockBuilder(\Magento\Customer\Api\Data\GroupInterface::class)
+ $groupTest = $this->getMockBuilder(GroupInterface::class)
->disableOriginalConstructor()
->setMethods(['getCode', 'getId'])
->getMockForAbstractClass();
$groupTest->expects($this->once())->method('getCode');
- $groupTest->expects($this->any())->method('getId');
+ $groupTest->method('getId');
$groups = [$groupTest];
- $groupSearchResult->expects($this->any())->method('getItems')->willReturn($groups);
+ $groupSearchResult->method('getItems')->willReturn($groups);
$this->tierPrice->init(null);
}
public function testInitAddToCustomerGroups()
{
- $searchCriteria = $this->createMock(\Magento\Framework\Api\SearchCriteria::class);
- $this->searchCriteriaBuilder->expects($this->any())->method('create')->willReturn($searchCriteria);
+ $searchCriteria = $this->createMock(SearchCriteria::class);
+ $this->searchCriteriaBuilder->method('create')->willReturn($searchCriteria);
$groupSearchResult = $this->getMockForAbstractClass(
- \Magento\Customer\Api\Data\GroupSearchResultsInterface::class,
+ GroupSearchResultsInterface::class,
[],
'',
false
);
$this->groupRepository
- ->expects($this->any())
->method('getList')
->with($searchCriteria)
->willReturn($groupSearchResult);
- $groupTest = $this->getMockBuilder(\Magento\Customer\Api\Data\GroupInterface::class)
+ $groupTest = $this->getMockBuilder(GroupInterface::class)
->disableOriginalConstructor()
->setMethods(['getCode', 'getId'])
->getMockForAbstractClass();
@@ -108,9 +123,9 @@ public function testInitAddToCustomerGroups()
$expectedCode => $expectedId,
];
$groupTest->expects($this->once())->method('getCode')->willReturn($expectedCode);
- $groupTest->expects($this->any())->method('getId')->willReturn($expectedId);
+ $groupTest->method('getId')->willReturn($expectedId);
$groups = [$groupTest];
- $groupSearchResult->expects($this->any())->method('getItems')->willReturn($groups);
+ $groupSearchResult->method('getItems')->willReturn($groups);
$this->tierPrice->init(null);
@@ -136,46 +151,45 @@ public function testIsValidResultTrue()
*/
public function testIsValidAddMessagesCall($value, $hasEmptyColumns, $customerGroups, $expectedMessages)
{
- $priceContextMock = $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Product::class)
+ $priceContextMock = $this->getMockBuilder(Product::class)
->setConstructorArgs(
[
- \Magento\Framework\Json\Helper\Data::class,
+ Data::class,
\Magento\ImportExport\Helper\Data::class,
\Magento\ImportExport\Model\ResourceModel\Import\Data::class,
- \Magento\Eav\Model\Config::class,
- \Magento\Framework\App\ResourceConnection::class,
- \Magento\ImportExport\Model\ResourceModel\Helper::class,
- \Magento\Framework\Stdlib\StringUtils::class,
+ Config::class,
+ ResourceConnection::class,
+ Helper::class,
+ StringUtils::class,
'ProcessingErrorAggregatorInterface'
]
);
$this->tierPrice->expects($this->once())->method('isValidValueAndLength')->willReturn(true);
- $this->tierPrice->expects($this->any())->method('hasEmptyColumns')->willReturn($hasEmptyColumns);
+ $this->tierPrice->method('hasEmptyColumns')->willReturn($hasEmptyColumns);
$this->setPropertyValue($this->tierPrice, 'customerGroups', $customerGroups);
- $searchCriteria = $this->createMock(\Magento\Framework\Api\SearchCriteria::class);
- $this->searchCriteriaBuilder->expects($this->any())->method('create')->willReturn($searchCriteria);
+ $searchCriteria = $this->createMock(SearchCriteria::class);
+ $this->searchCriteriaBuilder->method('create')->willReturn($searchCriteria);
$groupSearchResult = $this->getMockForAbstractClass(
- \Magento\Customer\Api\Data\GroupSearchResultsInterface::class,
+ GroupSearchResultsInterface::class,
[],
'',
false
);
$this->groupRepository
- ->expects($this->any())
->method('getList')
->with($searchCriteria)
->willReturn($groupSearchResult);
- $groupTest = $this->getMockBuilder(\Magento\Customer\Api\Data\GroupInterface::class)
+ $groupTest = $this->getMockBuilder(GroupInterface::class)
->disableOriginalConstructor()
->setMethods(['getCode', 'getId'])
->getMockForAbstractClass();
$groupTest->expects($this->once())->method('getCode');
- $groupTest->expects($this->any())->method('getId');
+ $groupTest->method('getId');
$groups = [$groupTest];
- $groupSearchResult->expects($this->any())->method('getItems')->willReturn($groups);
+ $groupSearchResult->method('getItems')->willReturn($groups);
$this->tierPrice->init($priceContextMock);
$this->tierPrice->isValid($value);
@@ -307,7 +321,7 @@ public function isValidAddMessagesCallDataProvider()
'$customerGroups' => [
'value' => 'value'
],
- '$expectedMessages' => [AdvancedPricing\Validator::ERROR_TIER_DATA_INCOMPLETE],
+ '$expectedMessages' => [Validator::ERROR_TIER_DATA_INCOMPLETE],
],
// Second if condition cases.
[
@@ -321,7 +335,7 @@ public function isValidAddMessagesCallDataProvider()
'$customerGroups' => [
'value' => 'value'
],
- '$expectedMessages' => [AdvancedPricing\Validator::ERROR_INVALID_TIER_PRICE_GROUP],
+ '$expectedMessages' => [Validator::ERROR_INVALID_TIER_PRICE_GROUP],
],
// Third if condition cases.
[
@@ -335,7 +349,7 @@ public function isValidAddMessagesCallDataProvider()
'$customerGroups' => [
'value' => 'value'
],
- '$expectedMessages' => [AdvancedPricing\Validator::ERROR_INVALID_TIER_PRICE_QTY],
+ '$expectedMessages' => [Validator::ERROR_INVALID_TIER_PRICE_QTY],
],
];
}
diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTypeTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTypeTest.php
index 0dc2a0b7e6ddf..cae49455c0894 100644
--- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTypeTest.php
+++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTypeTest.php
@@ -3,15 +3,16 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\AdvancedPricingImportExport\Test\Unit\Model\Import\AdvancedPricing\Validator;
-use \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing as AdvancedPricing;
+use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing as AdvancedPricing;
+use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\TierPriceType;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-/**
- * Class TierPriceTypeTest.
- */
-class TierPriceTypeTest extends \PHPUnit\Framework\TestCase
+class TierPriceTypeTest extends TestCase
{
/**
* @var AdvancedPricing\Validator\TierPriceType
@@ -23,11 +24,11 @@ class TierPriceTypeTest extends \PHPUnit\Framework\TestCase
*
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->tierPriceType = $objectManager->getObject(
- AdvancedPricing\Validator\TierPriceType::class,
+ TierPriceType::class,
[]
);
}
diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/WebsiteTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/WebsiteTest.php
index d78c4f5e61af3..1a0b2b35ce0f7 100644
--- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/WebsiteTest.php
+++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/WebsiteTest.php
@@ -3,41 +3,48 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\AdvancedPricingImportExport\Test\Unit\Model\Import\AdvancedPricing\Validator;
use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing as AdvancedPricing;
-
-class WebsiteTest extends \PHPUnit\Framework\TestCase
+use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\Website as WebsiteValidator;
+use Magento\CatalogImportExport\Model\Import\Product\StoreResolver;
+use Magento\Directory\Model\Currency;
+use Magento\Store\Model\Website;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class WebsiteTest extends TestCase
{
/**
- * @var \Magento\Store\Model\WebSite|\PHPUnit_Framework_MockObject_MockObject
+ * @var Website|MockObject
*/
protected $webSiteModel;
/**
- * @var \Magento\CatalogImportExport\Model\Import\Product\StoreResolver|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreResolver|MockObject
*/
protected $storeResolver;
/**
- * @var AdvancedPricing\Validator\Website|\PHPUnit_Framework_MockObject_MockObject
+ * @var WebsiteValidator|MockObject
*/
protected $website;
- protected function setUp()
+ protected function setUp(): void
{
- $this->webSiteModel = $this->getMockBuilder(\Magento\Store\Model\Website::class)
+ $this->webSiteModel = $this->getMockBuilder(Website::class)
->setMethods(['getBaseCurrency'])
->disableOriginalConstructor()
->getMock();
$this->storeResolver = $this->createPartialMock(
- \Magento\CatalogImportExport\Model\Import\Product\StoreResolver::class,
+ StoreResolver::class,
['getWebsiteCodeToId']
);
$this->website = $this->getMockBuilder(
- \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\Website::class
+ WebsiteValidator::class
)
->setMethods(['getAllWebsitesValue', '_clearMessages', '_addMessages'])
->setConstructorArgs([$this->storeResolver, $this->webSiteModel])
@@ -66,7 +73,7 @@ public function testIsValidReturn(
$expectedResult
) {
$this->website->expects($this->once())->method('_clearMessages');
- $this->website->expects($this->any())->method('getAllWebsitesValue')->willReturn($allWebsites);
+ $this->website->method('getAllWebsitesValue')->willReturn($allWebsites);
$this->storeResolver->method('getWebsiteCodeToId')->willReturnMap([
[$value[AdvancedPricing::COL_TIER_PRICE_WEBSITE], $colTierPriceWebsite],
]);
@@ -82,29 +89,29 @@ public function testIsValidReturnAddMessagesCall()
];
$allWebsitesValue = 'not tier|group price website value';
$colTierPriceWebsite = false;
- $expectedMessages = [AdvancedPricing\Validator\Website::ERROR_INVALID_WEBSITE];
+ $expectedMessages = [WebsiteValidator::ERROR_INVALID_WEBSITE];
$this->website->expects($this->once())->method('_clearMessages');
- $this->website->expects($this->any())->method('getAllWebsitesValue')->willReturn($allWebsitesValue);
+ $this->website->method('getAllWebsitesValue')->willReturn($allWebsitesValue);
$this->storeResolver->method('getWebsiteCodeToId')->willReturnMap([
[$value[AdvancedPricing::COL_TIER_PRICE_WEBSITE], $colTierPriceWebsite],
]);
- $this->website->expects($this->any())->method('_addMessages')->with($expectedMessages);
+ $this->website->method('_addMessages')->with($expectedMessages);
$this->website->isValid($value);
}
public function testGetAllWebsitesValue()
{
$currencyCode = 'currencyCodeValue';
- $currency = $this->createPartialMock(\Magento\Directory\Model\Currency::class, ['getCurrencyCode']);
+ $currency = $this->createPartialMock(Currency::class, ['getCurrencyCode']);
$currency->expects($this->once())->method('getCurrencyCode')->willReturn($currencyCode);
$this->webSiteModel->expects($this->once())->method('getBaseCurrency')->willReturn($currency);
$expectedResult = AdvancedPricing::VALUE_ALL_WEBSITES . ' [' . $currencyCode . ']';
$websiteString = $this->getMockBuilder(
- \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\Website::class
+ WebsiteValidator::class
)
->setMethods(['_clearMessages', '_addMessages'])
->setConstructorArgs([$this->storeResolver, $this->webSiteModel])
diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/ValidatorTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/ValidatorTest.php
index 5ca534284a48d..7f5002875f4b1 100644
--- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/ValidatorTest.php
+++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/ValidatorTest.php
@@ -3,29 +3,33 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\AdvancedPricingImportExport\Test\Unit\Model\Import\AdvancedPricing;
use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator as Validator;
use Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface as RowValidatorInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ValidatorTest extends \PHPUnit\Framework\TestCase
+class ValidatorTest extends TestCase
{
/**
- * @var Validator |\PHPUnit_Framework_MockObject_MockObject
+ * @var Validator|MockObject
*/
protected $validator;
/**
- * @var Validator |\PHPUnit_Framework_MockObject_MockObject
+ * @var Validator|MockObject
*/
protected $validators;
/**
- * @var RowValidatorInterface |\PHPUnit_Framework_MockObject_MockObject
+ * @var RowValidatorInterface|MockObject
*/
protected $validatorTest;
- protected function setUp()
+ protected function setUp(): void
{
$this->validatorTest = $this->getMockForAbstractClass(
\Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface::class,
@@ -34,7 +38,7 @@ protected function setUp()
false
);
$messages = ['messages'];
- $this->validatorTest->expects($this->any())->method('getMessages')->willReturn($messages);
+ $this->validatorTest->method('getMessages')->willReturn($messages);
$this->validators = [$this->validatorTest];
$this->validator = $this->getMockBuilder(
diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php
index fd968a2682d58..e57ed2c91409d 100644
--- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php
+++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php
@@ -3,17 +3,40 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\AdvancedPricingImportExport\Test\Unit\Model\Import;
use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing as AdvancedPricing;
+use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator;
+use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\TierPrice;
+use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\Website;
+use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\CatalogImportExport\Model\Import\Product;
use Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface as RowValidatorInterface;
+use Magento\CatalogImportExport\Model\Import\Product\StoreResolver;
use Magento\CatalogImportExport\Model\Import\Proxy\Product\ResourceModelFactory as ResourceFactory;
+use Magento\Eav\Model\Config;
+use Magento\Eav\Model\Entity\Type;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Select;
+use Magento\Framework\EntityManager\EntityMetadata;
+use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Framework\Json\Helper\Data;
+use Magento\Framework\Stdlib\DateTime\DateTime;
+use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
+use Magento\Framework\Stdlib\StringUtils;
+use Magento\ImportExport\Model\Import;
+use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
+use Magento\ImportExport\Model\ResourceModel\Helper;
+use Magento\ImportExport\Test\Unit\Model\Import\AbstractImportTestCase;
+use PHPUnit\Framework\MockObject\MockObject;
/**
* @SuppressWarnings(PHPMD)
*/
-class AdvancedPricingTest extends \Magento\ImportExport\Test\Unit\Model\Import\AbstractImportTestCase
+class AdvancedPricingTest extends AbstractImportTestCase
{
/**
* DB Table data
@@ -22,82 +45,82 @@ class AdvancedPricingTest extends \Magento\ImportExport\Test\Unit\Model\Import\A
const LINK_FIELD = 'linkField';
/**
- * @var ResourceFactory |\PHPUnit_Framework_MockObject_MockObject
+ * @var ResourceFactory|MockObject
*/
protected $resourceFactory;
/**
- * @var \Magento\Catalog\Helper\Data |\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Catalog\Helper\Data|MockObject
*/
protected $catalogData;
/**
- * @var \Magento\CatalogImportExport\Model\Import\Product\StoreResolver |\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreResolver|MockObject
*/
protected $storeResolver;
/**
- * @var \Magento\CatalogImportExport\Model\Import\Product|\PHPUnit_Framework_MockObject_MockObject
+ * @var Product|MockObject
*/
protected $importProduct;
/**
- * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Catalog\Model\Product|MockObject
*/
protected $productModel;
/**
- * @var AdvancedPricing\Validator |\PHPUnit_Framework_MockObject_MockObject
+ * @var AdvancedPricing\Validator|MockObject
*/
protected $validator;
/**
- * @var AdvancedPricing\Validator\Website |\PHPUnit_Framework_MockObject_MockObject
+ * @var AdvancedPricing\Validator\Website|MockObject
*/
protected $websiteValidator;
/**
- * @var AdvancedPricing\Validator\TierPrice |\PHPUnit_Framework_MockObject_MockObject
+ * @var AdvancedPricing\Validator\TierPrice|MockObject
*/
protected $tierPriceValidator;
/**
- * @var \Magento\ImportExport\Model\ResourceModel\Helper |\PHPUnit_Framework_MockObject_MockObject
+ * @var Helper|MockObject
*/
protected $resourceHelper;
/**
- * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AdapterInterface|MockObject
*/
protected $connection;
/**
- * @var \Magento\ImportExport\Model\ResourceModel\Import\Data|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\ImportExport\Model\ResourceModel\Import\Data|MockObject
*/
protected $dataSourceModel;
/**
- * @var \Magento\Eav\Model\Config
+ * @var Config
*/
protected $eavConfig;
/**
- * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var TimezoneInterface|MockObject
*/
protected $dateTime;
/**
- * @var \Magento\Framework\App\ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResourceConnection|MockObject
*/
protected $resource;
/**
- * @var \Magento\Framework\Json\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\Json\Helper\Data|MockObject
*/
protected $jsonHelper;
/**
- * @var \Magento\ImportExport\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\ImportExport\Helper\Data|MockObject
*/
protected $importExportData;
@@ -112,38 +135,38 @@ class AdvancedPricingTest extends \Magento\ImportExport\Test\Unit\Model\Import\A
protected $oldSkus;
/**
- * @var AdvancedPricing |\PHPUnit_Framework_MockObject_MockObject
+ * @var AdvancedPricing|MockObject
*/
protected $advancedPricing;
/**
- * @var \Magento\Framework\Stdlib\StringUtils
+ * @var StringUtils
*/
protected $stringObject;
/**
- * @var \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface
+ * @var ProcessingErrorAggregatorInterface
*/
protected $errorAggregator;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
- $this->jsonHelper = $this->createMock(\Magento\Framework\Json\Helper\Data::class);
+ $this->jsonHelper = $this->createMock(Data::class);
$this->importExportData = $this->createMock(\Magento\ImportExport\Helper\Data::class);
- $this->resourceHelper = $this->createMock(\Magento\ImportExport\Model\ResourceModel\Helper::class);
- $this->resource = $this->createPartialMock(\Magento\Framework\App\ResourceConnection::class, ['getConnection']);
+ $this->resourceHelper = $this->createMock(Helper::class);
+ $this->resource = $this->createPartialMock(ResourceConnection::class, ['getConnection']);
$this->connection = $this->getMockForAbstractClass(
- \Magento\Framework\DB\Adapter\AdapterInterface::class,
+ AdapterInterface::class,
[],
'',
false
);
- $this->resource->expects($this->any())->method('getConnection')->willReturn($this->connection);
+ $this->resource->method('getConnection')->willReturn($this->connection);
$this->dataSourceModel = $this->createMock(\Magento\ImportExport\Model\ResourceModel\Import\Data::class);
- $this->eavConfig = $this->createMock(\Magento\Eav\Model\Config::class);
- $entityType = $this->createMock(\Magento\Eav\Model\Entity\Type::class);
+ $this->eavConfig = $this->createMock(Config::class);
+ $entityType = $this->createMock(Type::class);
$entityType->method('getEntityTypeId')->willReturn('');
$this->eavConfig->method('getEntityType')->willReturn($entityType);
$this->resourceFactory = $this->getMockBuilder(
@@ -152,31 +175,32 @@ protected function setUp()
->setMethods(['create', 'getTable'])
->disableOriginalConstructor()
->getMock();
- $this->resourceFactory->expects($this->any())->method('create')->willReturnSelf();
- $this->resourceFactory->expects($this->any())->method('getTable')->willReturn(self::TABLE_NAME);
+ $this->resourceFactory->method('create')->willReturnSelf();
+ $this->resourceFactory->method('getTable')->willReturn(self::TABLE_NAME);
$this->catalogData = $this->createMock(\Magento\Catalog\Helper\Data::class);
$this->storeResolver = $this->createMock(
- \Magento\CatalogImportExport\Model\Import\Product\StoreResolver::class
+ StoreResolver::class
);
- $this->importProduct = $this->createMock(\Magento\CatalogImportExport\Model\Import\Product::class);
+ $this->importProduct = $this->createMock(Product::class);
$this->productModel = $this->createMock(\Magento\Catalog\Model\Product::class);
$this->validator = $this->createPartialMock(
- \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator::class,
+ Validator::class,
['isValid', 'getMessages']
);
$this->websiteValidator = $this->createMock(
- \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\Website::class
+ Website::class
);
$this->tierPriceValidator = $this->createMock(
- \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\TierPrice::class
+ TierPrice::class
);
- $this->stringObject = $this->createMock(\Magento\Framework\Stdlib\StringUtils::class);
+ $this->stringObject = $this->createMock(StringUtils::class);
$this->errorAggregator = $this->getErrorAggregatorObject();
- $this->dateTime = $this->createPartialMock(
- \Magento\Framework\Stdlib\DateTime\DateTime::class,
- ['date', 'format']
- );
- $this->dateTime->expects($this->any())->method('date')->willReturnSelf();
+ $this->dateTime = $this->getMockBuilder(DateTime::class)
+ ->disableOriginalConstructor()
+ ->addMethods(['format'])
+ ->onlyMethods(['date'])
+ ->getMock();
+ $this->dateTime->method('date')->willReturnSelf();
$this->advancedPricing = $this->getAdvancedPricingMock(
[
@@ -194,7 +218,7 @@ protected function setUp()
]
);
- $this->advancedPricing->expects($this->any())->method('retrieveOldSkus')->willReturn([]);
+ $this->advancedPricing->method('retrieveOldSkus')->willReturn([]);
}
/**
@@ -230,8 +254,8 @@ public function testValidateRowResult($rowData, $behavior, $expectedResult)
'getBehavior',
]
);
- $this->validator->expects($this->any())->method('isValid')->willReturn(true);
- $advancedPricingMock->expects($this->any())->method('getBehavior')->willReturn($behavior);
+ $this->validator->method('isValid')->willReturn(true);
+ $advancedPricingMock->method('getBehavior')->willReturn($behavior);
$result = $advancedPricingMock->validateRow($rowData, $rowNum);
$this->assertEquals($expectedResult, $result);
@@ -259,8 +283,8 @@ public function testValidateRowAddRowErrorCall($rowData, $behavior, $error)
'getBehavior',
]
);
- $this->validator->expects($this->any())->method('isValid')->willReturn(true);
- $advancedPricingMock->expects($this->any())->method('getBehavior')->willReturn($behavior);
+ $this->validator->method('isValid')->willReturn(true);
+ $advancedPricingMock->method('getBehavior')->willReturn($behavior);
$advancedPricingMock->expects($this->once())->method('addRowError')->with($error, $rowNum);
$advancedPricingMock->validateRow($rowData, $rowNum);
@@ -306,7 +330,7 @@ public function testSaveAndReplaceAdvancedPricesAddRowErrorCall()
];
$this->dataSourceModel->expects($this->at(0))->method('getNextBunch')->willReturn($testBunch);
$this->advancedPricing->expects($this->once())->method('validateRow')->willReturn(false);
- $this->advancedPricing->expects($this->any())->method('saveProductPrices')->will($this->returnSelf());
+ $this->advancedPricing->method('saveProductPrices')->willReturnSelf();
$this->advancedPricing
->expects($this->once())
@@ -368,19 +392,18 @@ public function testSaveAndReplaceAdvancedPricesAppendBehaviourDataAndCalls(
]
);
$advancedPricing
- ->expects($this->any())
->method('getBehavior')
- ->willReturn(\Magento\ImportExport\Model\Import::BEHAVIOR_APPEND);
+ ->willReturn(Import::BEHAVIOR_APPEND);
$this->dataSourceModel->expects($this->at(0))->method('getNextBunch')->willReturn($data);
- $advancedPricing->expects($this->any())->method('validateRow')->willReturn(true);
+ $advancedPricing->method('validateRow')->willReturn(true);
- $advancedPricing->expects($this->any())->method('getCustomerGroupId')->willReturnMap(
+ $advancedPricing->method('getCustomerGroupId')->willReturnMap(
[
[$data[0][AdvancedPricing::COL_TIER_PRICE_CUSTOMER_GROUP], $tierCustomerGroupId],
]
);
- $advancedPricing->expects($this->any())->method('getWebSiteId')->willReturnMap(
+ $advancedPricing->method('getWebSiteId')->willReturnMap(
[
[$data[0][AdvancedPricing::COL_TIER_PRICE_WEBSITE], $tierWebsiteId],
]
@@ -393,8 +416,8 @@ public function testSaveAndReplaceAdvancedPricesAppendBehaviourDataAndCalls(
->method('insertOnDuplicate')
->with(self::TABLE_NAME, $expectedTierPrices[$sku], ['value', 'percentage_value']);
- $advancedPricing->expects($this->any())->method('processCountExistingPrices')->willReturnSelf();
- $advancedPricing->expects($this->any())->method('processCountNewPrices')->willReturnSelf();
+ $advancedPricing->method('processCountExistingPrices')->willReturnSelf();
+ $advancedPricing->method('processCountNewPrices')->willReturnSelf();
$result = $this->invokeMethod($advancedPricing, 'saveAndReplaceAdvancedPrices');
@@ -437,19 +460,18 @@ public function testSaveAndReplaceAdvancedPricesAppendBehaviourDataAndCallsWitho
]
);
$advancedPricing
- ->expects($this->any())
->method('getBehavior')
- ->willReturn(\Magento\ImportExport\Model\Import::BEHAVIOR_APPEND);
+ ->willReturn(Import::BEHAVIOR_APPEND);
$this->dataSourceModel->expects($this->at(0))->method('getNextBunch')->willReturn($data);
- $advancedPricing->expects($this->any())->method('validateRow')->willReturn(true);
+ $advancedPricing->method('validateRow')->willReturn(true);
- $advancedPricing->expects($this->any())->method('getCustomerGroupId')->willReturnMap(
+ $advancedPricing->method('getCustomerGroupId')->willReturnMap(
[
[$data[0][AdvancedPricing::COL_TIER_PRICE_CUSTOMER_GROUP], $tierCustomerGroupId],
]
);
- $advancedPricing->expects($this->any())->method('getWebSiteId')->willReturnMap(
+ $advancedPricing->method('getWebSiteId')->willReturnMap(
[
[$data[0][AdvancedPricing::COL_TIER_PRICE_WEBSITE], $tierWebsiteId],
]
@@ -462,8 +484,8 @@ public function testSaveAndReplaceAdvancedPricesAppendBehaviourDataAndCallsWitho
->method('insertOnDuplicate')
->with(self::TABLE_NAME, $expectedTierPrices[$sku], ['value', 'percentage_value']);
- $advancedPricing->expects($this->any())->method('processCountExistingPrices')->willReturnSelf();
- $advancedPricing->expects($this->any())->method('processCountNewPrices')->willReturnSelf();
+ $advancedPricing->method('processCountExistingPrices')->willReturnSelf();
+ $advancedPricing->method('processCountNewPrices')->willReturnSelf();
$result = $this->invokeMethod($advancedPricing, 'saveAndReplaceAdvancedPrices');
@@ -485,8 +507,8 @@ public function testSaveAndReplaceAdvancedPricesReplaceBehaviourInternalCalls()
$listSku = [
$skuVal
];
- $this->advancedPricing->expects($this->any())->method('getBehavior')->willReturn(
- \Magento\ImportExport\Model\Import::BEHAVIOR_REPLACE
+ $this->advancedPricing->method('getBehavior')->willReturn(
+ Import::BEHAVIOR_REPLACE
);
$this->dataSourceModel->expects($this->at(0))->method('getNextBunch')->willReturn($data);
$this->advancedPricing->expects($this->once())->method('validateRow')->willReturn(true);
@@ -499,7 +521,6 @@ public function testSaveAndReplaceAdvancedPricesReplaceBehaviourInternalCalls()
->method('getWebSiteId');
$this->advancedPricing
- ->expects($this->any())
->method('deleteProductTierPrices')
->withConsecutive(
[
@@ -510,7 +531,6 @@ public function testSaveAndReplaceAdvancedPricesReplaceBehaviourInternalCalls()
->willReturn(true);
$this->advancedPricing
- ->expects($this->any())
->method('saveProductPrices')
->withConsecutive(
[
@@ -518,7 +538,7 @@ public function testSaveAndReplaceAdvancedPricesReplaceBehaviourInternalCalls()
AdvancedPricing::TABLE_TIER_PRICE
]
)
- ->will($this->returnSelf());
+ ->willReturnSelf();
$this->invokeMethod($this->advancedPricing, 'saveAndReplaceAdvancedPrices');
}
@@ -540,14 +560,14 @@ public function testDeleteAdvancedPricingFormListSkuToDelete()
];
$this->dataSourceModel->expects($this->at(0))->method('getNextBunch')->willReturn($data);
- $this->advancedPricing->expects($this->any())->method('validateRow')->willReturn(true);
+ $this->advancedPricing->method('validateRow')->willReturn(true);
$expectedSkuList = ['sku value'];
$this->advancedPricing
->expects($this->once())
->method('deleteProductTierPrices')
->withConsecutive(
[$expectedSkuList, AdvancedPricing::TABLE_TIER_PRICE]
- )->will($this->returnSelf());
+ )->willReturnSelf();
$this->advancedPricing->deleteAdvancedPricing();
}
@@ -728,14 +748,14 @@ public function validateRowResultDataProvider()
'$rowData' => [
AdvancedPricing::COL_SKU => null,
],
- '$behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE,
+ '$behavior' => Import::BEHAVIOR_DELETE,
'$expectedResult' => false,
],
[
'$rowData' => [
AdvancedPricing::COL_SKU => 'sku value',
],
- '$behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE,
+ '$behavior' => Import::BEHAVIOR_DELETE,
'$expectedResult' => true,
]
];
@@ -753,7 +773,7 @@ public function validateRowAddRowErrorCallDataProvider()
'$rowData' => [
AdvancedPricing::COL_SKU => null,
],
- '$behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE,
+ '$behavior' => Import::BEHAVIOR_DELETE,
'$error' => RowValidatorInterface::ERROR_SKU_IS_EMPTY,
],
[
@@ -777,7 +797,7 @@ public function testSaveProductPrices($priceData, $oldSkus, $priceIn, $callNum)
{
$this->advancedPricing = $this->getAdvancedPricingMock(['retrieveOldSkus']);
- $this->advancedPricing->expects($this->any())->method('retrieveOldSkus')->willReturn($oldSkus);
+ $this->advancedPricing->method('retrieveOldSkus')->willReturn($oldSkus);
$this->connection->expects($this->exactly($callNum))
->method('insertOnDuplicate')
@@ -826,7 +846,7 @@ public function testDeleteProductTierPrices(
$result
) {
$this->advancedPricing = $this->getAdvancedPricingMock(['addRowError', 'retrieveOldSkus']);
- $dbSelectMock = $this->createMock(\Magento\Framework\DB\Select::class);
+ $dbSelectMock = $this->createMock(Select::class);
if ($listSku) {
$this->connection->expects($this->once())
->method('fetchCol')
@@ -922,7 +942,7 @@ public function testProcessCountExistingPrices(
'retrieveOldSkus'
]
);
- $dbSelectMock = $this->createMock(\Magento\Framework\DB\Select::class);
+ $dbSelectMock = $this->createMock(Select::class);
$this->connection->expects($this->once())
->method('fetchAll')
->willReturn($existingPrices);
@@ -1027,19 +1047,19 @@ private function invokeMethod($object, $method, $args = [])
*
* @param array $methods
*
- * @return \PHPUnit_Framework_MockObject_MockObject
+ * @return MockObject
* @throws \ReflectionException
*/
private function getAdvancedPricingMock($methods = [])
{
- $metadataPoolMock = $this->createMock(\Magento\Framework\EntityManager\MetadataPool::class);
- $metadataMock = $this->createMock(\Magento\Framework\EntityManager\EntityMetadata::class);
- $metadataMock->expects($this->any())
+ $metadataPoolMock = $this->createMock(MetadataPool::class);
+ $metadataMock = $this->createMock(EntityMetadata::class);
+ $metadataMock
->method('getLinkField')
->willReturn(self::LINK_FIELD);
- $metadataPoolMock->expects($this->any())
+ $metadataPoolMock
->method('getMetaData')
- ->with(\Magento\Catalog\Api\Data\ProductInterface::class)
+ ->with(ProductInterface::class)
->willReturn($metadataMock);
$advancedPricingMock = $this->getMockBuilder(
\Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing::class
diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php
index e2afe10137f27..0bde9c2a265c7 100644
--- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php
+++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php
@@ -3,53 +3,60 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\AdvancedPricingImportExport\Test\Unit\Model\Indexer\Product\Price\Plugin;
+use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing;
use Magento\AdvancedPricingImportExport\Model\Indexer\Product\Price\Plugin\Import as Import;
+use Magento\Catalog\Model\Indexer\Product\Price\Processor;
+use Magento\Framework\Indexer\IndexerInterface;
+use Magento\Framework\Indexer\IndexerRegistry;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ImportTest extends \PHPUnit\Framework\TestCase
+class ImportTest extends TestCase
{
/**
- * @var \Magento\Framework\Indexer\IndexerInterface |\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerInterface|MockObject
*/
private $indexer;
/**
- * @var Import |\PHPUnit_Framework_MockObject_MockObject
+ * @var Import|MockObject
*/
private $import;
/**
- * @var \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing|\PHPUnit_Framework_MockObject_MockObject
+ * @var AdvancedPricing|MockObject
*/
private $advancedPricing;
/**
- * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerRegistry|MockObject
*/
private $indexerRegistry;
- protected function setUp()
+ protected function setUp(): void
{
$this->indexer = $this->getMockForAbstractClass(
- \Magento\Framework\Indexer\IndexerInterface::class,
+ IndexerInterface::class,
[],
'',
false
);
$this->indexerRegistry = $this->createMock(
- \Magento\Framework\Indexer\IndexerRegistry::class
+ IndexerRegistry::class
);
$this->import = new \Magento\AdvancedPricingImportExport\Model\Indexer\Product\Price\Plugin\Import(
$this->indexerRegistry
);
$this->advancedPricing = $this->createMock(
- \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing::class
+ AdvancedPricing::class
);
- $this->indexerRegistry->expects($this->any())
+ $this->indexerRegistry
->method('get')
- ->with(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID)
+ ->with(Processor::INDEXER_ID)
->willReturn($this->indexer);
}
diff --git a/app/code/Magento/AdvancedPricingImportExport/composer.json b/app/code/Magento/AdvancedPricingImportExport/composer.json
index 767c1a9cd4164..ea6a39fba2c3d 100644
--- a/app/code/Magento/AdvancedPricingImportExport/composer.json
+++ b/app/code/Magento/AdvancedPricingImportExport/composer.json
@@ -5,7 +5,7 @@
"sort-packages": true
},
"require": {
- "php": "~7.1.3||~7.2.0||~7.3.0",
+ "php": "~7.3.0||~7.4.0",
"magento/framework": "*",
"magento/module-catalog": "*",
"magento/module-catalog-import-export": "*",
diff --git a/app/code/Magento/AdvancedSearch/Test/Mftf/ActionGroup/AdminFillSearchTermActionGroup.xml b/app/code/Magento/AdvancedSearch/Test/Mftf/ActionGroup/AdminFillSearchTermActionGroup.xml
new file mode 100644
index 0000000000000..e402ec0391c0a
--- /dev/null
+++ b/app/code/Magento/AdvancedSearch/Test/Mftf/ActionGroup/AdminFillSearchTermActionGroup.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+ Fills the search terms form with sample data.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/AdvancedSearch/Test/Mftf/ActionGroup/AdminOpenNewSearchTermsPageActionGroup.xml b/app/code/Magento/AdvancedSearch/Test/Mftf/ActionGroup/AdminOpenNewSearchTermsPageActionGroup.xml
new file mode 100644
index 0000000000000..2fbbab8a55721
--- /dev/null
+++ b/app/code/Magento/AdvancedSearch/Test/Mftf/ActionGroup/AdminOpenNewSearchTermsPageActionGroup.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+ Navigate to search terms form page.
+
+
+
+
+
diff --git a/app/code/Magento/AdvancedSearch/Test/Mftf/ActionGroup/AdminSaveSearchTermActionGroup.xml b/app/code/Magento/AdvancedSearch/Test/Mftf/ActionGroup/AdminSaveSearchTermActionGroup.xml
new file mode 100644
index 0000000000000..cac996d97a6bf
--- /dev/null
+++ b/app/code/Magento/AdvancedSearch/Test/Mftf/ActionGroup/AdminSaveSearchTermActionGroup.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+ Save a new search term from Magento admin.
+
+
+
+
+
diff --git a/app/code/Magento/AdvancedSearch/Test/Mftf/Data/SearchTermsData.xml b/app/code/Magento/AdvancedSearch/Test/Mftf/Data/SearchTermsData.xml
new file mode 100644
index 0000000000000..913784afe66ea
--- /dev/null
+++ b/app/code/Magento/AdvancedSearch/Test/Mftf/Data/SearchTermsData.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+ books
+ Default Store View
+ http://sample.com
+ 1
+
+
diff --git a/app/code/Magento/AdvancedSearch/Test/Mftf/Page/AdminSearchTermsFormPage.xml b/app/code/Magento/AdvancedSearch/Test/Mftf/Page/AdminSearchTermsFormPage.xml
new file mode 100644
index 0000000000000..b8997093de840
--- /dev/null
+++ b/app/code/Magento/AdvancedSearch/Test/Mftf/Page/AdminSearchTermsFormPage.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/AdvancedSearch/Test/Mftf/Section/AdminSearchTermsPageFormFieldsSection.xml b/app/code/Magento/AdvancedSearch/Test/Mftf/Section/AdminSearchTermsPageFormFieldsSection.xml
new file mode 100644
index 0000000000000..ba593b332bf8a
--- /dev/null
+++ b/app/code/Magento/AdvancedSearch/Test/Mftf/Section/AdminSearchTermsPageFormFieldsSection.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/AdvancedSearch/Test/Mftf/Test/AdminAddSearchTermTest.xml b/app/code/Magento/AdvancedSearch/Test/Mftf/Test/AdminAddSearchTermTest.xml
new file mode 100644
index 0000000000000..88c04263a1bc5
--- /dev/null
+++ b/app/code/Magento/AdvancedSearch/Test/Mftf/Test/AdminAddSearchTermTest.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/AdvancedSearch/Test/Unit/Block/SearchDataTest.php b/app/code/Magento/AdvancedSearch/Test/Unit/Block/SearchDataTest.php
index 14065ef2a9a18..a677094d5d3d0 100644
--- a/app/code/Magento/AdvancedSearch/Test/Unit/Block/SearchDataTest.php
+++ b/app/code/Magento/AdvancedSearch/Test/Unit/Block/SearchDataTest.php
@@ -3,96 +3,111 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\AdvancedSearch\Test\Unit\Block;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use Magento\AdvancedSearch\Block\SearchData;
+use Magento\AdvancedSearch\Model\SuggestedQueriesInterface;
+use Magento\Framework\View\Element\Template\Context as TemplateContext;
+use Magento\Search\Model\QueryFactoryInterface;
+use Magento\Search\Model\QueryInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class SearchDataTest extends \PHPUnit\Framework\TestCase
+/**
+ * @covers \Magento\AdvancedSearch\Block\SearchData
+ */
+class SearchDataTest extends TestCase
{
- /** @var \Magento\Framework\View\Element\Template\Context|MockObject */
- private $context;
+ /**
+ * Testable Object
+ *
+ * @var SearchData
+ */
+ private $block;
/**
- * @var \Magento\Search\Model\QueryFactoryInterface|MockObject
+ * @var TemplateContext|MockObject
*/
- private $queryFactory;
+ private $contextMock;
/**
- * @var \Magento\Search\Model\Query|MockObject
+ * @var QueryFactoryInterface|MockObject
*/
- private $searchQuery;
+ private $queryFactoryMock;
/**
- * @var \Magento\AdvancedSearch\Model\SuggestedQueriesInterface|MockObject
+ * @var QueryInterface|MockObject
*/
- private $dataProvider;
+ private $searchQueryMock;
/**
- * @var \Magento\AdvancedSearch\Block\SearchData
+ * @var SuggestedQueriesInterface|MockObject
*/
- private $block;
+ private $dataProvider;
- protected function setUp()
+ protected function setUp(): void
{
- $this->dataProvider = $this->getMockBuilder(\Magento\AdvancedSearch\Model\SuggestedQueriesInterface::class)
+ $this->dataProvider = $this->getMockBuilder(SuggestedQueriesInterface::class)
->disableOriginalConstructor()
->setMethods(['getItems', 'isResultsCountEnabled'])
->getMockForAbstractClass();
- $this->searchQuery = $this->getMockBuilder(\Magento\Search\Model\QueryInterface::class)
+ $this->searchQueryMock = $this->getMockBuilder(QueryInterface::class)
->disableOriginalConstructor()
->setMethods(['getQueryText'])
->getMockForAbstractClass();
- $this->queryFactory = $this->getMockBuilder(\Magento\Search\Model\QueryFactoryInterface::class)
+ $this->queryFactoryMock = $this->getMockBuilder(QueryFactoryInterface::class)
->disableOriginalConstructor()
->setMethods(['get'])
->getMockForAbstractClass();
- $this->queryFactory->expects($this->once())
+ $this->queryFactoryMock->expects($this->once())
->method('get')
- ->will($this->returnValue($this->searchQuery));
- $this->context = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class)
+ ->willReturn($this->searchQueryMock);
+ $this->contextMock = $this->getMockBuilder(TemplateContext::class)
->disableOriginalConstructor()
->getMock();
- $this->block = $this->getMockBuilder(\Magento\AdvancedSearch\Block\SearchData::class)->setConstructorArgs(
- [
- $this->context,
- $this->dataProvider,
- $this->queryFactory,
- 'Test Title',
- [],
- ]
- )
+ $this->block = $this->getMockBuilder(SearchData::class)
+ ->setConstructorArgs(
+ [
+ $this->contextMock,
+ $this->dataProvider,
+ $this->queryFactoryMock,
+ 'Test Title',
+ [],
+ ]
+ )
->setMethods(['getUrl'])
->getMockForAbstractClass();
}
- public function testGetSuggestions()
+ public function testGetSuggestions(): void
{
$value = [1, 2, 3, 100500];
$this->dataProvider->expects($this->once())
->method('getItems')
- ->with($this->searchQuery)
- ->will($this->returnValue($value));
+ ->with($this->searchQueryMock)
+ ->willReturn($value);
$actualValue = $this->block->getItems();
$this->assertEquals($value, $actualValue);
}
- public function testGetLink()
+ public function testGetLink(): void
{
- $searchQuery = 'Some test search query';
+ $searchQueryMock = 'Some test search query';
$expectedResult = '?q=Some+test+search+query';
- $actualResult = $this->block->getLink($searchQuery);
+ $actualResult = $this->block->getLink($searchQueryMock);
$this->assertEquals($expectedResult, $actualResult);
}
- public function testIsShowResultsCount()
+ public function testIsShowResultsCount(): void
{
$value = 'qwertyasdfzxcv';
$this->dataProvider->expects($this->once())
->method('isResultsCountEnabled')
- ->will($this->returnValue($value));
+ ->willReturn($value);
$this->assertEquals($value, $this->block->isShowResultsCount());
}
}
diff --git a/app/code/Magento/AdvancedSearch/Test/Unit/Controller/Adminhtml/Search/System/Config/TestConnectionTest.php b/app/code/Magento/AdvancedSearch/Test/Unit/Controller/Adminhtml/Search/System/Config/TestConnectionTest.php
index 6215d79fc41ee..1895603920ff8 100644
--- a/app/code/Magento/AdvancedSearch/Test/Unit/Controller/Adminhtml/Search/System/Config/TestConnectionTest.php
+++ b/app/code/Magento/AdvancedSearch/Test/Unit/Controller/Adminhtml/Search/System/Config/TestConnectionTest.php
@@ -3,96 +3,108 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\AdvancedSearch\Test\Unit\Controller\Adminhtml\Search\System\Config;
use Magento\AdvancedSearch\Controller\Adminhtml\Search\System\Config\TestConnection;
-use Magento\AdvancedSearch\Model\Client\ClientResolver;
use Magento\AdvancedSearch\Model\Client\ClientInterface;
+use Magento\AdvancedSearch\Model\Client\ClientResolver;
+use Magento\Backend\App\Action\Context;
+use Magento\Framework\App\Request\Http as HttpRequest;
+use Magento\Framework\App\Response\Http as HttpResponse;
+use Magento\Framework\Controller\Result\Json;
+use Magento\Framework\Controller\Result\JsonFactory;
+use Magento\Framework\Filter\StripTags;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
- * Class TestConnectionTest
- *
+ * @covers \Magento\AdvancedSearch\Controller\Adminhtml\Search\System\Config\TestConnection
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class TestConnectionTest extends \PHPUnit\Framework\TestCase
+class TestConnectionTest extends TestCase
{
/**
- * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject
+ * Testable Object
+ *
+ * @var TestConnection
*/
- protected $requestMock;
+ private $controller;
/**
- * @var ClientResolver|\PHPUnit_Framework_MockObject_MockObject
+ * @var HttpRequest|MockObject
*/
- private $clientResolverMock;
+ private $requestMock;
/**
- * @var ClientInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ClientResolver|MockObject
*/
- private $clientMock;
+ private $clientResolverMock;
/**
- * @var \Magento\Framework\Controller\Result\Json|\PHPUnit_Framework_MockObject_MockObject
+ * @var ClientInterface|MockObject
*/
- private $resultJson;
+ private $clientMock;
/**
- * @var \Magento\Framework\Controller\Result\JsonFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var Json|MockObject
*/
- private $resultJsonFactory;
+ private $resultJsonMock;
/**
- * @var \Magento\Framework\Filter\StripTags|\PHPUnit_Framework_MockObject_MockObject
+ * @var JsonFactory|MockObject
*/
- private $tagFilterMock;
+ private $resultJsonFactoryMock;
/**
- * @var TestConnection
+ * @var StripTags|MockObject
*/
- private $controller;
+ private $tagFilterMock;
/**
* Setup test function
*
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->requestMock = $this->createPartialMock(\Magento\Framework\App\Request\Http::class, ['getParams']);
- $responseMock = $this->createMock(\Magento\Framework\App\Response\Http::class);
+ $helper = new ObjectManager($this);
+ $this->requestMock = $this->createPartialMock(HttpRequest::class, ['getParams']);
+ $responseMock = $this->createMock(HttpResponse::class);
- $context = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class)
+ $context = $this->getMockBuilder(Context::class)
->setMethods(['getRequest', 'getResponse', 'getMessageManager', 'getSession'])
->setConstructorArgs(
$helper->getConstructArguments(
- \Magento\Backend\App\Action\Context::class,
+ Context::class,
[
'request' => $this->requestMock
]
)
)
->getMock();
- $context->expects($this->once())->method('getRequest')->will($this->returnValue($this->requestMock));
- $context->expects($this->once())->method('getResponse')->will($this->returnValue($responseMock));
+ $context->expects($this->once())->method('getRequest')->willReturn($this->requestMock);
+ $context->expects($this->once())->method('getResponse')->willReturn($responseMock);
- $this->clientResolverMock = $this->getMockBuilder(\Magento\AdvancedSearch\Model\Client\ClientResolver::class)
+ $this->clientResolverMock = $this->getMockBuilder(ClientResolver::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
- $this->clientMock = $this->createMock(\Magento\AdvancedSearch\Model\Client\ClientInterface::class);
+ $this->clientMock = $this->getMockForAbstractClass(ClientInterface::class);
- $this->resultJson = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class)
+ $this->resultJsonMock = $this->getMockBuilder(Json::class)
->disableOriginalConstructor()
->getMock();
- $this->resultJsonFactory = $this->getMockBuilder(\Magento\Framework\Controller\Result\JsonFactory::class)
+ $this->resultJsonFactoryMock = $this->getMockBuilder(JsonFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
- $this->tagFilterMock = $this->getMockBuilder(\Magento\Framework\Filter\StripTags::class)
+ $this->tagFilterMock = $this->getMockBuilder(StripTags::class)
->disableOriginalConstructor()
->setMethods(['filter'])
->getMock();
@@ -100,69 +112,69 @@ protected function setUp()
$this->controller = new TestConnection(
$context,
$this->clientResolverMock,
- $this->resultJsonFactory,
+ $this->resultJsonFactoryMock,
$this->tagFilterMock
);
}
- public function testExecuteEmptyEngine()
+ public function testExecuteEmptyEngine(): void
{
$this->requestMock->expects($this->once())->method('getParams')
- ->will($this->returnValue(['engine' => '']));
+ ->willReturn(['engine' => '']);
- $this->resultJsonFactory->expects($this->once())->method('create')
- ->will($this->returnValue($this->resultJson));
+ $this->resultJsonFactoryMock->expects($this->once())->method('create')
+ ->willReturn($this->resultJsonMock);
$result = ['success' => false, 'errorMessage' => 'Missing search engine parameter.'];
- $this->resultJson->expects($this->once())->method('setData')
- ->with($this->equalTo($result));
+ $this->resultJsonMock->expects($this->once())->method('setData')
+ ->with($result);
$this->controller->execute();
}
- public function testExecute()
+ public function testExecute(): void
{
$this->requestMock->expects($this->once())->method('getParams')
- ->will($this->returnValue(['engine' => 'engineName']));
+ ->willReturn(['engine' => 'engineName']);
$this->clientResolverMock->expects($this->once())->method('create')
- ->with($this->equalTo('engineName'))
- ->will($this->returnValue($this->clientMock));
+ ->with('engineName')
+ ->willReturn($this->clientMock);
$this->clientMock->expects($this->once())->method('testConnection')
- ->will($this->returnValue(true));
+ ->willReturn(true);
- $this->resultJsonFactory->expects($this->once())->method('create')
- ->will($this->returnValue($this->resultJson));
+ $this->resultJsonFactoryMock->expects($this->once())->method('create')
+ ->willReturn($this->resultJsonMock);
$result = ['success' => true, 'errorMessage' => ''];
- $this->resultJson->expects($this->once())->method('setData')
- ->with($this->equalTo($result));
+ $this->resultJsonMock->expects($this->once())->method('setData')
+ ->with($result);
$this->controller->execute();
}
- public function testExecutePingFailed()
+ public function testExecutePingFailed(): void
{
$this->requestMock->expects($this->once())->method('getParams')
- ->will($this->returnValue(['engine' => 'engineName']));
+ ->willReturn(['engine' => 'engineName']);
$this->clientResolverMock->expects($this->once())->method('create')
- ->with($this->equalTo('engineName'))
- ->will($this->returnValue($this->clientMock));
+ ->with('engineName')
+ ->willReturn($this->clientMock);
$this->clientMock->expects($this->once())->method('testConnection')
- ->will($this->returnValue(false));
+ ->willReturn(false);
- $this->resultJsonFactory->expects($this->once())->method('create')
- ->will($this->returnValue($this->resultJson));
+ $this->resultJsonFactoryMock->expects($this->once())->method('create')
+ ->willReturn($this->resultJsonMock);
$result = ['success' => false, 'errorMessage' => ''];
- $this->resultJson->expects($this->once())->method('setData')
- ->with($this->equalTo($result));
+ $this->resultJsonMock->expects($this->once())->method('setData')
+ ->with($result);
$this->controller->execute();
}
diff --git a/app/code/Magento/AdvancedSearch/Test/Unit/Model/Client/ClientResolverTest.php b/app/code/Magento/AdvancedSearch/Test/Unit/Model/Client/ClientResolverTest.php
index 0cad0a2e8301c..dc4c1a3659d21 100644
--- a/app/code/Magento/AdvancedSearch/Test/Unit/Model/Client/ClientResolverTest.php
+++ b/app/code/Magento/AdvancedSearch/Test/Unit/Model/Client/ClientResolverTest.php
@@ -3,39 +3,49 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\AdvancedSearch\Test\Unit\Model\Client;
+use InvalidArgumentException;
+use LogicException;
use Magento\AdvancedSearch\Model\Client\ClientFactoryInterface;
use Magento\AdvancedSearch\Model\Client\ClientInterface;
use Magento\AdvancedSearch\Model\Client\ClientOptionsInterface;
use Magento\AdvancedSearch\Model\Client\ClientResolver;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Search\EngineResolverInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ClientResolverTest extends \PHPUnit\Framework\TestCase
+/**
+ * @covers \Magento\AdvancedSearch\Model\Client\ClientResolver
+ */
+class ClientResolverTest extends TestCase
{
/**
- * @var ClientResolver|\PHPUnit_Framework_MockObject_MockObject
+ * Testable Object
+ *
+ * @var ClientResolver
*/
private $model;
/**
- * @var ObjectManagerInterface |\PHPUnit_Framework_MockObject_MockObject
+ * @var ObjectManagerInterface|MockObject
*/
private $objectManager;
/**
- * @var EngineResolverInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var EngineResolverInterface|MockObject
*/
private $engineResolverMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->engineResolverMock = $this->getMockBuilder(EngineResolverInterface::class)
->getMockForAbstractClass();
- $this->objectManager = $this->createMock(ObjectManagerInterface::class);
+ $this->objectManager = $this->getMockForAbstractClass(ObjectManagerInterface::class);
$this->model = new ClientResolver(
$this->objectManager,
@@ -45,16 +55,16 @@ protected function setUp()
);
}
- public function testCreate()
+ public function testCreate(): void
{
$this->engineResolverMock->expects($this->once())->method('getCurrentSearchEngine')
- ->will($this->returnValue('engineName'));
+ ->willReturn('engineName');
- $factoryMock = $this->createMock(ClientFactoryInterface::class);
+ $factoryMock = $this->getMockForAbstractClass(ClientFactoryInterface::class);
- $clientMock = $this->createMock(ClientInterface::class);
+ $clientMock = $this->getMockForAbstractClass(ClientInterface::class);
- $clientOptionsMock = $this->createMock(ClientOptionsInterface::class);
+ $clientOptionsMock = $this->getMockForAbstractClass(ClientOptionsInterface::class);
$this->objectManager->expects($this->exactly(2))->method('create')
->withConsecutive(
@@ -68,40 +78,36 @@ public function testCreate()
$clientOptionsMock->expects($this->once())->method('prepareClientOptions')
->with([])
- ->will($this->returnValue(['parameters']));
+ ->willReturn(['parameters']);
$factoryMock->expects($this->once())->method('create')
- ->with($this->equalTo(['parameters']))
- ->will($this->returnValue($clientMock));
+ ->with(['parameters'])
+ ->willReturn($clientMock);
$result = $this->model->create();
$this->assertInstanceOf(ClientInterface::class, $result);
}
- /**
- * @expectedException \InvalidArgumentException
- */
- public function testCreateExceptionThrown()
+ public function testCreateExceptionThrown(): void
{
+ $this->expectException(InvalidArgumentException::class);
$this->objectManager->expects($this->once())->method('create')
- ->with($this->equalTo('engineFactoryClass'))
- ->will($this->returnValue('t'));
+ ->with('engineFactoryClass')
+ ->willReturn('t');
$this->model->create('engineName');
}
- /**
- * @expectedException LogicException
- */
- public function testCreateLogicException()
+ public function testCreateLogicException(): void
{
+ $this->expectException(LogicException::class);
$this->model->create('input');
}
- public function testGetCurrentEngine()
+ public function testGetCurrentEngine(): void
{
$this->engineResolverMock->expects($this->once())->method('getCurrentSearchEngine')
- ->will($this->returnValue('engineName'));
+ ->willReturn('engineName');
$this->assertEquals('engineName', $this->model->getCurrentEngine());
}
diff --git a/app/code/Magento/AdvancedSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/CustomerGroupTest.php b/app/code/Magento/AdvancedSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/CustomerGroupTest.php
index e6de135aab473..6991ceec93e47 100644
--- a/app/code/Magento/AdvancedSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/CustomerGroupTest.php
+++ b/app/code/Magento/AdvancedSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/CustomerGroupTest.php
@@ -3,52 +3,65 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\AdvancedSearch\Test\Unit\Model\Indexer\Fulltext\Plugin;
-use Magento\AdvancedSearch\Model\Indexer\Fulltext\Plugin\CustomerGroup;
+use Magento\AdvancedSearch\Model\Client\ClientOptionsInterface;
+use Magento\AdvancedSearch\Model\Indexer\Fulltext\Plugin\CustomerGroup as CustomerGroupPlugin;
+use Magento\CatalogSearch\Model\Indexer\Fulltext as FulltextIndexer;
+use Magento\Customer\Model\Group as CustomerGroupModel;
+use Magento\Customer\Model\ResourceModel\Group as CustomerGroupResourceModel;
+use Magento\Framework\Indexer\IndexerInterface;
+use Magento\Framework\Indexer\IndexerRegistry;
use Magento\Framework\Search\EngineResolverInterface;
+use PHPUnit\Framework\TestCase;
-class CustomerGroupTest extends \PHPUnit\Framework\TestCase
+/**
+ * @covers \Magento\AdvancedSearch\Model\Indexer\Fulltext\Plugin\CustomerGroup
+ */
+class CustomerGroupTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Indexer\IndexerInterface
+ * Testable Object
+ *
+ * @var CustomerGroupPlugin
*/
- protected $indexerMock;
+ private $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Customer\Model\ResourceModel\Group
+ * @var IndexerInterface|MockObject
*/
- protected $subjectMock;
+ private $indexerMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\AdvancedSearch\Model\Client\ClientOptionsInterface
+ * @var Group|MockObject
*/
- protected $customerOptionsMock;
+ private $subjectMock;
/**
- * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject
+ * @var ClientOptionsInterface|MockObject
*/
- protected $indexerRegistryMock;
+ private $customerOptionsMock;
/**
- * @var EngineResolverInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerRegistry|MockObject
*/
- protected $engineResolverMock;
+ private $indexerRegistryMock;
/**
- * @var CustomerGroup
+ * @var EngineResolverInterface|MockObject
*/
- protected $model;
+ private $engineResolverMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->subjectMock = $this->createMock(\Magento\Customer\Model\ResourceModel\Group::class);
+ $this->subjectMock = $this->createMock(CustomerGroupResourceModel::class);
$this->customerOptionsMock = $this->createMock(
- \Magento\AdvancedSearch\Model\Client\ClientOptionsInterface::class
+ ClientOptionsInterface::class
);
$this->indexerMock = $this->getMockForAbstractClass(
- \Magento\Framework\Indexer\IndexerInterface::class,
+ IndexerInterface::class,
[],
'',
false,
@@ -57,14 +70,14 @@ protected function setUp()
['getId', 'getState', '__wakeup']
);
$this->indexerRegistryMock = $this->createPartialMock(
- \Magento\Framework\Indexer\IndexerRegistry::class,
+ IndexerRegistry::class,
['get']
);
$this->engineResolverMock = $this->createPartialMock(
- \Magento\Search\Model\EngineResolver::class,
+ EngineResolverInterface::class,
['getCurrentSearchEngine']
);
- $this->model = new CustomerGroup(
+ $this->model = new CustomerGroupPlugin(
$this->indexerRegistryMock,
$this->customerOptionsMock,
$this->engineResolverMock
@@ -79,23 +92,27 @@ protected function setUp()
* @return void
* @dataProvider aroundSaveDataProvider
*/
- public function testAroundSave($searchEngine, $isObjectNew, $isTaxClassIdChanged, $invalidateCounter)
- {
+ public function testAroundSave(
+ string $searchEngine,
+ bool $isObjectNew,
+ bool $isTaxClassIdChanged,
+ int $invalidateCounter
+ ): void {
$this->engineResolverMock->expects($this->once())
->method('getCurrentSearchEngine')
- ->will($this->returnValue($searchEngine));
+ ->willReturn($searchEngine);
$groupMock = $this->createPartialMock(
- \Magento\Customer\Model\Group::class,
+ CustomerGroupModel::class,
['dataHasChangedFor', 'isObjectNew', '__wakeup']
);
- $groupMock->expects($this->any())->method('isObjectNew')->will($this->returnValue($isObjectNew));
+ $groupMock->expects($this->any())->method('isObjectNew')->willReturn($isObjectNew);
$groupMock->expects($this->any())
->method('dataHasChangedFor')
->with('tax_class_id')
- ->will($this->returnValue($isTaxClassIdChanged));
+ ->willReturn($isTaxClassIdChanged);
- $closureMock = function (\Magento\Customer\Model\Group $object) use ($groupMock) {
+ $closureMock = function (CustomerGroupModel $object) use ($groupMock) {
$this->assertEquals($object, $groupMock);
return $this->subjectMock;
};
@@ -103,8 +120,8 @@ public function testAroundSave($searchEngine, $isObjectNew, $isTaxClassIdChanged
$this->indexerMock->expects($this->exactly($invalidateCounter))->method('invalidate');
$this->indexerRegistryMock->expects($this->exactly($invalidateCounter))
->method('get')
- ->with(\Magento\CatalogSearch\Model\Indexer\Fulltext::INDEXER_ID)
- ->will($this->returnValue($this->indexerMock));
+ ->with(FulltextIndexer::INDEXER_ID)
+ ->willReturn($this->indexerMock);
$this->assertEquals(
$this->subjectMock,
@@ -113,9 +130,11 @@ public function testAroundSave($searchEngine, $isObjectNew, $isTaxClassIdChanged
}
/**
+ * Data Provider for testAroundSave
+ *
* @return array
*/
- public function aroundSaveDataProvider()
+ public function aroundSaveDataProvider(): array
{
return [
['mysql', false, false, 0],
diff --git a/app/code/Magento/AdvancedSearch/Test/Unit/Model/Recommendations/DataProviderTest.php b/app/code/Magento/AdvancedSearch/Test/Unit/Model/Recommendations/DataProviderTest.php
index c62c906914fd7..81d9f592dcafe 100644
--- a/app/code/Magento/AdvancedSearch/Test/Unit/Model/Recommendations/DataProviderTest.php
+++ b/app/code/Magento/AdvancedSearch/Test/Unit/Model/Recommendations/DataProviderTest.php
@@ -8,26 +8,29 @@
namespace Magento\AdvancedSearch\Test\Unit\Model\Recommendations;
use Magento\AdvancedSearch\Model\Recommendations\DataProvider;
-use Magento\Framework\App\Config\ScopeConfigInterface;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
-use Magento\Catalog\Model\Layer\Resolver;
use Magento\AdvancedSearch\Model\ResourceModel\Recommendations;
use Magento\AdvancedSearch\Model\ResourceModel\RecommendationsFactory;
+use Magento\Catalog\Model\Layer as SearchLayer;
+use Magento\Catalog\Model\Layer\Resolver;
+use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Search\Model\QueryInterface;
use Magento\Search\Model\QueryResult;
use Magento\Search\Model\QueryResultFactory;
-use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
-use Magento\Catalog\Model\Layer as SearchLayer;
use Magento\Store\Model\ScopeInterface;
-use Magento\Search\Model\QueryInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
+ * @covers \Magento\AdvancedSearch\Model\Recommendations\DataProvider
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
- *
- * Class \Magento\AdvancedSearch\Test\Unit\Model\Recommendations\DataProviderTest
*/
-class DataProviderTest extends \PHPUnit\Framework\TestCase
+class DataProviderTest extends TestCase
{
/**
+ * Testable Object
+ *
* @var DataProvider;
*/
private $model;
@@ -38,43 +41,43 @@ class DataProviderTest extends \PHPUnit\Framework\TestCase
private $objectManagerHelper;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|ScopeConfigInterface
+ * @var ScopeConfigInterface|MockObject
*/
private $scopeConfigMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|Resolver
+ * @var Resolver|MockObject
*/
private $layerResolverMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|SearchLayer
+ * @var SearchLayer|MockObject
*/
private $searchLayerMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|RecommendationsFactory
+ * @var RecommendationsFactory|MockObject
*/
private $recommendationsFactoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|Recommendations
+ * @var Recommendations|MockObject
*/
private $recommendationsMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|Resolver
+ * @var Resolver|MockObject
*/
- private $queryResultFactory;
+ private $queryResultFactoryMock;
/**
* Set up test environment.
*
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class);
+ $this->scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
$this->layerResolverMock = $this->getMockBuilder(Resolver::class)
->disableOriginalConstructor()
->setMethods(['get'])
@@ -84,7 +87,7 @@ protected function setUp()
$this->layerResolverMock->expects($this->any())
->method('get')
- ->will($this->returnValue($this->searchLayerMock));
+ ->willReturn($this->searchLayerMock);
$this->recommendationsFactoryMock = $this->getMockBuilder(RecommendationsFactory::class)
->disableOriginalConstructor()
@@ -93,7 +96,7 @@ protected function setUp()
$this->recommendationsMock = $this->createMock(Recommendations::class);
- $this->queryResultFactory = $this->getMockBuilder(QueryResultFactory::class)
+ $this->queryResultFactoryMock = $this->getMockBuilder(QueryResultFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
@@ -105,7 +108,7 @@ protected function setUp()
'scopeConfig' => $this->scopeConfigMock,
'layerResolver' => $this->layerResolverMock,
'recommendationsFactory' => $this->recommendationsFactoryMock,
- 'queryResultFactory' => $this->queryResultFactory
+ 'queryResultFactory' => $this->queryResultFactoryMock
]
);
}
@@ -115,12 +118,12 @@ protected function setUp()
*
* @return void
*/
- public function testGetItemsWhenDisabledSearchRecommendations()
+ public function testGetItemsWhenDisabledSearchRecommendations(): void
{
$isEnabledSearchRecommendations = false;
- /** @var $queryInterfaceMock QueryInterface */
- $queryInterfaceMock = $this->createMock(QueryInterface::class);
+ /** @var QueryInterface $queryInterfaceMock */
+ $queryInterfaceMock = $this->getMockForAbstractClass(QueryInterface::class);
$this->scopeConfigMock->expects($this->any())
->method('isSetFlag')
@@ -136,15 +139,15 @@ public function testGetItemsWhenDisabledSearchRecommendations()
*
* @return void
*/
- public function testGetItemsWhenEnabledSearchRecommendations()
+ public function testGetItemsWhenEnabledSearchRecommendations(): void
{
$storeId = 1;
$searchRecommendationsCountConfig = 2;
$isEnabledSearchRecommendations = true;
$queryText = 'test';
- /** @var $queryInterfaceMock QueryInterface */
- $queryInterfaceMock = $this->createMock(QueryInterface::class);
+ /** @var QueryInterface $queryInterfaceMock */
+ $queryInterfaceMock = $this->getMockForAbstractClass(QueryInterface::class);
$queryInterfaceMock->expects($this->any())->method('getQueryText')->willReturn($queryText);
$this->scopeConfigMock->expects($this->any())
@@ -181,9 +184,9 @@ public function testGetItemsWhenEnabledSearchRecommendations()
]
);
$queryResultMock = $this->createMock(QueryResult::class);
- $this->queryResultFactory->expects($this->any())->method('create')->willReturn($queryResultMock);
+ $this->queryResultFactoryMock->expects($this->any())->method('create')->willReturn($queryResultMock);
$result = $this->model->getItems($queryInterfaceMock);
- $this->assertEquals(2, count($result));
+ $this->assertCount(2, $result);
}
}
diff --git a/app/code/Magento/AdvancedSearch/Test/Unit/Model/ResourceModel/IndexTest.php b/app/code/Magento/AdvancedSearch/Test/Unit/Model/ResourceModel/IndexTest.php
index 1f37e40842f54..9bf0838a77472 100644
--- a/app/code/Magento/AdvancedSearch/Test/Unit/Model/ResourceModel/IndexTest.php
+++ b/app/code/Magento/AdvancedSearch/Test/Unit/Model/ResourceModel/IndexTest.php
@@ -3,74 +3,89 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\AdvancedSearch\Test\Unit\Model\ResourceModel;
use Magento\AdvancedSearch\Model\ResourceModel\Index;
-use Magento\Store\Model\StoreManagerInterface;
-use Magento\Framework\Model\ResourceModel\Db\Context;
-use Magento\Framework\EntityManager\MetadataPool;
-use Magento\Store\Api\Data\StoreInterface;
-use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory;
use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\DB\Select;
+use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Framework\Indexer\MultiDimensionProvider;
+use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver;
+use Magento\Framework\Model\ResourceModel\Db\Context;
+use Magento\Store\Api\Data\StoreInterface;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+use Traversable;
/**
+ * @covers \Magento\AdvancedSearch\Model\ResourceModel\Index
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class IndexTest extends \PHPUnit\Framework\TestCase
+class IndexTest extends TestCase
{
/**
+ * Testable Object
+ *
* @var Index
*/
private $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
private $storeManagerMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
private $resourceContextMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MetadataPool|MockObject
*/
private $metadataPoolMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var AdapterInterface|MockObject
*/
private $adapterMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var ResourceConnection|MockObject
*/
private $resourceConnectionMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->storeManagerMock = $this->createMock(StoreManagerInterface::class);
+ $this->storeManagerMock = $this->getMockForAbstractClass(StoreManagerInterface::class);
$this->resourceContextMock = $this->createMock(Context::class);
$this->resourceConnectionMock = $this->createMock(ResourceConnection::class);
$this->resourceContextMock->expects($this->any())
->method('getResources')
->willReturn($this->resourceConnectionMock);
- $this->adapterMock = $this->createMock(AdapterInterface::class);
- $this->resourceConnectionMock->expects($this->any())->method('getConnection')->willReturn($this->adapterMock);
+ $this->adapterMock = $this->getMockForAbstractClass(AdapterInterface::class);
+ $this->resourceConnectionMock->expects($this->any())
+ ->method('getConnection')
+ ->willReturn($this->adapterMock);
$this->metadataPoolMock = $this->createMock(MetadataPool::class);
- $indexScopeResolverMock = $this->createMock(
- \Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver::class
- );
- $traversableMock = $this->createMock(\Traversable::class);
- $dimensionsMock = $this->createMock(\Magento\Framework\Indexer\MultiDimensionProvider::class);
+ /** @var IndexScopeResolver|MockObject $indexScopeResolverMock */
+ $indexScopeResolverMock = $this->createMock(IndexScopeResolver::class);
+
+ /** @var Traversable|MockObject $traversableMock */
+ $traversableMock = $this->createMock(Traversable::class);
+
+ /** @var MultiDimensionProvider|MockObject $dimensionsMock */
+ $dimensionsMock = $this->createMock(MultiDimensionProvider::class);
$dimensionsMock->method('getIterator')->willReturn($traversableMock);
- $dimensionFactoryMock = $this->createMock(
- \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory::class
- );
+
+ /** @var DimensionCollectionFactory|MockObject $dimensionFactoryMock */
+ $dimensionFactoryMock = $this->createMock(DimensionCollectionFactory::class);
$dimensionFactoryMock->method('create')->willReturn($dimensionsMock);
$this->model = new Index(
@@ -83,13 +98,15 @@ protected function setUp()
);
}
- public function testGetPriceIndexDataUsesFrontendPriceIndexerTable()
+ public function testGetPriceIndexDataUsesFrontendPriceIndexerTable(): void
{
$storeId = 1;
- $storeMock = $this->createMock(StoreInterface::class);
+ $storeMock = $this->getMockForAbstractClass(StoreInterface::class);
$storeMock->expects($this->any())->method('getId')->willReturn($storeId);
$storeMock->method('getWebsiteId')->willReturn(1);
- $this->storeManagerMock->expects($this->once())->method('getStore')->with($storeId)->willReturn($storeMock);
+ $this->storeManagerMock->expects($this->once())
+ ->method('getStore')
+ ->with($storeId)->willReturn($storeMock);
$selectMock = $this->createMock(Select::class);
$selectMock->expects($this->any())->method('from')->willReturnSelf();
diff --git a/app/code/Magento/AdvancedSearch/Test/Unit/Model/SuggestedQueriesTest.php b/app/code/Magento/AdvancedSearch/Test/Unit/Model/SuggestedQueriesTest.php
index d349ed3e3ce93..f9ddd38554b03 100644
--- a/app/code/Magento/AdvancedSearch/Test/Unit/Model/SuggestedQueriesTest.php
+++ b/app/code/Magento/AdvancedSearch/Test/Unit/Model/SuggestedQueriesTest.php
@@ -3,42 +3,56 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\AdvancedSearch\Test\Unit\Model;
+use InvalidArgumentException;
+use Magento\AdvancedSearch\Model\SuggestedQueries;
+use Magento\AdvancedSearch\Model\SuggestedQueriesInterface;
+use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Search\EngineResolverInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
-use Magento\Framework\ObjectManagerInterface;
+use Magento\Search\Model\EngineResolver;
+use Magento\Search\Model\QueryInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class SuggestedQueriesTest extends \PHPUnit\Framework\TestCase
+/**
+ * @covers \Magento\AdvancedSearch\Model\SuggestedQueries
+ */
+class SuggestedQueriesTest extends TestCase
{
/**
- * @var \Magento\AdvancedSearch\Model\SuggestedQueries;
+ * Testable Object
+ *
+ * @var SuggestedQueries;
*/
- protected $model;
+ private $model;
/**
- * @var EngineResolverInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var EngineResolverInterface|MockObject
*/
- protected $engineResolverMock;
+ private $engineResolverMock;
/**
- * @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ObjectManagerInterface|MockObject
*/
- protected $objectManagerMock;
+ private $objectManagerMock;
/**
* @var ObjectManagerHelper
*/
- protected $objectManagerHelper;
+ private $objectManagerHelper;
/**
* Set up test environment.
*
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->engineResolverMock = $this->getMockBuilder(\Magento\Search\Model\EngineResolver::class)
+ $this->engineResolverMock = $this->getMockBuilder(EngineResolver::class)
->setMethods(['getCurrentSearchEngine'])
->disableOriginalConstructor()
->getMock();
@@ -46,21 +60,17 @@ protected function setUp()
->method('getCurrentSearchEngine')
->willReturn('my_engine');
- /**
- * @var \Magento\AdvancedSearch\Model\SuggestedQueriesInterface|
- * \PHPUnit_Framework_MockObject_MockObject
- */
- $suggestedQueriesMock = $this->createMock(\Magento\AdvancedSearch\Model\SuggestedQueriesInterface::class);
+ /** @var SuggestedQueriesInterface|MockObject $suggestedQueriesMock */
+ $suggestedQueriesMock = $this->getMockForAbstractClass(SuggestedQueriesInterface::class);
$suggestedQueriesMock->expects($this->any())
->method('isResultsCountEnabled')
->willReturn(true);
$suggestedQueriesMock->expects($this->any())
->method('getItems')
->willReturn([]);
-
- $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class)
+ $this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)
->disableOriginalConstructor()
- ->getMock();
+ ->getMockForAbstractClass();
$this->objectManagerMock->expects($this->any())
->method('create')
->with('search_engine')
@@ -68,7 +78,7 @@ protected function setUp()
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->model = $this->objectManagerHelper->getObject(
- \Magento\AdvancedSearch\Model\SuggestedQueries::class,
+ SuggestedQueries::class,
[
'engineResolver' => $this->engineResolverMock,
'objectManager' => $this->objectManagerMock,
@@ -82,7 +92,7 @@ protected function setUp()
*
* @return void
*/
- public function testIsResultsCountEnabled()
+ public function testIsResultsCountEnabled(): void
{
$result = $this->model->isResultsCountEnabled();
$this->assertTrue($result);
@@ -90,29 +100,29 @@ public function testIsResultsCountEnabled()
/**
* Test isResultsCountEnabled() method failure.
- * @expectedException \InvalidArgumentException
*
* @return void
*/
- public function testIsResultsCountEnabledException()
+ public function testIsResultsCountEnabledException(): void
{
- $objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class)
+ $objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)
->disableOriginalConstructor()
- ->getMock();
+ ->getMockForAbstractClass();
$objectManagerMock->expects($this->once())
->method('create')
->willReturn(null);
$objectManagerHelper = new ObjectManagerHelper($this);
- /* @var $model \Magento\AdvancedSearch\Model\SuggestedQueries */
+ /* @var SuggestedQueries $model */
$model = $objectManagerHelper->getObject(
- \Magento\AdvancedSearch\Model\SuggestedQueries::class,
+ SuggestedQueries::class,
[
'engineResolver' => $this->engineResolverMock,
'objectManager' => $objectManagerMock,
'data' => ['my_engine' => 'search_engine']
]
);
+ $this->expectException(InvalidArgumentException::class);
$model->isResultsCountEnabled();
}
@@ -121,10 +131,10 @@ public function testIsResultsCountEnabledException()
*
* @return void
*/
- public function testGetItems()
+ public function testGetItems(): void
{
- /** @var $queryInterfaceMock \Magento\Search\Model\QueryInterface */
- $queryInterfaceMock = $this->createMock(\Magento\Search\Model\QueryInterface::class);
+ /** @var QueryInterface|MockObject $queryInterfaceMock */
+ $queryInterfaceMock = $this->getMockForAbstractClass(QueryInterface::class);
$result = $this->model->getItems($queryInterfaceMock);
$this->assertEquals([], $result);
}
diff --git a/app/code/Magento/AdvancedSearch/composer.json b/app/code/Magento/AdvancedSearch/composer.json
index 30b4a141087ff..720309b619e43 100644
--- a/app/code/Magento/AdvancedSearch/composer.json
+++ b/app/code/Magento/AdvancedSearch/composer.json
@@ -13,7 +13,7 @@
"magento/module-customer": "*",
"magento/module-search": "*",
"magento/module-store": "*",
- "php": "~7.1.3||~7.2.0||~7.3.0"
+ "php": "~7.3.0||~7.4.0"
},
"type": "magento2-module",
"license": [
diff --git a/app/code/Magento/Amqp/Test/Unit/Setup/ConfigOptionsListTest.php b/app/code/Magento/Amqp/Test/Unit/Setup/ConfigOptionsListTest.php
index 5b19ba055d059..cce976ecc817d 100644
--- a/app/code/Magento/Amqp/Test/Unit/Setup/ConfigOptionsListTest.php
+++ b/app/code/Magento/Amqp/Test/Unit/Setup/ConfigOptionsListTest.php
@@ -3,15 +3,20 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Amqp\Test\Unit\Setup;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Amqp\Setup\ConfigOptionsList;
-use Magento\Framework\Setup\Option\TextConfigOption;
+use Magento\Amqp\Setup\ConnectionValidator;
use Magento\Framework\App\DeploymentConfig;
+use Magento\Framework\Config\Data\ConfigData;
+use Magento\Framework\Setup\Option\TextConfigOption;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ConfigOptionsListTest extends \PHPUnit\Framework\TestCase
+class ConfigOptionsListTest extends TestCase
{
/**
* @var ObjectManager
@@ -24,12 +29,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 +43,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 +56,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,
]
@@ -133,11 +138,11 @@ public function testGetOptions()
public function testCreateConfig($options, $expectedConfigData)
{
$result = $this->model->createConfig($options, $this->deploymentConfigMock);
- $this->assertInternalType('array', $result);
+ $this->assertIsArray($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());
}
@@ -179,18 +184,16 @@ public function getCreateConfigDataProvider()
ConfigOptionsList::INPUT_KEY_QUEUE_AMQP_SSL => 'ssl',
ConfigOptionsList::INPUT_KEY_QUEUE_AMQP_SSL_OPTIONS => '{"ssl_option":"test"}',
],
- ['queue' =>
- ['amqp' =>
- [
- 'host' => 'host',
- 'port' => 'port',
- 'user' => 'user',
- 'password' => 'password',
- 'virtualhost' => 'virtual host',
- 'ssl' => 'ssl',
- 'ssl_options' => ['ssl_option' => 'test'],
- ]
- ]
+ ['queue' => ['amqp' => [
+ 'host' => 'host',
+ 'port' => 'port',
+ 'user' => 'user',
+ 'password' => 'password',
+ 'virtualhost' => 'virtual host',
+ 'ssl' => 'ssl',
+ 'ssl_options' => ['ssl_option' => 'test'],
+ ]
+ ]
],
],
[
@@ -203,18 +206,16 @@ public function getCreateConfigDataProvider()
ConfigOptionsList::INPUT_KEY_QUEUE_AMQP_SSL => 'ssl',
ConfigOptionsList::INPUT_KEY_QUEUE_AMQP_SSL_OPTIONS => '{"ssl_option":"test"}',
],
- ['queue' =>
- ['amqp' =>
- [
- 'host' => 'host',
- 'port' => ConfigOptionsList::DEFAULT_AMQP_PORT,
- 'user' => 'user',
- 'password' => 'password',
- 'virtualhost' => 'virtual host',
- 'ssl' => 'ssl',
- 'ssl_options' => ['ssl_option' => 'test'],
- ]
- ]
+ ['queue' => ['amqp' => [
+ 'host' => 'host',
+ 'port' => ConfigOptionsList::DEFAULT_AMQP_PORT,
+ 'user' => 'user',
+ 'password' => 'password',
+ 'virtualhost' => 'virtual host',
+ 'ssl' => 'ssl',
+ 'ssl_options' => ['ssl_option' => 'test'],
+ ]
+ ]
],
],
[
@@ -223,9 +224,8 @@ public function getCreateConfigDataProvider()
ConfigOptionsList::INPUT_KEY_QUEUE_AMQP_PORT => ConfigOptionsList::DEFAULT_AMQP_PORT,
ConfigOptionsList::INPUT_KEY_QUEUE_AMQP_USER => ConfigOptionsList::DEFAULT_AMQP_USER,
ConfigOptionsList::INPUT_KEY_QUEUE_AMQP_PASSWORD => ConfigOptionsList::DEFAULT_AMQP_PASSWORD,
- ConfigOptionsList::INPUT_KEY_QUEUE_AMQP_VIRTUAL_HOST =>
- ConfigOptionsList::DEFAULT_AMQP_VIRTUAL_HOST,
ConfigOptionsList::INPUT_KEY_QUEUE_AMQP_SSL => ConfigOptionsList::DEFAULT_AMQP_SSL,
+ ConfigOptionsList::INPUT_KEY_QUEUE_AMQP_VIRTUAL_HOST => ConfigOptionsList::DEFAULT_AMQP_VIRTUAL_HOST
],
[],
],
diff --git a/app/code/Magento/Amqp/composer.json b/app/code/Magento/Amqp/composer.json
index e7509d8801145..9e7a035112b04 100644
--- a/app/code/Magento/Amqp/composer.json
+++ b/app/code/Magento/Amqp/composer.json
@@ -8,7 +8,7 @@
"magento/framework": "*",
"magento/framework-amqp": "*",
"magento/framework-message-queue": "*",
- "php": "~7.1.3||~7.2.0||~7.3.0"
+ "php": "~7.3.0||~7.4.0"
},
"type": "magento2-module",
"license": [
diff --git a/app/code/Magento/AmqpStore/composer.json b/app/code/Magento/AmqpStore/composer.json
index bfefab262d3fc..70a10810ece21 100644
--- a/app/code/Magento/AmqpStore/composer.json
+++ b/app/code/Magento/AmqpStore/composer.json
@@ -8,7 +8,7 @@
"magento/framework": "*",
"magento/framework-amqp": "*",
"magento/module-store": "*",
- "php": "~7.1.3||~7.2.0||~7.3.0"
+ "php": "~7.3.0||~7.4.0"
},
"suggest": {
"magento/module-asynchronous-operations": "*",
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/Setup/Patch/Data/ActivateDataCollection.php b/app/code/Magento/Analytics/Setup/Patch/Data/ActivateDataCollection.php
new file mode 100644
index 0000000000000..dd60d74b53d09
--- /dev/null
+++ b/app/code/Magento/Analytics/Setup/Patch/Data/ActivateDataCollection.php
@@ -0,0 +1,95 @@
+scopeConfig = $scopeConfig;
+ $this->subscriptionStatusProvider = $subscriptionStatusProvider;
+ $this->collectionTimeBackendModel = $collectionTimeBackendModel;
+ }
+
+ /**
+ * @inheritDoc
+ *
+ * @throws LocalizedException
+ */
+ public function apply()
+ {
+ $subscriptionStatus = $this->subscriptionStatusProvider->getStatus();
+ $isCollectionProcessActivated = $this->scopeConfig->getValue(CollectionTime::CRON_SCHEDULE_PATH);
+ if ($subscriptionStatus !== $this->subscriptionStatusProvider->getStatusForDisabledSubscription()
+ && !$isCollectionProcessActivated
+ ) {
+ $this->collectionTimeBackendModel
+ ->setValue($this->scopeConfig->getValue($this->analyticsCollectionTimeConfigPath));
+ $this->collectionTimeBackendModel->setPath($this->analyticsCollectionTimeConfigPath);
+ $this->collectionTimeBackendModel->afterSave();
+ }
+
+ return $this;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public static function getDependencies()
+ {
+ return [
+ PrepareInitialConfig::class,
+ ];
+ }
+}
diff --git a/app/code/Magento/Analytics/Setup/Patch/Data/PrepareInitialConfig.php b/app/code/Magento/Analytics/Setup/Patch/Data/PrepareInitialConfig.php
index a352854a8b77b..97ac340f9d491 100644
--- a/app/code/Magento/Analytics/Setup/Patch/Data/PrepareInitialConfig.php
+++ b/app/code/Magento/Analytics/Setup/Patch/Data/PrepareInitialConfig.php
@@ -4,17 +4,18 @@
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Setup\Patch\Data;
use Magento\Analytics\Model\Config\Backend\Enabled\SubscriptionHandler;
+use Magento\Config\Model\Config\Source\Enabledisable;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
/**
- * Initial patch.
- *
- * @package Magento\Analytics\Setup\Patch
+ * Active subscription process for Advanced Reporting
*/
class PrepareInitialConfig implements DataPatchInterface, PatchVersionInterface
{
@@ -24,50 +25,47 @@ class PrepareInitialConfig implements DataPatchInterface, PatchVersionInterface
private $moduleDataSetup;
/**
- * PrepareInitialConfig constructor.
+ * @var SubscriptionHandler
+ */
+ private $subscriptionHandler;
+
+ /**
+ * @var string
+ */
+ private $subscriptionEnabledConfigPath = 'analytics/subscription/enabled';
+
+ /**
* @param ModuleDataSetupInterface $moduleDataSetup
+ * @param SubscriptionHandler $subscriptionHandler
*/
public function __construct(
- ModuleDataSetupInterface $moduleDataSetup
+ ModuleDataSetupInterface $moduleDataSetup,
+ SubscriptionHandler $subscriptionHandler
) {
$this->moduleDataSetup = $moduleDataSetup;
+ $this->subscriptionHandler = $subscriptionHandler;
}
/**
- * {@inheritdoc}
+ * @inheritDoc
*/
public function apply()
{
- $this->moduleDataSetup->getConnection()->insertMultiple(
+ $this->moduleDataSetup->getConnection()->insert(
$this->moduleDataSetup->getTable('core_config_data'),
[
- [
- 'scope' => 'default',
- 'scope_id' => 0,
- 'path' => 'analytics/subscription/enabled',
- 'value' => 1
- ],
- [
- 'scope' => 'default',
- 'scope_id' => 0,
- 'path' => SubscriptionHandler::CRON_STRING_PATH,
- 'value' => join(' ', SubscriptionHandler::CRON_EXPR_ARRAY)
- ]
+ 'path' => $this->subscriptionEnabledConfigPath,
+ 'value' => Enabledisable::ENABLE_VALUE,
]
);
- $this->moduleDataSetup->getConnection()->insert(
- $this->moduleDataSetup->getTable('flag'),
- [
- 'flag_code' => SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE,
- 'state' => 0,
- 'flag_data' => 24,
- ]
- );
+ $this->subscriptionHandler->processEnabled();
+
+ return $this;
}
/**
- * {@inheritdoc}
+ * @inheritDoc
*/
public static function getDependencies()
{
@@ -75,7 +73,7 @@ public static function getDependencies()
}
/**
- * {@inheritdoc}
+ * @inheritDoc
*/
public static function getVersion()
{
@@ -83,7 +81,7 @@ public static function getVersion()
}
/**
- * {@inheritdoc}
+ * @inheritDoc
*/
public function getAliases()
{
diff --git a/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingButtonTest.xml b/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingButtonTest.xml
index 5da7ccd3c9823..cbcbb3a5dd64c 100644
--- a/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingButtonTest.xml
+++ b/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingButtonTest.xml
@@ -22,7 +22,7 @@
-
+
diff --git a/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingNavigateMenuTest.xml b/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingNavigateMenuTest.xml
index c742248b32cc3..ee25e80fcab30 100644
--- a/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingNavigateMenuTest.xml
+++ b/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingNavigateMenuTest.xml
@@ -20,7 +20,7 @@
-
+
diff --git a/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationPermissionTest.xml b/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationPermissionTest.xml
index 93ee464a17efa..40f80ce52c2de 100644
--- a/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationPermissionTest.xml
+++ b/app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationPermissionTest.xml
@@ -35,8 +35,9 @@
-
+
+
diff --git a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/AdditionalCommentTest.php b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/AdditionalCommentTest.php
index 9428f8954c60e..70b5b46ceaff5 100644
--- a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/AdditionalCommentTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/AdditionalCommentTest.php
@@ -3,15 +3,20 @@
* 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\AdditionalComment;
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\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class AdditionalCommentTest extends \PHPUnit\Framework\TestCase
+class AdditionalCommentTest extends TestCase
{
/**
* @var AdditionalComment
@@ -19,21 +24,21 @@ class AdditionalCommentTest extends \PHPUnit\Framework\TestCase
private $additionalComment;
/**
- * @var AbstractElement|\PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractElement|MockObject
*/
private $abstractElementMock;
/**
- * @var Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
private $contextMock;
/**
- * @var Form|\PHPUnit_Framework_MockObject_MockObject
+ * @var Form|MockObject
*/
private $formMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)
->setMethods(['getComment', 'getLabel'])
@@ -41,19 +46,15 @@ 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);
$reflection_property->setValue($this->abstractElementMock, $escaper);
$this->abstractElementMock->setEscaper($escaper);
- $this->contextMock = $this->getMockBuilder(Context::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->formMock = $this->getMockBuilder(Form::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->contextMock = $this->createMock(Context::class);
+ $this->formMock = $this->createMock(Form::class);
$objectManager = new ObjectManager($this);
$this->additionalComment = $objectManager->getObject(
@@ -67,18 +68,18 @@ protected function setUp()
public function testRender()
{
$this->abstractElementMock->setForm($this->formMock);
- $this->abstractElementMock->expects($this->any())
+ $this->abstractElementMock
->method('getComment')
->willReturn('New comment');
- $this->abstractElementMock->expects($this->any())
+ $this->abstractElementMock
->method('getLabel')
->willReturn('Comment label');
$html = $this->additionalComment->render($this->abstractElementMock);
- $this->assertRegExp(
+ $this->assertMatchesRegularExpression(
"/New comment/",
$html
);
- $this->assertRegExp(
+ $this->assertMatchesRegularExpression(
"/Comment label/",
$html
);
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..89595d21a10f0 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,26 +29,34 @@ 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()
+ protected function setUp(): void
{
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)
->setMethods(['getComment'])
@@ -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);
@@ -58,44 +74,40 @@ protected function setUp()
->setMethods(['getLocaleDate'])
->disableOriginalConstructor()
->getMock();
- $this->formMock = $this->getMockBuilder(Form::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->timeZoneMock = $this->getMockBuilder(TimezoneInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->contextMock->expects($this->any())
- ->method('getLocaleDate')
+ $this->formMock = $this->createMock(Form::class);
+ $this->timeZoneMock = $this->getMockForAbstractClass(TimezoneInterface::class);
+ $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(
+ $this->assertMatchesRegularExpression(
"/Eastern Standard Time \(America\/New_York\)/",
$this->collectionTimeLabel->render($this->abstractElementMock)
);
diff --git a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/SubscriptionStatusLabelTest.php b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/SubscriptionStatusLabelTest.php
index b43225be9570d..0dc2671adf2d7 100644
--- a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/SubscriptionStatusLabelTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/SubscriptionStatusLabelTest.php
@@ -3,6 +3,8 @@
* 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\SubscriptionStatusLabel;
@@ -10,9 +12,12 @@
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\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class SubscriptionStatusLabelTest extends \PHPUnit\Framework\TestCase
+class SubscriptionStatusLabelTest extends TestCase
{
/**
* @var SubscriptionStatusLabel
@@ -20,48 +25,42 @@ class SubscriptionStatusLabelTest extends \PHPUnit\Framework\TestCase
private $subscriptionStatusLabel;
/**
- * @var AbstractElement|\PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractElement|MockObject
*/
private $abstractElementMock;
/**
- * @var SubscriptionStatusProvider|\PHPUnit_Framework_MockObject_MockObject
+ * @var SubscriptionStatusProvider|MockObject
*/
private $subscriptionStatusProviderMock;
/**
- * @var Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
private $contextMock;
/**
- * @var Form|\PHPUnit_Framework_MockObject_MockObject
+ * @var Form|MockObject
*/
private $formMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->subscriptionStatusProviderMock = $this->getMockBuilder(SubscriptionStatusProvider::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->contextMock = $this->getMockBuilder(Context::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->subscriptionStatusProviderMock = $this->createMock(SubscriptionStatusProvider::class);
+ $this->contextMock = $this->createMock(Context::class);
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)
->setMethods(['getComment'])
->disableOriginalConstructor()
->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);
$reflection_property->setValue($this->abstractElementMock, $escaper);
- $this->formMock = $this->getMockBuilder(Form::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->formMock = $this->createMock(Form::class);
$objectManager = new ObjectManager($this);
$this->subscriptionStatusLabel = $objectManager->getObject(
@@ -79,10 +78,10 @@ public function testRender()
$this->subscriptionStatusProviderMock->expects($this->once())
->method('getStatus')
->willReturn('Enabled');
- $this->abstractElementMock->expects($this->any())
+ $this->abstractElementMock
->method('getComment')
->willReturn('Subscription status: Enabled');
- $this->assertRegExp(
+ $this->assertMatchesRegularExpression(
"/Subscription status: Enabled/",
$this->subscriptionStatusLabel->render($this->abstractElementMock)
);
diff --git a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/VerticalTest.php b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/VerticalTest.php
index 0b5e86a523339..6e315643ade1f 100644
--- a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/VerticalTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/VerticalTest.php
@@ -3,15 +3,20 @@
* 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\Vertical;
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\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class VerticalTest extends \PHPUnit\Framework\TestCase
+class VerticalTest extends TestCase
{
/**
* @var Vertical
@@ -19,21 +24,21 @@ class VerticalTest extends \PHPUnit\Framework\TestCase
private $vertical;
/**
- * @var AbstractElement|\PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractElement|MockObject
*/
private $abstractElementMock;
/**
- * @var Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
private $contextMock;
/**
- * @var Form|\PHPUnit_Framework_MockObject_MockObject
+ * @var Form|MockObject
*/
private $formMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)
->setMethods(['getComment', 'getLabel', 'getHint'])
@@ -41,18 +46,14 @@ 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);
$reflection_property->setValue($this->abstractElementMock, $escaper);
- $this->contextMock = $this->getMockBuilder(Context::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->formMock = $this->getMockBuilder(Form::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->contextMock = $this->createMock(Context::class);
+ $this->formMock = $this->createMock(Form::class);
$objectManager = new ObjectManager($this);
$this->vertical = $objectManager->getObject(
@@ -66,18 +67,18 @@ protected function setUp()
public function testRender()
{
$this->abstractElementMock->setForm($this->formMock);
- $this->abstractElementMock->expects($this->any())
+ $this->abstractElementMock
->method('getComment')
->willReturn('New comment');
- $this->abstractElementMock->expects($this->any())
+ $this->abstractElementMock
->method('getHint')
->willReturn('New hint');
$html = $this->vertical->render($this->abstractElementMock);
- $this->assertRegExp(
+ $this->assertMatchesRegularExpression(
"/New comment/",
$html
);
- $this->assertRegExp(
+ $this->assertMatchesRegularExpression(
"/New hint/",
$html
);
diff --git a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/BIEssentials/SignUpTest.php b/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/BIEssentials/SignUpTest.php
index 4e79ca43327bf..6f788b973e5c3 100644
--- a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/BIEssentials/SignUpTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/BIEssentials/SignUpTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Controller\Adminhtml\BIEssentials;
use Magento\Analytics\Controller\Adminhtml\BIEssentials\SignUp;
@@ -10,8 +12,10 @@
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Controller\Result\Redirect;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class SignUpTest extends \PHPUnit\Framework\TestCase
+class SignUpTest extends TestCase
{
/**
* @var ObjectManagerHelper
@@ -19,7 +23,7 @@ class SignUpTest extends \PHPUnit\Framework\TestCase
private $objectManagerHelper;
/**
- * @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
private $configMock;
@@ -29,29 +33,23 @@ class SignUpTest extends \PHPUnit\Framework\TestCase
private $signUpController;
/**
- * @var RedirectFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var RedirectFactory|MockObject
*/
private $resultRedirectFactoryMock;
/**
- * @var Redirect|\PHPUnit_Framework_MockObject_MockObject
+ * @var Redirect|MockObject
*/
private $redirectMock;
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->configMock = $this->getMockBuilder(ScopeConfigInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->resultRedirectFactoryMock = $this->getMockBuilder(RedirectFactory::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->redirectMock = $this->getMockBuilder(Redirect::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->configMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
+ $this->resultRedirectFactoryMock = $this->createMock(RedirectFactory::class);
+ $this->redirectMock = $this->createMock(Redirect::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
diff --git a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Reports/ShowTest.php b/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Reports/ShowTest.php
index 4f54ce5059965..d70cb88b9053d 100644
--- a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Reports/ShowTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Reports/ShowTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Controller\Adminhtml\Reports;
use Magento\Analytics\Controller\Adminhtml\Reports\Show;
@@ -13,29 +15,31 @@
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Message\ManagerInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ShowTest extends \PHPUnit\Framework\TestCase
+class ShowTest extends TestCase
{
/**
- * @var ReportUrlProvider|\PHPUnit_Framework_MockObject_MockObject
+ * @var ReportUrlProvider|MockObject
*/
private $reportUrlProviderMock;
/**
- * @var Redirect|\PHPUnit_Framework_MockObject_MockObject
+ * @var Redirect|MockObject
*/
private $redirectMock;
/**
- * @var ResultFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResultFactory|MockObject
*/
private $resultFactoryMock;
/**
- * @var ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ManagerInterface|MockObject
*/
private $messageManagerMock;
@@ -52,23 +56,15 @@ class ShowTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->reportUrlProviderMock = $this->getMockBuilder(ReportUrlProvider::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->reportUrlProviderMock = $this->createMock(ReportUrlProvider::class);
- $this->resultFactoryMock = $this->getMockBuilder(ResultFactory::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->resultFactoryMock = $this->createMock(ResultFactory::class);
- $this->redirectMock = $this->getMockBuilder(Redirect::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->redirectMock = $this->createMock(Redirect::class);
- $this->messageManagerMock = $this->getMockBuilder(ManagerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->messageManagerMock = $this->getMockForAbstractClass(ManagerInterface::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
@@ -114,7 +110,6 @@ public function testExecute()
*/
public function testExecuteWithException(\Exception $exception)
{
-
$this->resultFactoryMock
->expects($this->once())
->method('create')
diff --git a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/RetryTest.php b/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/RetryTest.php
index 89107b8999ecd..2fd0a81f43967 100644
--- a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/RetryTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/RetryTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Analytics\Test\Unit\Controller\Adminhtml\Subscription;
@@ -14,26 +15,28 @@
use Magento\Framework\Message\ManagerInterface;
use Magento\Framework\Phrase;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class RetryTest extends \PHPUnit\Framework\TestCase
+class RetryTest extends TestCase
{
/**
- * @var ResultFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResultFactory|MockObject
*/
private $resultFactoryMock;
/**
- * @var Redirect|\PHPUnit_Framework_MockObject_MockObject
+ * @var Redirect|MockObject
*/
private $resultRedirectMock;
/**
- * @var SubscriptionHandler|\PHPUnit_Framework_MockObject_MockObject
+ * @var SubscriptionHandler|MockObject
*/
private $subscriptionHandlerMock;
/**
- * @var ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ManagerInterface|MockObject
*/
private $messageManagerMock;
@@ -50,23 +53,15 @@ class RetryTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->resultFactoryMock = $this->getMockBuilder(ResultFactory::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->resultFactoryMock = $this->createMock(ResultFactory::class);
- $this->resultRedirectMock = $this->getMockBuilder(Redirect::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->resultRedirectMock = $this->createMock(Redirect::class);
- $this->subscriptionHandlerMock = $this->getMockBuilder(SubscriptionHandler::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->subscriptionHandlerMock = $this->createMock(SubscriptionHandler::class);
- $this->messageManagerMock = $this->getMockBuilder(ManagerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->messageManagerMock = $this->getMockForAbstractClass(ManagerInterface::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
diff --git a/app/code/Magento/Analytics/Test/Unit/Cron/CollectDataTest.php b/app/code/Magento/Analytics/Test/Unit/Cron/CollectDataTest.php
index 66d1715de0321..5c59595df3309 100644
--- a/app/code/Magento/Analytics/Test/Unit/Cron/CollectDataTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Cron/CollectDataTest.php
@@ -3,22 +3,26 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Cron;
use Magento\Analytics\Cron\CollectData;
use Magento\Analytics\Model\ExportDataHandlerInterface;
use Magento\Analytics\Model\SubscriptionStatusProvider;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class CollectDataTest extends \PHPUnit\Framework\TestCase
+class CollectDataTest extends TestCase
{
/**
- * @var ExportDataHandlerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ExportDataHandlerInterface|MockObject
*/
private $exportDataHandlerMock;
/**
- * @var SubscriptionStatusProvider|\PHPUnit_Framework_MockObject_MockObject
+ * @var SubscriptionStatusProvider|MockObject
*/
private $subscriptionStatusMock;
@@ -35,14 +39,12 @@ class CollectDataTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->exportDataHandlerMock = $this->getMockBuilder(ExportDataHandlerInterface::class)
->getMockForAbstractClass();
- $this->subscriptionStatusMock = $this->getMockBuilder(SubscriptionStatusProvider::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->subscriptionStatusMock = $this->createMock(SubscriptionStatusProvider::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
diff --git a/app/code/Magento/Analytics/Test/Unit/Cron/SignUpTest.php b/app/code/Magento/Analytics/Test/Unit/Cron/SignUpTest.php
index 959a11f9e1058..a6cb9d0f63ffd 100644
--- a/app/code/Magento/Analytics/Test/Unit/Cron/SignUpTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Cron/SignUpTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Cron;
use Magento\Analytics\Cron\SignUp;
@@ -11,29 +13,31 @@
use Magento\Framework\App\Config\ReinitableConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;
use Magento\Framework\FlagManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class SignUpTest extends \PHPUnit\Framework\TestCase
+class SignUpTest extends TestCase
{
/**
- * @var Connector|\PHPUnit_Framework_MockObject_MockObject
+ * @var Connector|MockObject
*/
private $connectorMock;
/**
- * @var WriterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var WriterInterface|MockObject
*/
private $configWriterMock;
/**
- * @var FlagManager|\PHPUnit_Framework_MockObject_MockObject
+ * @var FlagManager|MockObject
*/
private $flagManagerMock;
/**
- * @var ReinitableConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ReinitableConfigInterface|MockObject
*/
private $reinitableConfigMock;
@@ -42,20 +46,12 @@ class SignUpTest extends \PHPUnit\Framework\TestCase
*/
private $signUp;
- protected function setUp()
+ protected function setUp(): void
{
- $this->connectorMock = $this->getMockBuilder(Connector::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->configWriterMock = $this->getMockBuilder(WriterInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->flagManagerMock = $this->getMockBuilder(FlagManager::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->reinitableConfigMock = $this->getMockBuilder(ReinitableConfigInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->connectorMock = $this->createMock(Connector::class);
+ $this->configWriterMock = $this->getMockForAbstractClass(WriterInterface::class);
+ $this->flagManagerMock = $this->createMock(FlagManager::class);
+ $this->reinitableConfigMock = $this->getMockForAbstractClass(ReinitableConfigInterface::class);
$this->signUp = new SignUp(
$this->connectorMock,
@@ -74,7 +70,7 @@ public function testExecute()
->with(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE)
->willReturn($attemptsCount);
- $attemptsCount -= 1;
+ $attemptsCount--;
$this->flagManagerMock->expects($this->once())
->method('saveFlag')
->with(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE, $attemptsCount);
diff --git a/app/code/Magento/Analytics/Test/Unit/Cron/UpdateTest.php b/app/code/Magento/Analytics/Test/Unit/Cron/UpdateTest.php
index aa3011ffc94f6..8f7e34c64bb3d 100644
--- a/app/code/Magento/Analytics/Test/Unit/Cron/UpdateTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Cron/UpdateTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Cron;
use Magento\Analytics\Cron\Update;
@@ -11,32 +13,35 @@
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;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class UpdateTest extends \PHPUnit\Framework\TestCase
+class UpdateTest extends TestCase
{
/**
- * @var Connector|\PHPUnit_Framework_MockObject_MockObject
+ * @var Connector|MockObject
*/
private $connectorMock;
/**
- * @var WriterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var WriterInterface|MockObject
*/
private $configWriterMock;
/**
- * @var FlagManager|\PHPUnit_Framework_MockObject_MockObject
+ * @var FlagManager|MockObject
*/
private $flagManagerMock;
/**
- * @var ReinitableConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ReinitableConfigInterface|MockObject
*/
private $reinitableConfigMock;
/**
- * @var AnalyticsToken|\PHPUnit_Framework_MockObject_MockObject
+ * @var AnalyticsToken|MockObject
*/
private $analyticsTokenMock;
@@ -45,23 +50,16 @@ class UpdateTest extends \PHPUnit\Framework\TestCase
*/
private $update;
- protected function setUp()
+ /**
+ * @inheritDoc
+ */
+ protected function setUp(): void
{
- $this->connectorMock = $this->getMockBuilder(Connector::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->configWriterMock = $this->getMockBuilder(WriterInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->flagManagerMock = $this->getMockBuilder(FlagManager::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->reinitableConfigMock = $this->getMockBuilder(ReinitableConfigInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->analyticsTokenMock = $this->getMockBuilder(AnalyticsToken::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->connectorMock = $this->createMock(Connector::class);
+ $this->configWriterMock = $this->getMockForAbstractClass(WriterInterface::class);
+ $this->flagManagerMock = $this->createMock(FlagManager::class);
+ $this->reinitableConfigMock = $this->getMockForAbstractClass(ReinitableConfigInterface::class);
+ $this->analyticsTokenMock = $this->createMock(AnalyticsToken::class);
$this->update = new Update(
$this->connectorMock,
@@ -74,6 +72,7 @@ protected function setUp()
/**
* @return void
+ * @throws NotFoundException
*/
public function testExecuteWithoutToken()
{
@@ -82,12 +81,11 @@ 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())
->method('isTokenExist')
->willReturn(false);
$this->addFinalOutputAsserts();
@@ -120,6 +118,7 @@ private function addFinalOutputAsserts(bool $isExecuted = true)
* @param $counterData
* @return void
* @dataProvider executeWithEmptyReverseCounterDataProvider
+ * @throws NotFoundException
*/
public function testExecuteWithEmptyReverseCounter($counterData)
{
@@ -159,6 +158,7 @@ public function executeWithEmptyReverseCounterDataProvider()
* @param bool $functionResult
* @return void
* @dataProvider executeRegularScenarioDataProvider
+ * @throws NotFoundException
*/
public function testExecuteRegularScenario(
int $reverseCount,
@@ -170,6 +170,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/AnalyticsTokenTest.php b/app/code/Magento/Analytics/Test/Unit/Model/AnalyticsTokenTest.php
index f4d17b3069229..5fe4918cbc0c6 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/AnalyticsTokenTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/AnalyticsTokenTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model;
use Magento\Analytics\Model\AnalyticsToken;
@@ -10,21 +12,23 @@
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class AnalyticsTokenTest extends \PHPUnit\Framework\TestCase
+class AnalyticsTokenTest extends TestCase
{
/**
- * @var ReinitableConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ReinitableConfigInterface|MockObject
*/
private $reinitableConfigMock;
/**
- * @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
private $configMock;
/**
- * @var WriterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var WriterInterface|MockObject
*/
private $configWriterMock;
@@ -46,19 +50,13 @@ class AnalyticsTokenTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->reinitableConfigMock = $this->getMockBuilder(ReinitableConfigInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->reinitableConfigMock = $this->getMockForAbstractClass(ReinitableConfigInterface::class);
- $this->configMock = $this->getMockBuilder(ScopeConfigInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->configMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
- $this->configWriterMock = $this->getMockBuilder(WriterInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->configWriterMock = $this->getMockForAbstractClass(WriterInterface::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Baseurl/SubscriptionUpdateHandlerTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Baseurl/SubscriptionUpdateHandlerTest.php
index f5f721c038c57..304be37a83754 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Baseurl/SubscriptionUpdateHandlerTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Baseurl/SubscriptionUpdateHandlerTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Analytics\Test\Unit\Model\Config\Backend\Baseurl;
@@ -12,26 +13,28 @@
use Magento\Framework\App\Config\Storage\WriterInterface;
use Magento\Framework\FlagManager;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class SubscriptionUpdateHandlerTest extends \PHPUnit\Framework\TestCase
+class SubscriptionUpdateHandlerTest extends TestCase
{
/**
- * @var AnalyticsToken|\PHPUnit_Framework_MockObject_MockObject
+ * @var AnalyticsToken|MockObject
*/
private $analyticsTokenMock;
/**
- * @var FlagManager|\PHPUnit_Framework_MockObject_MockObject
+ * @var FlagManager|MockObject
*/
private $flagManagerMock;
/**
- * @var ReinitableConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ReinitableConfigInterface|MockObject
*/
private $reinitableConfigMock;
/**
- * @var WriterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var WriterInterface|MockObject
*/
private $configWriterMock;
@@ -58,19 +61,15 @@ class SubscriptionUpdateHandlerTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->reinitableConfigMock = $this->getMockBuilder(ReinitableConfigInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $this->analyticsTokenMock = $this->getMockBuilder(AnalyticsToken::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->flagManagerMock = $this->getMockBuilder(FlagManager::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->analyticsTokenMock = $this->createMock(AnalyticsToken::class);
+
+ $this->flagManagerMock = $this->createMock(FlagManager::class);
$this->configWriterMock = $this->getMockBuilder(WriterInterface::class)
->disableOriginalConstructor()
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/CollectionTimeTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/CollectionTimeTest.php
index 25f4008f9a6e4..cde005ab5d365 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/CollectionTimeTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/CollectionTimeTest.php
@@ -3,23 +3,27 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model\Config\Backend;
use Magento\Analytics\Model\Config\Backend\CollectionTime;
use Magento\Framework\App\Config\Storage\WriterInterface;
use Magento\Framework\App\Config\Value;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
-class CollectionTimeTest extends \PHPUnit\Framework\TestCase
+class CollectionTimeTest extends TestCase
{
/**
- * @var WriterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var WriterInterface|MockObject
*/
private $configWriterMock;
/**
- * @var LoggerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var LoggerInterface|MockObject
*/
private $loggerMock;
@@ -36,15 +40,11 @@ class CollectionTimeTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->configWriterMock = $this->getMockBuilder(WriterInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->configWriterMock = $this->getMockForAbstractClass(WriterInterface::class);
- $this->loggerMock = $this->getMockBuilder(LoggerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
@@ -77,20 +77,20 @@ public function testAfterSave()
/**
* @return void
- * @expectedException \Magento\Framework\Exception\LocalizedException
*/
public function testAfterSaveWrongValue()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
$this->collectionTime->setData('value', '00,01');
$this->collectionTime->afterSave();
}
/**
* @return void
- * @expectedException \Magento\Framework\Exception\LocalizedException
*/
public function testAfterSaveWithLocalizedException()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
$exception = new \Exception('Test message');
$this->collectionTime->setData('value', '05,04,03');
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Enabled/SubscriptionHandlerTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Enabled/SubscriptionHandlerTest.php
index cf3e37ad89a31..35c40b6a5874e 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Enabled/SubscriptionHandlerTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Enabled/SubscriptionHandlerTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Analytics\Test\Unit\Model\Config\Backend\Enabled;
@@ -12,21 +13,23 @@
use Magento\Framework\App\Config\Storage\WriterInterface;
use Magento\Framework\FlagManager;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class SubscriptionHandlerTest extends \PHPUnit\Framework\TestCase
+class SubscriptionHandlerTest extends TestCase
{
/**
- * @var FlagManager|\PHPUnit_Framework_MockObject_MockObject
+ * @var FlagManager|MockObject
*/
private $flagManagerMock;
/**
- * @var WriterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var WriterInterface|MockObject
*/
private $configWriterMock;
/**
- * @var AnalyticsToken|\PHPUnit_Framework_MockObject_MockObject
+ * @var AnalyticsToken|MockObject
*/
private $tokenMock;
@@ -45,19 +48,13 @@ class SubscriptionHandlerTest extends \PHPUnit\Framework\TestCase
*/
private $subscriptionHandler;
- protected function setUp()
+ protected function setUp(): void
{
- $this->flagManagerMock = $this->getMockBuilder(FlagManager::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->flagManagerMock = $this->createMock(FlagManager::class);
- $this->configWriterMock = $this->getMockBuilder(WriterInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->configWriterMock = $this->getMockForAbstractClass(WriterInterface::class);
- $this->tokenMock = $this->getMockBuilder(AnalyticsToken::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->tokenMock = $this->createMock(AnalyticsToken::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/EnabledTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/EnabledTest.php
index 587f3599282f0..e977903bab7e4 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/EnabledTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/EnabledTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Analytics\Test\Unit\Model\Config\Backend;
@@ -11,22 +12,24 @@
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Config\Value;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
-class EnabledTest extends \PHPUnit\Framework\TestCase
+class EnabledTest extends TestCase
{
/**
- * @var SubscriptionHandler|\PHPUnit_Framework_MockObject_MockObject
+ * @var SubscriptionHandler|MockObject
*/
private $subscriptionHandlerMock;
/**
- * @var LoggerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var LoggerInterface|MockObject
*/
private $loggerMock;
/**
- * @var Value|\PHPUnit_Framework_MockObject_MockObject
+ * @var Value|MockObject
*/
private $configMock;
@@ -53,19 +56,13 @@ class EnabledTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->subscriptionHandlerMock = $this->getMockBuilder(SubscriptionHandler::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->subscriptionHandlerMock = $this->createMock(SubscriptionHandler::class);
- $this->loggerMock = $this->getMockBuilder(LoggerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
- $this->configMock = $this->getMockBuilder(ScopeConfigInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->configMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
@@ -87,7 +84,6 @@ public function testAfterSaveSuccessEnabled()
$this->enabledModel->setData('value', $this->valueEnabled);
$this->configMock
- ->expects($this->any())
->method('getValue')
->willReturn(!$this->valueEnabled);
@@ -111,7 +107,6 @@ public function testAfterSaveSuccessDisabled()
$this->enabledModel->setData('value', $this->valueDisabled);
$this->configMock
- ->expects($this->any())
->method('getValue')
->willReturn(!$this->valueDisabled);
@@ -135,7 +130,6 @@ public function testAfterSaveSuccessValueNotChanged()
$this->enabledModel->setData('value', null);
$this->configMock
- ->expects($this->any())
->method('getValue')
->willReturn(null);
@@ -158,10 +152,10 @@ public function testAfterSaveSuccessValueNotChanged()
/**
* @return void
- * @expectedException \Magento\Framework\Exception\LocalizedException
*/
public function testExecuteAfterSaveFailedWithLocalizedException()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
$exception = new \Exception('Message');
$this->enabledModel->setData('value', $this->valueEnabled);
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/VerticalTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/VerticalTest.php
index 6fe7d0aa93998..e8771f0c01fcc 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/VerticalTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/VerticalTest.php
@@ -3,33 +3,39 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model\Config\Backend;
+use Magento\Analytics\Model\Config\Backend\Vertical;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
+
/**
* A unit test for testing of the backend model for verticals configuration.
*/
-class VerticalTest extends \PHPUnit\Framework\TestCase
+class VerticalTest extends TestCase
{
/**
- * @var \Magento\Analytics\Model\Config\Backend\Vertical
+ * @var Vertical
*/
private $subject;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
private $objectManagerHelper;
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManagerHelper =
- new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ new ObjectManager($this);
$this->subject = $this->objectManagerHelper->getObject(
- \Magento\Analytics\Model\Config\Backend\Vertical::class
+ Vertical::class
);
}
@@ -41,17 +47,17 @@ public function testBeforeSaveSuccess()
$this->subject->setValue('Apps and Games');
$this->assertInstanceOf(
- \Magento\Analytics\Model\Config\Backend\Vertical::class,
+ Vertical::class,
$this->subject->beforeSave()
);
}
/**
* @return void
- * @expectedException \Magento\Framework\Exception\LocalizedException
*/
public function testBeforeSaveFailedWithLocalizedException()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
$this->subject->setValue('');
$this->subject->beforeSave();
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/MapperTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/MapperTest.php
index 0b7f4870dbac8..c16d5cc00225d 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Config/MapperTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Config/MapperTest.php
@@ -3,15 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model\Config;
use Magento\Analytics\Model\Config\Mapper;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class MapperTest extends \PHPUnit\Framework\TestCase
+class MapperTest extends TestCase
{
/**
* @var ObjectManagerHelper
@@ -26,7 +29,7 @@ class MapperTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManagerHelper = new ObjectManagerHelper($this);
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/ReaderTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/ReaderTest.php
index 6aa9c7ef3106c..b51d291d7d6eb 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Config/ReaderTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Config/ReaderTest.php
@@ -3,30 +3,34 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model\Config;
use Magento\Analytics\Model\Config\Mapper;
use Magento\Analytics\Model\Config\Reader;
use Magento\Framework\Config\ReaderInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ReaderTest extends \PHPUnit\Framework\TestCase
+class ReaderTest extends TestCase
{
/**
- * @var Mapper|\PHPUnit_Framework_MockObject_MockObject
+ * @var Mapper|MockObject
*/
private $mapperMock;
/**
- * @var ReaderInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ReaderInterface|MockObject
*/
private $readerXmlMock;
/**
- * @var ReaderInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ReaderInterface|MockObject
*/
private $readerDbMock;
@@ -43,19 +47,13 @@ class ReaderTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->mapperMock = $this->getMockBuilder(Mapper::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->mapperMock = $this->createMock(Mapper::class);
- $this->readerXmlMock = $this->getMockBuilder(ReaderInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->readerXmlMock = $this->getMockForAbstractClass(ReaderInterface::class);
- $this->readerDbMock = $this->getMockBuilder(ReaderInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->readerDbMock = $this->getMockForAbstractClass(ReaderInterface::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/Source/VerticalTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/Source/VerticalTest.php
index c13205d34f25b..2f87f36cd6003 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Config/Source/VerticalTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Config/Source/VerticalTest.php
@@ -3,33 +3,39 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model\Config\Source;
+use Magento\Analytics\Model\Config\Source\Vertical;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
+
/**
* A unit test for testing of the source model for verticals configuration.
*/
-class VerticalTest extends \PHPUnit\Framework\TestCase
+class VerticalTest extends TestCase
{
/**
- * @var \Magento\Analytics\Model\Config\Source\Vertical
+ * @var Vertical
*/
private $subject;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
private $objectManagerHelper;
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManagerHelper =
- new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ new ObjectManager($this);
$this->subject = $this->objectManagerHelper->getObject(
- \Magento\Analytics\Model\Config\Source\Vertical::class,
+ Vertical::class,
[
'verticals' => [
'Apps and Games',
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ConfigTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ConfigTest.php
index 8739219ebdf09..e04cc7478c18c 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/ConfigTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/ConfigTest.php
@@ -3,19 +3,23 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model;
use Magento\Analytics\Model\Config;
use Magento\Framework\Config\DataInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ConfigTest extends \PHPUnit\Framework\TestCase
+class ConfigTest extends TestCase
{
/**
- * @var DataInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var DataInterface|MockObject
*/
private $dataInterfaceMock;
@@ -32,11 +36,9 @@ class ConfigTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->dataInterfaceMock = $this->getMockBuilder(DataInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->dataInterfaceMock = $this->getMockForAbstractClass(DataInterface::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/Client/CurlTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/Client/CurlTest.php
index 92f79c2bf6dee..36ae51912d5ec 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/Client/CurlTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/Client/CurlTest.php
@@ -3,79 +3,75 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model\Connector\Http\Client;
+use Magento\Analytics\Model\Connector\Http\Client\Curl;
use Magento\Analytics\Model\Connector\Http\ConverterInterface;
use Magento\Analytics\Model\Connector\Http\JsonConverter;
use Magento\Framework\HTTP\Adapter\CurlFactory;
use Magento\Framework\HTTP\ResponseFactory;
+use Magento\Framework\HTTP\ZendClient;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+use Psr\Log\LoggerInterface;
/**
* A unit test for testing of the CURL HTTP client.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CurlTest extends \PHPUnit\Framework\TestCase
+class CurlTest extends TestCase
{
/**
- * @var \Magento\Analytics\Model\Connector\Http\Client\Curl
+ * @var Curl
*/
private $curl;
/**
- * @var \Magento\Framework\HTTP\Adapter\Curl|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\HTTP\Adapter\Curl|MockObject
*/
private $curlAdapterMock;
/**
- * @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var LoggerInterface|MockObject
*/
private $loggerMock;
/**
- * @var ResponseFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResponseFactory|MockObject
*/
private $responseFactoryMock;
/**
- * @var ConverterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ConverterInterface|MockObject
*/
private $converterMock;
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->curlAdapterMock = $this->getMockBuilder(
- \Magento\Framework\HTTP\Adapter\Curl::class
- )
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->loggerMock = $this->getMockBuilder(
- \Psr\Log\LoggerInterface::class
- )
- ->disableOriginalConstructor()
- ->getMock();
+ $this->curlAdapterMock = $this->createMock(\Magento\Framework\HTTP\Adapter\Curl::class);
+
+ $this->loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
$curlFactoryMock = $this->getMockBuilder(CurlFactory::class)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
- $curlFactoryMock->expects($this->any())
+ $curlFactoryMock
->method('create')
->willReturn($this->curlAdapterMock);
- $this->responseFactoryMock = $this->getMockBuilder(
- ResponseFactory::class
- )
- ->disableOriginalConstructor()
- ->getMock();
+ $this->responseFactoryMock = $this->createMock(ResponseFactory::class);
$this->converterMock = $this->createJsonConverter();
- $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManagerHelper = new ObjectManager($this);
$this->curl = $objectManagerHelper->getObject(
- \Magento\Analytics\Model\Connector\Http\Client\Curl::class,
+ Curl::class,
[
'curlFactory' => $curlFactoryMock,
'responseFactory' => $this->responseFactoryMock,
@@ -98,7 +94,7 @@ public function getTestData()
'version' => '1.1',
'body'=> ['name' => 'value'],
'url' => 'http://www.mystore.com',
- 'method' => \Magento\Framework\HTTP\ZendClient::POST,
+ 'method' => ZendClient::POST,
]
]
];
@@ -126,11 +122,11 @@ public function testRequestSuccess(array $data)
$this->curlAdapterMock->expects($this->once())
->method('read')
->willReturn($responseString);
- $this->curlAdapterMock->expects($this->any())
+ $this->curlAdapterMock
->method('getErrno')
->willReturn(0);
- $this->responseFactoryMock->expects($this->any())
+ $this->responseFactoryMock
->method('create')
->with($responseString)
->willReturn($response);
@@ -195,7 +191,7 @@ public function testRequestError(array $data)
}
/**
- * @return \PHPUnit_Framework_MockObject_MockObject
+ * @return MockObject
*/
private function createJsonConverter()
{
@@ -203,7 +199,7 @@ private function createJsonConverter()
->setMethodsExcept(['getContentTypeHeader'])
->disableOriginalConstructor()
->getMock();
- $converterMock->expects($this->any())->method('toBody')->willReturnCallback(function ($value) {
+ $converterMock->method('toBody')->willReturnCallback(function ($value) {
return json_encode($value);
});
return $converterMock;
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/JsonConverterTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/JsonConverterTest.php
index d3258c8ae9caa..81d1bca4c1c42 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/JsonConverterTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/JsonConverterTest.php
@@ -3,20 +3,25 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model\Connector\Http;
use Magento\Analytics\Model\Connector\Http\JsonConverter;
use Magento\Framework\Serialize\Serializer\Json;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class JsonConverterTest extends \PHPUnit\Framework\TestCase
+class JsonConverterTest extends TestCase
{
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
private $objectManagerHelper;
/**
- * @var Json|\PHPUnit_Framework_MockObject_MockObject
+ * @var Json|MockObject
*/
private $serializerMock;
@@ -28,12 +33,10 @@ class JsonConverterTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->serializerMock = $this->getMockBuilder(Json::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->objectManagerHelper = new ObjectManager($this);
+ $this->serializerMock = $this->createMock(Json::class);
$this->converter = $this->objectManagerHelper->getObject(
JsonConverter::class,
['serializer' => $this->serializerMock]
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/ResponseResolverTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/ResponseResolverTest.php
index 2564240c4fa11..10a987e44af63 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/ResponseResolverTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/ResponseResolverTest.php
@@ -11,8 +11,10 @@
use Magento\Analytics\Model\Connector\Http\ResponseHandlerInterface;
use Magento\Analytics\Model\Connector\Http\ResponseResolver;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ResponseResolverTest extends \PHPUnit\Framework\TestCase
+class ResponseResolverTest extends TestCase
{
/**
* @var ObjectManagerHelper
@@ -20,17 +22,17 @@ class ResponseResolverTest extends \PHPUnit\Framework\TestCase
private $objectManagerHelper;
/**
- * @var ConverterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ConverterInterface|MockObject
*/
private $converterMock;
/**
- * @var ResponseHandlerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResponseHandlerInterface|MockObject
*/
private $successResponseHandlerMock;
/**
- * @var ResponseHandlerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResponseHandlerInterface|MockObject
*/
private $notFoundResponseHandlerMock;
@@ -42,12 +44,10 @@ class ResponseResolverTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManagerHelper = new ObjectManagerHelper($this);
- $this->converterMock = $this->getMockBuilder(ConverterInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->converterMock = $this->getMockForAbstractClass(ConverterInterface::class);
$this->successResponseHandlerMock = $this->getMockBuilder(ResponseHandlerInterface::class)
->getMockForAbstractClass();
$this->notFoundResponseHandlerMock = $this->getMockBuilder(ResponseHandlerInterface::class)
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/NotifyDataChangedCommandTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/NotifyDataChangedCommandTest.php
index c2b6c72e868c1..501142079b5d7 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/NotifyDataChangedCommandTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/NotifyDataChangedCommandTest.php
@@ -3,20 +3,28 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model\Connector;
use Magento\Analytics\Model\AnalyticsToken;
+use Magento\Analytics\Model\Connector\Http\ClientInterface;
use Magento\Analytics\Model\Connector\Http\JsonConverter;
+use Magento\Analytics\Model\Connector\Http\ResponseHandlerInterface;
use Magento\Analytics\Model\Connector\Http\ResponseResolver;
+use Magento\Analytics\Model\Connector\NotifyDataChangedCommand;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\HTTP\ZendClient;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
-use Magento\Analytics\Model\Connector\NotifyDataChangedCommand;
-use Magento\Analytics\Model\Connector\Http\ClientInterface;
-class NotifyDataChangedCommandTest extends \PHPUnit\Framework\TestCase
+/**
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
+class NotifyDataChangedCommandTest extends TestCase
{
/**
* @var NotifyDataChangedCommand
@@ -24,50 +32,40 @@ class NotifyDataChangedCommandTest extends \PHPUnit\Framework\TestCase
private $notifyDataChangedCommand;
/**
- * @var AnalyticsToken|\PHPUnit_Framework_MockObject_MockObject
+ * @var AnalyticsToken|MockObject
*/
private $analyticsTokenMock;
/**
- * @var ClientInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ClientInterface|MockObject
*/
private $httpClientMock;
/**
- * @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
public $configMock;
/**
- * @var LoggerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var LoggerInterface|MockObject
*/
private $loggerMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->analyticsTokenMock = $this->getMockBuilder(AnalyticsToken::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->analyticsTokenMock = $this->createMock(AnalyticsToken::class);
- $this->httpClientMock = $this->getMockBuilder(ClientInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->httpClientMock = $this->getMockForAbstractClass(ClientInterface::class);
- $this->configMock = $this->getMockBuilder(ScopeConfigInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->configMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
- $this->loggerMock = $this->getMockBuilder(LoggerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $successHandler = $this->getMockBuilder(\Magento\Analytics\Model\Connector\Http\ResponseHandlerInterface::class)
+ $this->loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
+ $successHandler = $this->getMockBuilder(ResponseHandlerInterface::class)
->getMockForAbstractClass();
$successHandler->method('handleResponse')
->willReturn(true);
- $serializerMock = $this->getMockBuilder(Json::class)
- ->disableOriginalConstructor()
- ->getMock();
- $serializerMock->expects($this->any())
+ $serializerMock = $this->createMock(Json::class);
+ $serializerMock
->method('unserialize')
->willReturn(['unserialized data']);
$objectManager = new ObjectManager($this);
@@ -99,7 +97,7 @@ public function testExecuteSuccess()
$this->analyticsTokenMock->expects($this->once())
->method('isTokenExist')
->willReturn(true);
- $this->configMock->expects($this->any())
+ $this->configMock
->method('getValue')
->willReturn($configVal);
$this->analyticsTokenMock->expects($this->once())
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/OTPRequestTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/OTPRequestTest.php
index 8a3f4efb15cf4..b5c12f40090f2 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/OTPRequestTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/OTPRequestTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model\Connector;
use Magento\Analytics\Model\AnalyticsToken;
@@ -10,12 +12,15 @@
use Magento\Analytics\Model\Connector\Http\ResponseResolver;
use Magento\Analytics\Model\Connector\OTPRequest;
use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\HTTP\ZendClient;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
/**
* A unit test for testing of the representation of a 'OTP' request.
*/
-class OTPRequestTest extends \PHPUnit\Framework\TestCase
+class OTPRequestTest extends TestCase
{
/**
* @var OTPRequest
@@ -23,55 +28,45 @@ class OTPRequestTest extends \PHPUnit\Framework\TestCase
private $subject;
/**
- * @var LoggerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var LoggerInterface|MockObject
*/
private $loggerMock;
/**
- * @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
private $configMock;
/**
- * @var ClientInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ClientInterface|MockObject
*/
private $httpClientMock;
/**
- * @var AnalyticsToken|\PHPUnit_Framework_MockObject_MockObject
+ * @var AnalyticsToken|MockObject
*/
private $analyticsTokenMock;
/**
- * @var ResponseResolver|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResponseResolver|MockObject
*/
private $responseResolverMock;
/**
* @return void
*/
- public function setUp()
+ protected function setUp(): void
{
- $this->loggerMock = $this->getMockBuilder(LoggerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->configMock = $this->getMockBuilder(ScopeConfigInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->httpClientMock = $this->getMockBuilder(ClientInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->analyticsTokenMock = $this->getMockBuilder(AnalyticsToken::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->responseResolverMock = $this->getMockBuilder(ResponseResolver::class)
- ->disableOriginalConstructor()
- ->getMock();
-
+ $this->loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
+
+ $this->configMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
+
+ $this->httpClientMock = $this->getMockForAbstractClass(ClientInterface::class);
+
+ $this->analyticsTokenMock = $this->createMock(AnalyticsToken::class);
+
+ $this->responseResolverMock = $this->createMock(ResponseResolver::class);
+
$this->subject = new OTPRequest(
$this->analyticsTokenMock,
$this->httpClientMock,
@@ -92,7 +87,7 @@ private function getTestData()
'otp' => 'thisisotp',
'url' => 'http://www.mystore.com',
'access-token' => 'thisisaccesstoken',
- 'method' => \Magento\Framework\HTTP\ZendClient::POST,
+ 'method' => ZendClient::POST,
'body'=> ['access-token' => 'thisisaccesstoken','url' => 'http://www.mystore.com'],
];
}
@@ -111,7 +106,7 @@ public function testCallSuccess()
->method('getToken')
->willReturn($data['access-token']);
- $this->configMock->expects($this->any())
+ $this->configMock
->method('getValue')
->willReturn($data['url']);
@@ -162,7 +157,7 @@ public function testCallNoOtp()
->method('getToken')
->willReturn($data['access-token']);
- $this->configMock->expects($this->any())
+ $this->configMock
->method('getValue')
->willReturn($data['url']);
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/OTPTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/OTPTest.php
index 4f3101e87ab9a..3a092f119af72 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/OTPTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/OTPTest.php
@@ -3,11 +3,14 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model\Connector\ResponseHandler;
use Magento\Analytics\Model\Connector\ResponseHandler\OTP;
+use PHPUnit\Framework\TestCase;
-class OTPTest extends \PHPUnit\Framework\TestCase
+class OTPTest extends TestCase
{
public function testHandleResult()
{
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/ReSignUpTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/ReSignUpTest.php
index 928883ca7bad4..e06f1a329f9da 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/ReSignUpTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/ReSignUpTest.php
@@ -3,29 +3,26 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model\Connector\ResponseHandler;
use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\Config\Backend\Enabled\SubscriptionHandler;
use Magento\Analytics\Model\Connector\ResponseHandler\ReSignUp;
use Magento\Analytics\Model\SubscriptionStatusProvider;
+use PHPUnit\Framework\TestCase;
-class ReSignUpTest extends \PHPUnit\Framework\TestCase
+class ReSignUpTest extends TestCase
{
public function testHandleResult()
{
- $analyticsToken = $this->getMockBuilder(AnalyticsToken::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $analyticsToken = $this->createMock(AnalyticsToken::class);
$analyticsToken->expects($this->once())
->method('storeToken')
->with(null);
- $subscriptionHandler = $this->getMockBuilder(SubscriptionHandler::class)
- ->disableOriginalConstructor()
- ->getMock();
- $subscriptionStatusProvider = $this->getMockBuilder(SubscriptionStatusProvider::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $subscriptionHandler = $this->createMock(SubscriptionHandler::class);
+ $subscriptionStatusProvider = $this->createMock(SubscriptionStatusProvider::class);
$subscriptionStatusProvider->method('getStatus')->willReturn(SubscriptionStatusProvider::ENABLED);
$reSignUpHandler = new ReSignUp($analyticsToken, $subscriptionHandler, $subscriptionStatusProvider);
$this->assertFalse($reSignUpHandler->handleResponse([]));
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/SignUpTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/SignUpTest.php
index 15f9884428d2e..2e9e70053b886 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/SignUpTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/SignUpTest.php
@@ -3,20 +3,21 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model\Connector\ResponseHandler;
use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\Connector\ResponseHandler\SignUp;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-class SignUpTest extends \PHPUnit\Framework\TestCase
+class SignUpTest extends TestCase
{
public function testHandleResult()
{
$accessToken = 'access-token-123';
- $analyticsToken = $this->getMockBuilder(AnalyticsToken::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $analyticsToken = $this->createMock(AnalyticsToken::class);
$analyticsToken->expects($this->once())
->method('storeToken')
->with($accessToken);
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/UpdateTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/UpdateTest.php
index 9a3093535afbf..4a35bc2c80596 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/UpdateTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/UpdateTest.php
@@ -3,11 +3,14 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model\Connector\ResponseHandler;
use Magento\Analytics\Model\Connector\ResponseHandler\Update;
+use PHPUnit\Framework\TestCase;
-class UpdateTest extends \PHPUnit\Framework\TestCase
+class UpdateTest extends TestCase
{
public function testHandleResult()
{
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/SignUpCommandTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/SignUpCommandTest.php
index c113b2dc275dd..9f87418038591 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/SignUpCommandTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/SignUpCommandTest.php
@@ -3,19 +3,23 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model\Connector;
+use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\Connector\Http\ClientInterface;
-use Magento\Analytics\Model\Connector\Http\JsonConverter;
use Magento\Analytics\Model\Connector\Http\ResponseResolver;
use Magento\Analytics\Model\Connector\SignUpCommand;
-use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\IntegrationManager;
use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\HTTP\ZendClient;
use Magento\Integration\Model\Oauth\Token as IntegrationToken;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
-class SignUpCommandTest extends \PHPUnit\Framework\TestCase
+class SignUpCommandTest extends TestCase
{
/**
* @var SignUpCommand
@@ -23,66 +27,52 @@ class SignUpCommandTest extends \PHPUnit\Framework\TestCase
private $signUpCommand;
/**
- * @var AnalyticsToken|\PHPUnit_Framework_MockObject_MockObject
+ * @var AnalyticsToken|MockObject
*/
private $analyticsTokenMock;
/**
- * @var IntegrationManager|\PHPUnit_Framework_MockObject_MockObject
+ * @var IntegrationManager|MockObject
*/
private $integrationManagerMock;
/**
- * @var IntegrationToken|\PHPUnit_Framework_MockObject_MockObject
+ * @var IntegrationToken|MockObject
*/
private $integrationToken;
/**
- * @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
private $configMock;
/**
- * @var ClientInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ClientInterface|MockObject
*/
private $httpClientMock;
/**
- * @var LoggerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var LoggerInterface|MockObject
*/
private $loggerMock;
/**
- * @var ResponseResolver|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResponseResolver|MockObject
*/
private $responseResolverMock;
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->analyticsTokenMock = $this->getMockBuilder(AnalyticsToken::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->integrationManagerMock = $this->getMockBuilder(IntegrationManager::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->integrationToken = $this->getMockBuilder(IntegrationToken::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->configMock = $this->getMockBuilder(ScopeConfigInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->httpClientMock = $this->getMockBuilder(ClientInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->loggerMock = $this->getMockBuilder(LoggerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->responseResolverMock = $this->getMockBuilder(ResponseResolver::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->analyticsTokenMock = $this->createMock(AnalyticsToken::class);
+ $this->integrationManagerMock = $this->createMock(IntegrationManager::class);
+ $this->integrationToken = $this->createMock(IntegrationToken::class);
+ $this->configMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
+ $this->httpClientMock = $this->getMockForAbstractClass(ClientInterface::class);
+ $this->loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
+ $this->responseResolverMock = $this->createMock(ResponseResolver::class);
$this->signUpCommand = new SignUpCommand(
$this->analyticsTokenMock,
@@ -108,10 +98,10 @@ public function testExecuteSuccess()
->willReturn(true);
$data = $this->getTestData();
- $this->configMock->expects($this->any())
+ $this->configMock
->method('getValue')
->willReturn($data['url']);
- $this->integrationToken->expects($this->any())
+ $this->integrationToken
->method('getData')
->with('token')
->willReturn($data['integration-token']);
@@ -124,7 +114,7 @@ public function testExecuteSuccess()
$data['body']
)
->willReturn($httpResponse);
- $this->responseResolverMock->expects($this->any())
+ $this->responseResolverMock
->method('getResult')
->with($httpResponse)
->willReturn(true);
@@ -160,7 +150,7 @@ public function testExecuteFailureResponseIsEmpty()
$this->httpClientMock->expects($this->once())
->method('request')
->willReturn($httpResponse);
- $this->responseResolverMock->expects($this->any())
+ $this->responseResolverMock
->method('getResult')
->willReturn(false);
$this->assertFalse($this->signUpCommand->execute());
@@ -177,7 +167,7 @@ private function getTestData()
'url' => 'http://www.mystore.com',
'access-token' => 'thisisaccesstoken',
'integration-token' => 'thisisintegrationtoken',
- 'method' => \Magento\Framework\HTTP\ZendClient::POST,
+ 'method' => ZendClient::POST,
'body'=> ['token' => 'thisisintegrationtoken','url' => 'http://www.mystore.com'],
];
}
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/UpdateCommandTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/UpdateCommandTest.php
index bf3c79e22fc52..d9ba16827aa59 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/UpdateCommandTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/UpdateCommandTest.php
@@ -3,19 +3,23 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model\Connector;
use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\Config\Backend\Baseurl\SubscriptionUpdateHandler;
+use Magento\Analytics\Model\Connector\Http\ClientInterface;
use Magento\Analytics\Model\Connector\Http\ResponseResolver;
+use Magento\Analytics\Model\Connector\UpdateCommand;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\FlagManager;
use Magento\Framework\HTTP\ZendClient;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
-use Magento\Analytics\Model\Connector\UpdateCommand;
-use Magento\Analytics\Model\Connector\Http\ClientInterface;
-class UpdateCommandTest extends \PHPUnit\Framework\TestCase
+class UpdateCommandTest extends TestCase
{
/**
* @var UpdateCommand
@@ -23,60 +27,48 @@ class UpdateCommandTest extends \PHPUnit\Framework\TestCase
private $updateCommand;
/**
- * @var AnalyticsToken|\PHPUnit_Framework_MockObject_MockObject
+ * @var AnalyticsToken|MockObject
*/
private $analyticsTokenMock;
/**
- * @var ClientInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ClientInterface|MockObject
*/
private $httpClientMock;
/**
- * @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
public $configMock;
/**
- * @var LoggerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var LoggerInterface|MockObject
*/
private $loggerMock;
/**
- * @var FlagManager|\PHPUnit_Framework_MockObject_MockObject
+ * @var FlagManager|MockObject
*/
private $flagManagerMock;
/**
- * @var ResponseResolver|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResponseResolver|MockObject
*/
private $responseResolverMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->analyticsTokenMock = $this->getMockBuilder(AnalyticsToken::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->analyticsTokenMock = $this->createMock(AnalyticsToken::class);
- $this->httpClientMock = $this->getMockBuilder(ClientInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->httpClientMock = $this->getMockForAbstractClass(ClientInterface::class);
- $this->configMock = $this->getMockBuilder(ScopeConfigInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->configMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
- $this->loggerMock = $this->getMockBuilder(LoggerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
- $this->flagManagerMock = $this->getMockBuilder(FlagManager::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->flagManagerMock = $this->createMock(FlagManager::class);
- $this->responseResolverMock = $this->getMockBuilder(ResponseResolver::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->responseResolverMock = $this->createMock(ResponseResolver::class);
$this->updateCommand = new UpdateCommand(
$this->analyticsTokenMock,
@@ -97,7 +89,7 @@ public function testExecuteSuccess()
->method('isTokenExist')
->willReturn(true);
- $this->configMock->expects($this->any())
+ $this->configMock
->method('getValue')
->willReturn($configVal);
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ConnectorTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ConnectorTest.php
index 90f6fa1643660..f1d4d51f872e7 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/ConnectorTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/ConnectorTest.php
@@ -3,16 +3,20 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model;
use Magento\Analytics\Model\Connector;
-use Magento\Framework\ObjectManagerInterface;
use Magento\Analytics\Model\Connector\SignUpCommand;
+use Magento\Framework\ObjectManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ConnectorTest extends \PHPUnit\Framework\TestCase
+class ConnectorTest extends TestCase
{
/**
- * @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ObjectManagerInterface|MockObject
*/
private $objectManagerMock;
@@ -22,7 +26,7 @@ class ConnectorTest extends \PHPUnit\Framework\TestCase
private $connector;
/**
- * @var SignUpCommand|\PHPUnit_Framework_MockObject_MockObject
+ * @var SignUpCommand|MockObject
*/
private $signUpCommandMock;
@@ -31,14 +35,10 @@ class ConnectorTest extends \PHPUnit\Framework\TestCase
*/
private $commands;
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->signUpCommandMock = $this->getMockBuilder(SignUpCommand::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->objectManagerMock = $this->getMockForAbstractClass(ObjectManagerInterface::class);
+ $this->signUpCommandMock = $this->createMock(SignUpCommand::class);
$this->commands = ['signUp' => SignUpCommand::class];
$this->connector = new Connector($this->commands, $this->objectManagerMock);
}
@@ -59,12 +59,12 @@ public function testExecute()
/**
* Executing non-existing command
*
- * @expectedException \Magento\Framework\Exception\NotFoundException
- * @expectedExceptionMessage Command "register" was not found.
* @return void
*/
public function testExecuteCommandNotFound(): void
{
+ $this->expectException('Magento\Framework\Exception\NotFoundException');
+ $this->expectExceptionMessage('Command "register" was not found.');
$commandName = 'register';
$this->connector->execute($commandName);
}
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/CryptographerTest.php b/app/code/Magento/Analytics/Test/Unit/Model/CryptographerTest.php
index 6ccf81cb94bad..562f6db34679e 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/CryptographerTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/CryptographerTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model;
use Magento\Analytics\Model\AnalyticsToken;
@@ -10,21 +12,23 @@
use Magento\Analytics\Model\EncodedContext;
use Magento\Analytics\Model\EncodedContextFactory;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class CryptographerTest extends \PHPUnit\Framework\TestCase
+class CryptographerTest extends TestCase
{
/**
- * @var AnalyticsToken|\PHPUnit_Framework_MockObject_MockObject
+ * @var AnalyticsToken|MockObject
*/
private $analyticsTokenMock;
/**
- * @var EncodedContextFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var EncodedContextFactory|MockObject
*/
private $encodedContextFactoryMock;
/**
- * @var EncodedContext|\PHPUnit_Framework_MockObject_MockObject
+ * @var EncodedContext|MockObject
*/
private $encodedContextMock;
@@ -61,20 +65,16 @@ class CryptographerTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->analyticsTokenMock = $this->getMockBuilder(AnalyticsToken::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->analyticsTokenMock = $this->createMock(AnalyticsToken::class);
$this->encodedContextFactoryMock = $this->getMockBuilder(EncodedContextFactory::class)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
- $this->encodedContextMock = $this->getMockBuilder(EncodedContext::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->encodedContextMock = $this->createMock(EncodedContext::class);
$this->key = '';
$this->source = '';
@@ -170,11 +170,11 @@ public function testEncodeUniqueInitializationVector()
}
/**
- * @expectedException \Magento\Framework\Exception\LocalizedException
* @dataProvider encodeNotValidSourceDataProvider
*/
public function testEncodeNotValidSource($source)
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
$this->cryptographer->encode($source);
}
@@ -189,11 +189,9 @@ public function encodeNotValidSourceDataProvider()
];
}
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- */
public function testEncodeNotValidCipherMethod()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
$source = 'Some string';
$cryptographer = $this->objectManagerHelper->getObject(
Cryptographer::class,
@@ -205,11 +203,9 @@ public function testEncodeNotValidCipherMethod()
$cryptographer->encode($source);
}
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- */
public function testEncodeTokenNotValid()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
$source = 'Some string';
$this->analyticsTokenMock
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/EncodedContextTest.php b/app/code/Magento/Analytics/Test/Unit/Model/EncodedContextTest.php
index e85dde90657ff..5d998948de6fa 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/EncodedContextTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/EncodedContextTest.php
@@ -3,12 +3,15 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model;
use Magento\Analytics\Model\EncodedContext;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\TestCase;
-class EncodedContextTest extends \PHPUnit\Framework\TestCase
+class EncodedContextTest extends TestCase
{
/**
* @var ObjectManagerHelper
@@ -18,7 +21,7 @@ class EncodedContextTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManagerHelper = new ObjectManagerHelper($this);
}
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerNotificationTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerNotificationTest.php
index d1cf2ce48a04e..767cc30b7a602 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerNotificationTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerNotificationTest.php
@@ -3,14 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model;
use Magento\Analytics\Model\Connector;
use Magento\Analytics\Model\ExportDataHandler;
use Magento\Analytics\Model\ExportDataHandlerNotification;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ExportDataHandlerNotificationTest extends \PHPUnit\Framework\TestCase
+class ExportDataHandlerNotificationTest extends TestCase
{
/**
* @var ObjectManagerHelper
@@ -20,7 +24,7 @@ class ExportDataHandlerNotificationTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- public function setUp()
+ protected function setUp(): void
{
$this->objectManagerHelper = new ObjectManagerHelper($this);
}
@@ -35,7 +39,7 @@ public function testThatNotifyExecuted()
$exportDataHandlerMockObject = $this->createExportDataHandlerMock();
$analyticsConnectorMockObject = $this->createAnalyticsConnectorMock();
/**
- * @var $exportDataHandlerNotification ExportDataHandlerNotification
+ * @var ExportDataHandlerNotification $exportDataHandlerNotification
*/
$exportDataHandlerNotification = $this->objectManagerHelper->getObject(
ExportDataHandlerNotification::class,
@@ -54,18 +58,18 @@ public function testThatNotifyExecuted()
}
/**
- * @return \PHPUnit_Framework_MockObject_MockObject
+ * @return MockObject
*/
private function createExportDataHandlerMock()
{
- return $this->getMockBuilder(ExportDataHandler::class)->disableOriginalConstructor()->getMock();
+ return $this->createMock(ExportDataHandler::class);
}
/**
- * @return \PHPUnit_Framework_MockObject_MockObject
+ * @return MockObject
*/
private function createAnalyticsConnectorMock()
{
- return $this->getMockBuilder(Connector::class)->disableOriginalConstructor()->getMock();
+ return $this->createMock(Connector::class);
}
}
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerTest.php
index cf00556cfe590..b3038197b1410 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model;
use Magento\Analytics\Model\Cryptographer;
@@ -15,41 +17,43 @@
use Magento\Framework\Filesystem\Directory\WriteInterface;
use Magento\Framework\Filesystem\DirectoryList;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ExportDataHandlerTest extends \PHPUnit\Framework\TestCase
+class ExportDataHandlerTest extends TestCase
{
/**
- * @var Filesystem|\PHPUnit_Framework_MockObject_MockObject
+ * @var Filesystem|MockObject
*/
private $filesystemMock;
/**
- * @var Archive|\PHPUnit_Framework_MockObject_MockObject
+ * @var Archive|MockObject
*/
private $archiveMock;
/**
- * @var ReportWriterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ReportWriterInterface|MockObject
*/
private $reportWriterMock;
/**
- * @var Cryptographer|\PHPUnit_Framework_MockObject_MockObject
+ * @var Cryptographer|MockObject
*/
private $cryptographerMock;
/**
- * @var FileRecorder|\PHPUnit_Framework_MockObject_MockObject
+ * @var FileRecorder|MockObject
*/
private $fileRecorderMock;
/**
- * @var WriteInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var WriteInterface|MockObject
*/
private $directoryMock;
/**
- * @var EncodedContext|\PHPUnit_Framework_MockObject_MockObject
+ * @var EncodedContext|MockObject
*/
private $encodedContextMock;
@@ -76,35 +80,21 @@ class ExportDataHandlerTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->filesystemMock = $this->getMockBuilder(Filesystem::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->filesystemMock = $this->createMock(Filesystem::class);
- $this->archiveMock = $this->getMockBuilder(Archive::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->archiveMock = $this->createMock(Archive::class);
- $this->reportWriterMock = $this->getMockBuilder(ReportWriterInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->reportWriterMock = $this->getMockForAbstractClass(ReportWriterInterface::class);
- $this->cryptographerMock = $this->getMockBuilder(Cryptographer::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->cryptographerMock = $this->createMock(Cryptographer::class);
- $this->fileRecorderMock = $this->getMockBuilder(FileRecorder::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->fileRecorderMock = $this->createMock(FileRecorder::class);
- $this->directoryMock = $this->getMockBuilder(WriteInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->directoryMock = $this->getMockForAbstractClass(WriteInterface::class);
- $this->encodedContextMock = $this->getMockBuilder(EncodedContext::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->encodedContextMock = $this->createMock(EncodedContext::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
@@ -228,10 +218,10 @@ public function prepareExportDataDataProvider()
/**
* @return void
- * @expectedException \Magento\Framework\Exception\LocalizedException
*/
public function testPrepareExportDataWithLocalizedException()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
$tmpFilesDirectoryPath = $this->subdirectoryPath . 'tmp/';
$archivePath = $this->subdirectoryPath . $this->archiveName;
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/FileInfoManagerTest.php b/app/code/Magento/Analytics/Test/Unit/Model/FileInfoManagerTest.php
index e49c942161cf2..f7d96b9c7839c 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/FileInfoManagerTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/FileInfoManagerTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model;
use Magento\Analytics\Model\FileInfo;
@@ -10,21 +12,23 @@
use Magento\Analytics\Model\FileInfoManager;
use Magento\Framework\FlagManager;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class FileInfoManagerTest extends \PHPUnit\Framework\TestCase
+class FileInfoManagerTest extends TestCase
{
/**
- * @var FlagManager|\PHPUnit_Framework_MockObject_MockObject
+ * @var FlagManager|MockObject
*/
private $flagManagerMock;
/**
- * @var FileInfoFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var FileInfoFactory|MockObject
*/
private $fileInfoFactoryMock;
/**
- * @var FileInfo|\PHPUnit_Framework_MockObject_MockObject
+ * @var FileInfo|MockObject
*/
private $fileInfoMock;
@@ -53,20 +57,16 @@ class FileInfoManagerTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->flagManagerMock = $this->getMockBuilder(FlagManager::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->flagManagerMock = $this->createMock(FlagManager::class);
$this->fileInfoFactoryMock = $this->getMockBuilder(FileInfoFactory::class)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
- $this->fileInfoMock = $this->getMockBuilder(FileInfo::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->fileInfoMock = $this->createMock(FileInfo::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
@@ -119,10 +119,10 @@ public function testSave()
* @param string|null $path
* @param string|null $initializationVector
* @dataProvider saveWithLocalizedExceptionDataProvider
- * @expectedException \Magento\Framework\Exception\LocalizedException
*/
public function testSaveWithLocalizedException($path, $initializationVector)
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
$this->fileInfoMock
->expects($this->once())
->method('getPath')
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/FileInfoTest.php b/app/code/Magento/Analytics/Test/Unit/Model/FileInfoTest.php
index 2a3588c8032fc..92522578fafda 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/FileInfoTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/FileInfoTest.php
@@ -3,12 +3,15 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model;
use Magento\Analytics\Model\FileInfo;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\TestCase;
-class FileInfoTest extends \PHPUnit\Framework\TestCase
+class FileInfoTest extends TestCase
{
/**
* @var ObjectManagerHelper
@@ -18,7 +21,7 @@ class FileInfoTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManagerHelper = new ObjectManagerHelper($this);
}
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/FileRecorderTest.php b/app/code/Magento/Analytics/Test/Unit/Model/FileRecorderTest.php
index bf5795111230b..50e7c8ed55f1b 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/FileRecorderTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/FileRecorderTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model;
use Magento\Analytics\Model\EncodedContext;
@@ -14,36 +16,38 @@
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\WriteInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class FileRecorderTest extends \PHPUnit\Framework\TestCase
+class FileRecorderTest extends TestCase
{
/**
- * @var FileInfoManager|\PHPUnit_Framework_MockObject_MockObject
+ * @var FileInfoManager|MockObject
*/
private $fileInfoManagerMock;
/**
- * @var FileInfoFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var FileInfoFactory|MockObject
*/
private $fileInfoFactoryMock;
/**
- * @var Filesystem|\PHPUnit_Framework_MockObject_MockObject
+ * @var Filesystem|MockObject
*/
private $filesystemMock;
/**
- * @var FileInfo|\PHPUnit_Framework_MockObject_MockObject
+ * @var FileInfo|MockObject
*/
private $fileInfoMock;
/**
- * @var WriteInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var WriteInterface|MockObject
*/
private $directoryMock;
/**
- * @var EncodedContext|\PHPUnit_Framework_MockObject_MockObject
+ * @var EncodedContext|MockObject
*/
private $encodedContextMock;
@@ -70,32 +74,22 @@ class FileRecorderTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->fileInfoManagerMock = $this->getMockBuilder(FileInfoManager::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->fileInfoManagerMock = $this->createMock(FileInfoManager::class);
$this->fileInfoFactoryMock = $this->getMockBuilder(FileInfoFactory::class)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
- $this->filesystemMock = $this->getMockBuilder(Filesystem::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->filesystemMock = $this->createMock(Filesystem::class);
- $this->fileInfoMock = $this->getMockBuilder(FileInfo::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->fileInfoMock = $this->createMock(FileInfo::class);
- $this->directoryMock = $this->getMockBuilder(WriteInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->directoryMock = $this->getMockForAbstractClass(WriteInterface::class);
- $this->encodedContextMock = $this->getMockBuilder(EncodedContext::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->encodedContextMock = $this->createMock(EncodedContext::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/IntegrationManagerTest.php b/app/code/Magento/Analytics/Test/Unit/Model/IntegrationManagerTest.php
index 568047a4521f8..d600644caf312 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/IntegrationManagerTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/IntegrationManagerTest.php
@@ -3,35 +3,38 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Analytics\Test\Unit\Model;
-use Magento\Integration\Api\IntegrationServiceInterface;
-use Magento\Config\Model\Config;
-use Magento\Integration\Model\Integration;
use Magento\Analytics\Model\IntegrationManager;
-use Magento\Integration\Api\OauthServiceInterface;
+use Magento\Config\Model\Config;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Integration\Api\IntegrationServiceInterface;
+use Magento\Integration\Api\OauthServiceInterface;
+use Magento\Integration\Model\Integration;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class IntegrationManagerTest extends \PHPUnit\Framework\TestCase
+class IntegrationManagerTest extends TestCase
{
/**
- * @var IntegrationServiceInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var IntegrationServiceInterface|MockObject
*/
private $integrationServiceMock;
/**
- * @var OauthServiceInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var OauthServiceInterface|MockObject
*/
private $oauthServiceMock;
/**
- * @var Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
private $configMock;
/**
- * @var Integration|\PHPUnit_Framework_MockObject_MockObject
+ * @var Integration|MockObject
*/
private $integrationMock;
@@ -40,16 +43,12 @@ class IntegrationManagerTest extends \PHPUnit\Framework\TestCase
*/
private $integrationManager;
- public function setUp()
+ protected function setUp(): void
{
$objectManagerHelper = new ObjectManagerHelper($this);
- $this->integrationServiceMock = $this->getMockBuilder(IntegrationServiceInterface::class)
- ->getMock();
- $this->configMock = $this->getMockBuilder(Config::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->oauthServiceMock = $this->getMockBuilder(OauthServiceInterface::class)
- ->getMock();
+ $this->integrationServiceMock = $this->getMockForAbstractClass(IntegrationServiceInterface::class);
+ $this->configMock = $this->createMock(Config::class);
+ $this->oauthServiceMock = $this->getMockForAbstractClass(OauthServiceInterface::class);
$this->integrationMock = $this->getMockBuilder(Integration::class)
->disableOriginalConstructor()
->setMethods([
@@ -109,11 +108,9 @@ public function testActivateIntegrationSuccess()
$this->assertTrue($this->integrationManager->activateIntegration());
}
- /**
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- */
public function testActivateIntegrationFailureNoSuchEntity()
{
+ $this->expectException('Magento\Framework\Exception\NoSuchEntityException');
$this->integrationServiceMock->expects($this->once())
->method('findByName')
->with('ma-integration-user')
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/LinkProviderTest.php b/app/code/Magento/Analytics/Test/Unit/Model/LinkProviderTest.php
index 2053187e641ae..e888c38c4e817 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/LinkProviderTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/LinkProviderTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model;
use Magento\Analytics\Api\Data\LinkInterface;
@@ -14,8 +16,10 @@
use Magento\Framework\UrlInterface;
use Magento\Store\Model\Store;
use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class LinkProviderTest extends \PHPUnit\Framework\TestCase
+class LinkProviderTest extends TestCase
{
/**
* @var ObjectManagerHelper
@@ -23,32 +27,32 @@ class LinkProviderTest extends \PHPUnit\Framework\TestCase
private $objectManagerHelper;
/**
- * @var LinkInterfaceFactory | \PHPUnit_Framework_MockObject_MockObject
+ * @var LinkInterfaceFactory|MockObject
*/
private $linkInterfaceFactoryMock;
/**
- * @var FileInfoManager | \PHPUnit_Framework_MockObject_MockObject
+ * @var FileInfoManager|MockObject
*/
private $fileInfoManagerMock;
/**
- * @var StoreManagerInterface | \PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
private $storeManagerInterfaceMock;
/**
- * @var LinkInterface | \PHPUnit_Framework_MockObject_MockObject
+ * @var LinkInterface|MockObject
*/
private $linkInterfaceMock;
/**
- * @var FileInfo | \PHPUnit_Framework_MockObject_MockObject
+ * @var FileInfo|MockObject
*/
private $fileInfoMock;
/**
- * @var Store | \PHPUnit_Framework_MockObject_MockObject
+ * @var Store|MockObject
*/
private $storeMock;
@@ -60,25 +64,19 @@ class LinkProviderTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->linkInterfaceFactoryMock = $this->getMockBuilder(LinkInterfaceFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
- $this->fileInfoManagerMock = $this->getMockBuilder(FileInfoManager::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->fileInfoManagerMock = $this->createMock(FileInfoManager::class);
$this->storeManagerInterfaceMock = $this->getMockBuilder(StoreManagerInterface::class)
->getMockForAbstractClass();
$this->linkInterfaceMock = $this->getMockBuilder(LinkInterface::class)
->getMockForAbstractClass();
- $this->fileInfoMock = $this->getMockBuilder(FileInfo::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->storeMock = $this->getMockBuilder(Store::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->fileInfoMock = $this->createMock(FileInfo::class);
+ $this->storeMock = $this->createMock(Store::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->linkProvider = $this->objectManagerHelper->getObject(
LinkProvider::class,
@@ -129,18 +127,18 @@ public function testGet()
* @param string|null $fileInitializationVector
*
* @dataProvider fileNotReadyDataProvider
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage File is not ready yet.
*/
public function testFileNotReady($fileInfoPath, $fileInitializationVector)
{
+ $this->expectException('Magento\Framework\Exception\NoSuchEntityException');
+ $this->expectExceptionMessage('File is not ready yet.');
$this->fileInfoManagerMock->expects($this->once())
->method('load')
->willReturn($this->fileInfoMock);
$this->fileInfoMock->expects($this->once())
->method('getPath')
->willReturn($fileInfoPath);
- $this->fileInfoMock->expects($this->any())
+ $this->fileInfoMock
->method('getInitializationVector')
->willReturn($fileInitializationVector);
$this->linkProvider->get();
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Plugin/BaseUrlConfigPluginTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Plugin/BaseUrlConfigPluginTest.php
index cdcd726f3e8fa..918320ef9c319 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Plugin/BaseUrlConfigPluginTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Plugin/BaseUrlConfigPluginTest.php
@@ -3,26 +3,29 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model\Plugin;
use Magento\Analytics\Model\Config\Backend\Baseurl\SubscriptionUpdateHandler;
use Magento\Analytics\Model\Plugin\BaseUrlConfigPlugin;
-use Magento\Analytics\Model\SubscriptionStatusProvider;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Config\Value;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\Store;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class BaseUrlConfigPluginTest extends \PHPUnit\Framework\TestCase
+class BaseUrlConfigPluginTest extends TestCase
{
/**
- * @var SubscriptionUpdateHandler | \PHPUnit_Framework_MockObject_MockObject
+ * @var SubscriptionUpdateHandler|MockObject
*/
private $subscriptionUpdateHandlerMock;
/**
- * @var Value | \PHPUnit_Framework_MockObject_MockObject
+ * @var Value|MockObject
*/
private $configValueMock;
@@ -39,11 +42,9 @@ class BaseUrlConfigPluginTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->subscriptionUpdateHandlerMock = $this->getMockBuilder(SubscriptionUpdateHandler::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->subscriptionUpdateHandlerMock = $this->createMock(SubscriptionUpdateHandler::class);
$this->configValueMock = $this->getMockBuilder(Value::class)
->disableOriginalConstructor()
->setMethods(['isValueChanged', 'getPath', 'getScope', 'getOldValue'])
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ReportUrlProviderTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ReportUrlProviderTest.php
index 0607a977e5b68..60dcfde64f16d 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/ReportUrlProviderTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/ReportUrlProviderTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model;
use Magento\Analytics\Model\AnalyticsToken;
@@ -13,29 +15,31 @@
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\FlagManager;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ReportUrlProviderTest extends \PHPUnit\Framework\TestCase
+class ReportUrlProviderTest extends TestCase
{
/**
- * @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
private $configMock;
/**
- * @var AnalyticsToken|\PHPUnit_Framework_MockObject_MockObject
+ * @var AnalyticsToken|MockObject
*/
private $analyticsTokenMock;
/**
- * @var OTPRequest|\PHPUnit_Framework_MockObject_MockObject
+ * @var OTPRequest|MockObject
*/
private $otpRequestMock;
/**
- * @var FlagManager|\PHPUnit_Framework_MockObject_MockObject
+ * @var FlagManager|MockObject
*/
private $flagManagerMock;
@@ -57,23 +61,15 @@ class ReportUrlProviderTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->configMock = $this->getMockBuilder(ScopeConfigInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->configMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
- $this->analyticsTokenMock = $this->getMockBuilder(AnalyticsToken::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->analyticsTokenMock = $this->createMock(AnalyticsToken::class);
- $this->otpRequestMock = $this->getMockBuilder(OTPRequest::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->otpRequestMock = $this->createMock(OTPRequest::class);
- $this->flagManagerMock = $this->getMockBuilder(FlagManager::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->flagManagerMock = $this->createMock(FlagManager::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ReportWriterTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ReportWriterTest.php
index d9b030b84d639..b68e26f98a397 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/ReportWriterTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/ReportWriterTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model;
use Magento\Analytics\Model\ConfigInterface;
@@ -12,29 +14,31 @@
use Magento\Analytics\ReportXml\ReportProvider;
use Magento\Framework\Filesystem\Directory\WriteInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ReportWriterTest extends \PHPUnit\Framework\TestCase
+class ReportWriterTest extends TestCase
{
/**
- * @var ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ConfigInterface|MockObject
*/
private $configInterfaceMock;
/**
- * @var ReportValidator|\PHPUnit_Framework_MockObject_MockObject
+ * @var ReportValidator|MockObject
*/
private $reportValidatorMock;
/**
- * @var ProviderFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProviderFactory|MockObject
*/
private $providerFactoryMock;
/**
- * @var ReportProvider|\PHPUnit_Framework_MockObject_MockObject
+ * @var ReportProvider|MockObject
*/
private $reportProviderMock;
@@ -44,7 +48,7 @@ class ReportWriterTest extends \PHPUnit\Framework\TestCase
private $objectManagerHelper;
/**
- * @var WriteInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var WriteInterface|MockObject
*/
private $directoryMock;
@@ -71,16 +75,15 @@ class ReportWriterTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->configInterfaceMock = $this->getMockBuilder(ConfigInterface::class)->getMockForAbstractClass();
- $this->reportValidatorMock = $this->getMockBuilder(ReportValidator::class)
- ->disableOriginalConstructor()->getMock();
- $this->providerFactoryMock = $this->getMockBuilder(ProviderFactory::class)
- ->disableOriginalConstructor()->getMock();
- $this->reportProviderMock = $this->getMockBuilder(ReportProvider::class)
- ->disableOriginalConstructor()->getMock();
- $this->directoryMock = $this->getMockBuilder(WriteInterface::class)->getMockForAbstractClass();
+ $this->configInterfaceMock = $this->getMockBuilder(ConfigInterface::class)
+ ->getMockForAbstractClass();
+ $this->reportValidatorMock = $this->createMock(ReportValidator::class);
+ $this->providerFactoryMock = $this->createMock(ProviderFactory::class);
+ $this->reportProviderMock = $this->createMock(ReportProvider::class);
+ $this->directoryMock = $this->getMockBuilder(WriteInterface::class)
+ ->getMockForAbstractClass();
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->reportWriter = $this->objectManagerHelper->getObject(
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ReportXml/ModuleIteratorTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ReportXml/ModuleIteratorTest.php
index 5288bcd306af9..121bfce8b156f 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/ReportXml/ModuleIteratorTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/ReportXml/ModuleIteratorTest.php
@@ -3,33 +3,31 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Analytics\Test\Unit\Model\ReportXml;
use Magento\Analytics\Model\ReportXml\ModuleIterator;
use Magento\Framework\Module\Manager as ModuleManager;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Module iterator test.
- */
-class ModuleIteratorTest extends \PHPUnit\Framework\TestCase
+class ModuleIteratorTest extends TestCase
{
/**
- * @var ModuleManager|\PHPUnit_Framework_MockObject_MockObject
+ * @var ModuleManager|MockObject
*/
private $moduleManagerMock;
/**
- * @var ModuleIterator|\PHPUnit_Framework_MockObject_MockObject
+ * @var ModuleIterator|MockObject
*/
private $moduleIterator;
- public function setUp()
+ protected function setUp(): void
{
- $this->moduleManagerMock = $this->getMockBuilder(ModuleManager::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->moduleManagerMock = $this->createMock(ModuleManager::class);
$objectManagerHelper = new ObjectManagerHelper($this);
$this->moduleIterator = $objectManagerHelper->getObject(
ModuleIterator::class,
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/StoreConfigurationProviderTest.php b/app/code/Magento/Analytics/Test/Unit/Model/StoreConfigurationProviderTest.php
index cc46d175543ad..2c9c57eb46dc5 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/StoreConfigurationProviderTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/StoreConfigurationProviderTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Analytics\Test\Unit\Model;
@@ -11,11 +12,13 @@
use Magento\Store\Api\Data\StoreInterface;
use Magento\Store\Api\Data\WebsiteInterface;
use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class StoreConfigurationProviderTest extends \PHPUnit\Framework\TestCase
+class StoreConfigurationProviderTest extends TestCase
{
/**
- * @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
private $scopeConfigMock;
@@ -25,45 +28,37 @@ class StoreConfigurationProviderTest extends \PHPUnit\Framework\TestCase
private $configPaths;
/**
- * @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
private $storeManagerMock;
/**
- * @var WebsiteInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var WebsiteInterface|MockObject
*/
private $websiteMock;
/**
- * @var StoreInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreInterface|MockObject
*/
private $storeMock;
/**
- * @var StoreConfigurationProvider|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreConfigurationProvider|MockObject
*/
private $storeConfigurationProvider;
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
- $this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->storeManagerMock = $this->getMockForAbstractClass(StoreManagerInterface::class);
- $this->websiteMock = $this->getMockBuilder(WebsiteInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->websiteMock = $this->getMockForAbstractClass(WebsiteInterface::class);
- $this->storeMock = $this->getMockBuilder(StoreInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->storeMock = $this->getMockForAbstractClass(StoreInterface::class);
$this->configPaths = [
'web/unsecure/base_url',
@@ -94,7 +89,7 @@ public function testGetReport()
$this->scopeConfigMock
->method('getValue')
- ->will($this->returnValueMap($map));
+ ->willReturnMap($map);
$this->storeManagerMock->expects($this->once())
->method('getWebsites')
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/SubscriptionStatusProviderTest.php b/app/code/Magento/Analytics/Test/Unit/Model/SubscriptionStatusProviderTest.php
index 373bb73d999f8..6f9dc82b2bf9f 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/SubscriptionStatusProviderTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/SubscriptionStatusProviderTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model;
use Magento\Analytics\Model\AnalyticsToken;
@@ -12,21 +14,23 @@
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\FlagManager;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class SubscriptionStatusProviderTest extends \PHPUnit\Framework\TestCase
+class SubscriptionStatusProviderTest extends TestCase
{
/**
- * @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
private $scopeConfigMock;
/**
- * @var AnalyticsToken|\PHPUnit_Framework_MockObject_MockObject
+ * @var AnalyticsToken|MockObject
*/
private $analyticsTokenMock;
/**
- * @var FlagManager|\PHPUnit_Framework_MockObject_MockObject
+ * @var FlagManager|MockObject
*/
private $flagManagerMock;
@@ -43,18 +47,14 @@ class SubscriptionStatusProviderTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class)
->getMockForAbstractClass();
- $this->analyticsTokenMock = $this->getMockBuilder(AnalyticsToken::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->analyticsTokenMock = $this->createMock(AnalyticsToken::class);
- $this->flagManagerMock = $this->getMockBuilder(FlagManager::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->flagManagerMock = $this->createMock(FlagManager::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/System/Message/NotificationAboutFailedSubscriptionTest.php b/app/code/Magento/Analytics/Test/Unit/Model/System/Message/NotificationAboutFailedSubscriptionTest.php
index 8c515afa32dd6..cc12c0da9866e 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/System/Message/NotificationAboutFailedSubscriptionTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/System/Message/NotificationAboutFailedSubscriptionTest.php
@@ -3,22 +3,26 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\Model\System\Message;
use Magento\Analytics\Model\SubscriptionStatusProvider;
use Magento\Analytics\Model\System\Message\NotificationAboutFailedSubscription;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use Magento\Framework\UrlInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class NotificationAboutFailedSubscriptionTest extends \PHPUnit\Framework\TestCase
+class NotificationAboutFailedSubscriptionTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|SubscriptionStatusProvider
+ * @var MockObject|SubscriptionStatusProvider
*/
private $subscriptionStatusMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|UrlInterface
+ * @var MockObject|UrlInterface
*/
private $urlBuilderMock;
@@ -35,11 +39,9 @@ class NotificationAboutFailedSubscriptionTest extends \PHPUnit\Framework\TestCas
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->subscriptionStatusMock = $this->getMockBuilder(SubscriptionStatusProvider::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->subscriptionStatusMock = $this->createMock(SubscriptionStatusProvider::class);
$this->urlBuilderMock = $this->getMockBuilder(UrlInterface::class)
->getMockForAbstractClass();
$this->objectManagerHelper = new ObjectManagerHelper($this);
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/Converter/XmlTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/Converter/XmlTest.php
index 3f1ed9a5cf4c0..9c2a891e05b93 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/Converter/XmlTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/Converter/XmlTest.php
@@ -3,33 +3,39 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\ReportXml\Config\Converter;
+use Magento\Analytics\ReportXml\Config\Converter\Xml;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
+
/**
* A unit test for testing of the reports configuration converter (XML to PHP array).
*/
-class XmlTest extends \PHPUnit\Framework\TestCase
+class XmlTest extends TestCase
{
/**
- * @var \Magento\Analytics\ReportXml\Config\Converter\Xml
+ * @var Xml
*/
private $subject;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
private $objectManagerHelper;
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManagerHelper =
- new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ new ObjectManager($this);
$this->subject = $this->objectManagerHelper->getObject(
- \Magento\Analytics\ReportXml\Config\Converter\Xml::class
+ Xml::class
);
}
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/MapperTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/MapperTest.php
index e764add9ba2f0..2df9f43f53d74 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/MapperTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/MapperTest.php
@@ -3,18 +3,21 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\ReportXml\Config;
use Magento\Analytics\ReportXml\Config\Mapper;
+use PHPUnit\Framework\TestCase;
-class MapperTest extends \PHPUnit\Framework\TestCase
+class MapperTest extends TestCase
{
/**
* @var Mapper
*/
private $mapper;
- protected function setUp()
+ protected function setUp(): void
{
$this->mapper = new Mapper();
}
@@ -28,10 +31,10 @@ public function testExecute()
]
];
$expectedResult = [
- 'Product' => [
- 'source' => 'product',
- 'name' => 'Product',
- ]
+ 'Product' => [
+ 'source' => 'product',
+ 'name' => 'Product',
+ ]
];
$this->assertEquals($this->mapper->execute($configData), $expectedResult);
}
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/ConfigTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/ConfigTest.php
index 7e6866d5a1e60..675c4ab61b0ff 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/ConfigTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/ConfigTest.php
@@ -3,16 +3,20 @@
* 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\Config;
use Magento\Framework\Config\DataInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ConfigTest extends \PHPUnit\Framework\TestCase
+class ConfigTest extends TestCase
{
/**
- * @var DataInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var DataInterface|MockObject
*/
private $dataMock;
@@ -29,11 +33,9 @@ class ConfigTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->dataMock = $this->getMockBuilder(DataInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->dataMock = $this->getMockForAbstractClass(DataInterface::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/ConnectionFactoryTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/ConnectionFactoryTest.php
index 1d40919ecfc4a..16caaa380067f 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/ConnectionFactoryTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/ConnectionFactoryTest.php
@@ -3,34 +3,38 @@
* 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\ConnectionFactory;
use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\DB\Adapter\Pdo\Mysql as MysqlPdoAdapter;
use Magento\Framework\ObjectManagerInterface;
-use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ConnectionFactoryTest extends \PHPUnit\Framework\TestCase
+class ConnectionFactoryTest extends TestCase
{
/**
- * @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResourceConnection|MockObject
*/
private $resourceConnectionMock;
/**
- * @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ObjectManagerInterface|MockObject
*/
private $objectManagerMock;
/**
- * @var ConnectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ConnectionFactory|MockObject
*/
private $connectionNewMock;
/**
- * @var AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AdapterInterface|MockObject
*/
private $connectionMock;
@@ -47,23 +51,15 @@ class ConnectionFactoryTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->resourceConnectionMock = $this->getMockBuilder(ResourceConnection::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->resourceConnectionMock = $this->createMock(ResourceConnection::class);
- $this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->objectManagerMock = $this->getMockForAbstractClass(ObjectManagerInterface::class);
- $this->connectionMock = $this->getMockBuilder(MysqlPdoAdapter::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->connectionMock = $this->createMock(MysqlPdoAdapter::class);
- $this->connectionNewMock = $this->getMockBuilder(MysqlPdoAdapter::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->connectionNewMock = $this->createMock(MysqlPdoAdapter::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FilterAssemblerTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FilterAssemblerTest.php
index 3b01105a8873b..a2ab68d3e8d11 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FilterAssemblerTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FilterAssemblerTest.php
@@ -3,69 +3,67 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\ReportXml\DB\Assembler;
+use Magento\Analytics\ReportXml\DB\Assembler\FilterAssembler;
+use Magento\Analytics\ReportXml\DB\ConditionResolver;
+use Magento\Analytics\ReportXml\DB\NameResolver;
+use Magento\Analytics\ReportXml\DB\SelectBuilder;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* A unit test for testing of the 'filter' assembler.
*/
-class FilterAssemblerTest extends \PHPUnit\Framework\TestCase
+class FilterAssemblerTest extends TestCase
{
/**
- * @var \Magento\Analytics\ReportXml\DB\Assembler\FilterAssembler
+ * @var FilterAssembler
*/
private $subject;
/**
- * @var \Magento\Analytics\ReportXml\DB\NameResolver|\PHPUnit_Framework_MockObject_MockObject
+ * @var NameResolver|MockObject
*/
private $nameResolverMock;
/**
- * @var \Magento\Analytics\ReportXml\DB\SelectBuilder|\PHPUnit_Framework_MockObject_MockObject
+ * @var SelectBuilder|MockObject
*/
private $selectBuilderMock;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
private $objectManagerHelper;
/**
- * @var \Magento\Analytics\ReportXml\DB\ConditionResolver|\PHPUnit_Framework_MockObject_MockObject
+ * @var ConditionResolver|MockObject
*/
private $conditionResolverMock;
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->nameResolverMock = $this->getMockBuilder(
- \Magento\Analytics\ReportXml\DB\NameResolver::class
- )
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->selectBuilderMock = $this->getMockBuilder(
- \Magento\Analytics\ReportXml\DB\SelectBuilder::class
- )
- ->disableOriginalConstructor()
- ->getMock();
- $this->selectBuilderMock->expects($this->any())
+ $this->nameResolverMock = $this->createMock(NameResolver::class);
+
+ $this->selectBuilderMock = $this->createMock(SelectBuilder::class);
+ $this->selectBuilderMock
->method('getFilters')
->willReturn([]);
- $this->conditionResolverMock = $this->getMockBuilder(
- \Magento\Analytics\ReportXml\DB\ConditionResolver::class
- )
- ->disableOriginalConstructor()
- ->getMock();
+ $this->conditionResolverMock = $this->createMock(ConditionResolver::class);
$this->objectManagerHelper =
- new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ new ObjectManager($this);
$this->subject = $this->objectManagerHelper->getObject(
- \Magento\Analytics\ReportXml\DB\Assembler\FilterAssembler::class,
+ FilterAssembler::class,
[
'conditionResolver' => $this->conditionResolverMock,
'nameResolver' => $this->nameResolverMock
@@ -117,7 +115,7 @@ public function testAssembleNotEmpty()
]
];
- $this->nameResolverMock->expects($this->any())
+ $this->nameResolverMock
->method('getAlias')
->with($queryConfigMock['source'])
->willReturn($queryConfigMock['source']['alias']);
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FromAssemblerTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FromAssemblerTest.php
index 575db94a7b7e1..86d4491abaa1b 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FromAssemblerTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FromAssemblerTest.php
@@ -3,80 +3,75 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\ReportXml\DB\Assembler;
+use Magento\Analytics\ReportXml\DB\Assembler\FromAssembler;
+use Magento\Analytics\ReportXml\DB\ColumnsResolver;
+use Magento\Analytics\ReportXml\DB\NameResolver;
+use Magento\Analytics\ReportXml\DB\SelectBuilder;
use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* A unit test for testing of the 'from' assembler.
*/
-class FromAssemblerTest extends \PHPUnit\Framework\TestCase
+class FromAssemblerTest extends TestCase
{
/**
- * @var \Magento\Analytics\ReportXml\DB\Assembler\FromAssembler
+ * @var FromAssembler
*/
private $subject;
/**
- * @var \Magento\Analytics\ReportXml\DB\NameResolver|\PHPUnit_Framework_MockObject_MockObject
+ * @var NameResolver|MockObject
*/
private $nameResolverMock;
/**
- * @var \Magento\Analytics\ReportXml\DB\SelectBuilder|\PHPUnit_Framework_MockObject_MockObject
+ * @var SelectBuilder|MockObject
*/
private $selectBuilderMock;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
private $objectManagerHelper;
/**
- * @var \Magento\Analytics\ReportXml\DB\ColumnsResolver|\PHPUnit_Framework_MockObject_MockObject
+ * @var ColumnsResolver|MockObject
*/
private $columnsResolverMock;
/**
- * @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResourceConnection|MockObject
*/
private $resourceConnection;
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->nameResolverMock = $this->getMockBuilder(
- \Magento\Analytics\ReportXml\DB\NameResolver::class
- )
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->selectBuilderMock = $this->getMockBuilder(
- \Magento\Analytics\ReportXml\DB\SelectBuilder::class
- )
- ->disableOriginalConstructor()
- ->getMock();
- $this->selectBuilderMock->expects($this->any())
+ $this->nameResolverMock = $this->createMock(NameResolver::class);
+
+ $this->selectBuilderMock = $this->createMock(SelectBuilder::class);
+ $this->selectBuilderMock
->method('getColumns')
->willReturn([]);
- $this->columnsResolverMock = $this->getMockBuilder(
- \Magento\Analytics\ReportXml\DB\ColumnsResolver::class
- )
- ->disableOriginalConstructor()
- ->getMock();
+ $this->columnsResolverMock = $this->createMock(ColumnsResolver::class);
- $this->resourceConnection = $this->getMockBuilder(ResourceConnection::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->resourceConnection = $this->createMock(ResourceConnection::class);
$this->objectManagerHelper =
- new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ new ObjectManager($this);
$this->subject = $this->objectManagerHelper->getObject(
- \Magento\Analytics\ReportXml\DB\Assembler\FromAssembler::class,
+ FromAssembler::class,
[
'nameResolver' => $this->nameResolverMock,
'columnsResolver' => $this->columnsResolverMock,
@@ -93,7 +88,7 @@ protected function setUp()
*/
public function testAssemble(array $queryConfig, $tableName)
{
- $this->nameResolverMock->expects($this->any())
+ $this->nameResolverMock
->method('getAlias')
->with($queryConfig['source'])
->willReturn($queryConfig['source']['alias']);
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/JoinAssemblerTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/JoinAssemblerTest.php
index aaafd731552a0..4f8b0b10163bc 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/JoinAssemblerTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/JoinAssemblerTest.php
@@ -3,97 +3,89 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\ReportXml\DB\Assembler;
+use Magento\Analytics\ReportXml\DB\Assembler\JoinAssembler;
+use Magento\Analytics\ReportXml\DB\ColumnsResolver;
+use Magento\Analytics\ReportXml\DB\ConditionResolver;
+use Magento\Analytics\ReportXml\DB\NameResolver;
+use Magento\Analytics\ReportXml\DB\SelectBuilder;
use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* A unit test for testing of the 'join' assembler.
*/
-class JoinAssemblerTest extends \PHPUnit\Framework\TestCase
+class JoinAssemblerTest extends TestCase
{
/**
- * @var \Magento\Analytics\ReportXml\DB\Assembler\JoinAssembler
+ * @var JoinAssembler
*/
private $subject;
/**
- * @var \Magento\Analytics\ReportXml\DB\NameResolver|\PHPUnit_Framework_MockObject_MockObject
+ * @var NameResolver|MockObject
*/
private $nameResolverMock;
/**
- * @var \Magento\Analytics\ReportXml\DB\SelectBuilder|\PHPUnit_Framework_MockObject_MockObject
+ * @var SelectBuilder|MockObject
*/
private $selectBuilderMock;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
private $objectManagerHelper;
/**
- * @var \Magento\Analytics\ReportXml\DB\ColumnsResolver|\PHPUnit_Framework_MockObject_MockObject
+ * @var ColumnsResolver|MockObject
*/
private $columnsResolverMock;
/**
- * @var \Magento\Analytics\ReportXml\DB\ConditionResolver|\PHPUnit_Framework_MockObject_MockObject
+ * @var ConditionResolver|MockObject
*/
private $conditionResolverMock;
/**
- * @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResourceConnection|MockObject
*/
private $resourceConnection;
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->nameResolverMock = $this->getMockBuilder(
- \Magento\Analytics\ReportXml\DB\NameResolver::class
- )
- ->disableOriginalConstructor()
- ->getMock();
+ $this->nameResolverMock = $this->createMock(NameResolver::class);
- $this->selectBuilderMock = $this->getMockBuilder(
- \Magento\Analytics\ReportXml\DB\SelectBuilder::class
- )
- ->disableOriginalConstructor()
- ->getMock();
- $this->selectBuilderMock->expects($this->any())
+ $this->selectBuilderMock = $this->createMock(SelectBuilder::class);
+ $this->selectBuilderMock
->method('getFilters')
->willReturn([]);
- $this->selectBuilderMock->expects($this->any())
+ $this->selectBuilderMock
->method('getColumns')
->willReturn([]);
- $this->selectBuilderMock->expects($this->any())
+ $this->selectBuilderMock
->method('getJoins')
->willReturn([]);
- $this->columnsResolverMock = $this->getMockBuilder(
- \Magento\Analytics\ReportXml\DB\ColumnsResolver::class
- )
- ->disableOriginalConstructor()
- ->getMock();
+ $this->columnsResolverMock = $this->createMock(ColumnsResolver::class);
- $this->conditionResolverMock = $this->getMockBuilder(
- \Magento\Analytics\ReportXml\DB\ConditionResolver::class
- )
- ->disableOriginalConstructor()
- ->getMock();
+ $this->conditionResolverMock = $this->createMock(ConditionResolver::class);
- $this->resourceConnection = $this->getMockBuilder(ResourceConnection::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->resourceConnection = $this->createMock(ResourceConnection::class);
$this->objectManagerHelper =
- new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ new ObjectManager($this);
$this->subject = $this->objectManagerHelper->getObject(
- \Magento\Analytics\ReportXml\DB\Assembler\JoinAssembler::class,
+ JoinAssembler::class,
[
'conditionResolver' => $this->conditionResolverMock,
'nameResolver' => $this->nameResolverMock,
@@ -153,7 +145,6 @@ public function testAssembleNotEmpty(array $queryConfigMock, array $joinsMock, a
->willReturn($queryConfigMock['source']['link-source'][0]['name']);
$this->resourceConnection
- ->expects($this->any())
->method('getTableName')
->willReturnOnConsecutiveCalls(...array_values($tablesMapping));
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ColumnsResolverTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ColumnsResolverTest.php
index 6f881fc4ae96a..0eb23a11d48f0 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ColumnsResolverTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ColumnsResolverTest.php
@@ -3,20 +3,24 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\ReportXml\DB;
use Magento\Analytics\ReportXml\DB\ColumnsResolver;
use Magento\Analytics\ReportXml\DB\NameResolver;
use Magento\Analytics\ReportXml\DB\SelectBuilder;
-use Magento\Framework\DB\Sql\ColumnValueExpression;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Sql\ColumnValueExpression;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ColumnsResolverTest extends \PHPUnit\Framework\TestCase
+class ColumnsResolverTest extends TestCase
{
/**
- * @var SelectBuilder|\PHPUnit_Framework_MockObject_MockObject
+ * @var SelectBuilder|MockObject
*/
private $selectBuilderMock;
@@ -26,31 +30,25 @@ class ColumnsResolverTest extends \PHPUnit\Framework\TestCase
private $columnsResolver;
/**
- * @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResourceConnection|MockObject
*/
private $resourceConnectionMock;
/**
- * @var AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AdapterInterface|MockObject
*/
private $connectionMock;
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->selectBuilderMock = $this->getMockBuilder(SelectBuilder::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->selectBuilderMock = $this->createMock(SelectBuilder::class);
- $this->resourceConnectionMock = $this->getMockBuilder(ResourceConnection::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->resourceConnectionMock = $this->createMock(ResourceConnection::class);
- $this->connectionMock = $this->getMockBuilder(AdapterInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->connectionMock = $this->getMockForAbstractClass(AdapterInterface::class);
$objectManager = new ObjectManagerHelper($this);
$this->columnsResolver = $objectManager->getObject(
@@ -72,10 +70,10 @@ public function testGetColumnsWithoutAttributes()
*/
public function testGetColumnsWithFunction($expectedColumns, $expectedGroup, $entityConfig)
{
- $this->resourceConnectionMock->expects($this->any())
+ $this->resourceConnectionMock
->method('getConnection')
->willReturn($this->connectionMock);
- $this->connectionMock->expects($this->any())
+ $this->connectionMock
->method('quoteIdentifier')
->with('cpe.name')
->willReturn('`cpe`.`name`');
@@ -104,43 +102,41 @@ public function getColumnsDataProvider()
{
return [
'COUNT( DISTINCT `cpe`.`name`) AS name' => [
- 'expectedColumns' => [
- 'name' => new ColumnValueExpression('COUNT( DISTINCT `cpe`.`name`)')
- ],
- 'expectedGroup' => [
- 'name' => new ColumnValueExpression('COUNT( DISTINCT `cpe`.`name`)')
- ],
- 'entityConfig' =>
+ 'expectedColumns' => [
+ 'name' => new ColumnValueExpression('COUNT( DISTINCT `cpe`.`name`)')
+ ],
+ 'expectedGroup' => [
+ 'name' => new ColumnValueExpression('COUNT( DISTINCT `cpe`.`name`)')
+ ],
+ 'entityConfig' => [
+ 'name' => 'catalog_product_entity',
+ 'alias' => 'cpe',
+ 'attribute' => [
[
- 'name' => 'catalog_product_entity',
- 'alias' => 'cpe',
- 'attribute' => [
- [
- 'name' => 'name',
- 'function' => 'COUNT',
- 'distinct' => true,
- 'group' => true
- ]
- ],
- ],
+ 'name' => 'name',
+ 'function' => 'COUNT',
+ 'distinct' => true,
+ 'group' => true
+ ]
],
+ ],
+ ],
'AVG(`cpe`.`name`) AS avg_name' => [
'expectedColumns' => [
'avg_name' => new ColumnValueExpression('AVG(`cpe`.`name`)')
],
'expectedGroup' => [],
- 'entityConfig' =>
- [
- 'name' => 'catalog_product_entity',
- 'alias' => 'cpe',
- 'attribute' => [
- [
- 'name' => 'name',
- 'alias' => 'avg_name',
- 'function' => 'AVG',
- ]
- ],
+ 'entityConfig' => [
+ 'name' => 'catalog_product_entity',
+ 'alias' => 'cpe',
+ 'attribute' => [
+ [
+ 'name' => 'name',
+ 'alias' => 'avg_name',
+ 'function' => 'AVG',
+ ]
],
+ ],
]
];
}
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ConditionResolverTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ConditionResolverTest.php
index 8fa9d3b538e71..497e8c9f1b336 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ConditionResolverTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ConditionResolverTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\ReportXml\DB;
use Magento\Analytics\ReportXml\DB\ConditionResolver;
@@ -10,11 +12,13 @@
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\DB\Sql\Expression;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ConditionResolverTest extends \PHPUnit\Framework\TestCase
+class ConditionResolverTest extends TestCase
{
/**
- * @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResourceConnection|MockObject
*/
private $resourceConnectionMock;
@@ -24,31 +28,25 @@ class ConditionResolverTest extends \PHPUnit\Framework\TestCase
private $conditionResolver;
/**
- * @var SelectBuilder|\PHPUnit_Framework_MockObject_MockObject
+ * @var SelectBuilder|MockObject
*/
private $selectBuilderMock;
/**
- * @var AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AdapterInterface|MockObject
*/
private $connectionMock;
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->resourceConnectionMock = $this->getMockBuilder(ResourceConnection::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->resourceConnectionMock = $this->createMock(ResourceConnection::class);
- $this->selectBuilderMock = $this->getMockBuilder(SelectBuilder::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->selectBuilderMock = $this->createMock(SelectBuilder::class);
- $this->connectionMock = $this->getMockBuilder(AdapterInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->connectionMock = $this->getMockForAbstractClass(AdapterInterface::class);
$this->conditionResolver = new ConditionResolver($this->resourceConnectionMock);
}
@@ -68,7 +66,7 @@ public function testGetFilter()
["glue" => "OR", "condition" => [$identifierCondition]],
];
$aliasName = 'n';
- $this->selectBuilderMock->expects($this->any())
+ $this->selectBuilderMock
->method('setParams')
->with(array_merge([], [$condition['_value']]));
@@ -76,7 +74,7 @@ public function testGetFilter()
->method('getParams')
->willReturn([]);
- $this->selectBuilderMock->expects($this->any())
+ $this->selectBuilderMock
->method('getColumns')
->willReturn(['price' => new Expression("(n.price = 400)")]);
@@ -84,7 +82,7 @@ public function testGetFilter()
->method('getConnection')
->willReturn($this->connectionMock);
- $this->connectionMock->expects($this->any())
+ $this->connectionMock
->method('quote')
->willReturn("'John'");
$this->connectionMock->expects($this->exactly(4))
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/NameResolverTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/NameResolverTest.php
index 8109e6f9e8631..051fead389485 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/NameResolverTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/NameResolverTest.php
@@ -3,15 +3,19 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\ReportXml\DB;
use Magento\Analytics\ReportXml\DB\NameResolver;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class NameResolverTest extends \PHPUnit\Framework\TestCase
+class NameResolverTest extends TestCase
{
/**
- * @var NameResolver|\PHPUnit_Framework_MockObject_MockObject
+ * @var NameResolver|MockObject
*/
private $nameResolverMock;
@@ -28,7 +32,7 @@ class NameResolverTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->nameResolverMock = $this->getMockBuilder(NameResolver::class)
->disableOriginalConstructor()
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ReportValidatorTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ReportValidatorTest.php
index ac141fae4be66..893dedfc46774 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ReportValidatorTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ReportValidatorTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\ReportXml\DB;
use Magento\Analytics\ReportXml\ConnectionFactory;
@@ -12,31 +14,34 @@
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\DB\Select;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\MockObject\Stub\Stub;
+use PHPUnit\Framework\TestCase;
-class ReportValidatorTest extends \PHPUnit\Framework\TestCase
+class ReportValidatorTest extends TestCase
{
/**
- * @var ConnectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ConnectionFactory|MockObject
*/
private $connectionFactoryMock;
/**
- * @var QueryFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var QueryFactory|MockObject
*/
private $queryFactoryMock;
/**
- * @var Query|\PHPUnit_Framework_MockObject_MockObject
+ * @var Query|MockObject
*/
private $queryMock;
/**
- * @var AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AdapterInterface|MockObject
*/
private $connectionMock;
/**
- * @var Select|\PHPUnit_Framework_MockObject_MockObject
+ * @var Select|MockObject
*/
private $selectMock;
@@ -53,17 +58,14 @@ class ReportValidatorTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->connectionFactoryMock = $this->getMockBuilder(ConnectionFactory::class)
- ->disableOriginalConstructor()->getMock();
- $this->queryFactoryMock = $this->getMockBuilder(QueryFactory::class)
- ->disableOriginalConstructor()->getMock();
- $this->queryMock = $this->getMockBuilder(Query::class)->disableOriginalConstructor()
- ->getMock();
- $this->connectionMock = $this->getMockBuilder(AdapterInterface::class)->getMockForAbstractClass();
- $this->selectMock = $this->getMockBuilder(Select::class)->disableOriginalConstructor()
- ->getMock();
+ $this->connectionFactoryMock = $this->createMock(ConnectionFactory::class);
+ $this->queryFactoryMock = $this->createMock(QueryFactory::class);
+ $this->queryMock = $this->createMock(Query::class);
+ $this->connectionMock = $this->getMockBuilder(AdapterInterface::class)
+ ->getMockForAbstractClass();
+ $this->selectMock = $this->createMock(Select::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->reportValidator = $this->objectManagerHelper->getObject(
@@ -79,9 +81,9 @@ protected function setUp()
* @dataProvider errorDataProvider
* @param string $reportName
* @param array $result
- * @param \PHPUnit\Framework\MockObject\Stub $queryReturnStub
+ * @param Stub $queryReturnStub
*/
- public function testValidate($reportName, $result, \PHPUnit\Framework\MockObject\Stub $queryReturnStub)
+ public function testValidate($reportName, $result, Stub $queryReturnStub)
{
$connectionName = 'testConnection';
$this->queryFactoryMock->expects($this->once())
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/SelectBuilderTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/SelectBuilderTest.php
index a4362d583dfbc..811b6aee93fdf 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/SelectBuilderTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/SelectBuilderTest.php
@@ -3,14 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Analytics\Test\Unit\ReportXml\DB;
use Magento\Analytics\ReportXml\DB\SelectBuilder;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\DB\Select;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class SelectBuilderTest extends \PHPUnit\Framework\TestCase
+class SelectBuilderTest extends TestCase
{
/**
* @var SelectBuilder
@@ -18,36 +22,30 @@ class SelectBuilderTest extends \PHPUnit\Framework\TestCase
private $selectBuilder;
/**
- * @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResourceConnection|MockObject
*/
private $resourceConnectionMock;
/**
- * @var AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AdapterInterface|MockObject
*/
private $connectionMock;
/**
- * @var Select|\PHPUnit_Framework_MockObject_MockObject
+ * @var Select|MockObject
*/
private $selectMock;
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->resourceConnectionMock = $this->getMockBuilder(ResourceConnection::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->resourceConnectionMock = $this->createMock(ResourceConnection::class);
- $this->connectionMock = $this->getMockBuilder(AdapterInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->connectionMock = $this->getMockForAbstractClass(AdapterInterface::class);
- $this->selectMock = $this->getMockBuilder(Select::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->selectMock = $this->createMock(Select::class);
$this->selectBuilder = new SelectBuilder($this->resourceConnectionMock);
}
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/IteratorFactoryTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/IteratorFactoryTest.php
index bc20a62dcb366..25b4f3f95030b 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/IteratorFactoryTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/IteratorFactoryTest.php
@@ -3,20 +3,24 @@
* 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\IteratorFactory;
use Magento\Framework\ObjectManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class IteratorFactoryTest extends \PHPUnit\Framework\TestCase
+class IteratorFactoryTest extends TestCase
{
/**
- * @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ObjectManagerInterface|MockObject
*/
private $objectManagerMock;
/**
- * @var \IteratorIterator|\PHPUnit_Framework_MockObject_MockObject
+ * @var \IteratorIterator|MockObject
*/
private $iteratorIteratorMock;
@@ -28,15 +32,11 @@ class IteratorFactoryTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->objectManagerMock = $this->getMockForAbstractClass(ObjectManagerInterface::class);
- $this->iteratorIteratorMock = $this->getMockBuilder(\IteratorIterator::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->iteratorIteratorMock = $this->createMock(\IteratorIterator::class);
$this->iteratorFactory = new IteratorFactory(
$this->objectManagerMock
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryFactoryTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryFactoryTest.php
index 032ef1e107825..7ed0e1dc123c2 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryFactoryTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryFactoryTest.php
@@ -8,16 +8,16 @@
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\Analytics\ReportXml\Query;
+use Magento\Analytics\ReportXml\QueryFactory;
+use Magento\Analytics\ReportXml\SelectHydrator;
+use Magento\Framework\App\CacheInterface;
+use Magento\Framework\DB\Select;
+use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use PHPUnit\Framework\MockObject\MockObject;
@@ -93,37 +93,21 @@ class QueryFactoryTest extends TestCase
*/
protected function setUp(): void
{
- $this->queryMock = $this->getMockBuilder(Query::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->queryMock = $this->createMock(Query::class);
- $this->configMock = $this->getMockBuilder(Config::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->configMock = $this->createMock(Config::class);
- $this->selectMock = $this->getMockBuilder(Select::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->selectMock = $this->createMock(Select::class);
- $this->assemblerMock = $this->getMockBuilder(AssemblerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->assemblerMock = $this->getMockForAbstractClass(AssemblerInterface::class);
- $this->queryCacheMock = $this->getMockBuilder(CacheInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->queryCacheMock = $this->getMockForAbstractClass(CacheInterface::class);
- $this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->objectManagerMock = $this->getMockForAbstractClass(ObjectManagerInterface::class);
- $this->selectHydratorMock = $this->getMockBuilder(SelectHydrator::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->selectHydratorMock = $this->createMock(SelectHydrator::class);
- $this->selectBuilderFactoryMock = $this->getMockBuilder(SelectBuilderFactory::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->selectBuilderFactoryMock = $this->createMock(SelectBuilderFactory::class);
$this->jsonSerializerMock = $this->createMock(Json::class);
@@ -153,7 +137,7 @@ public function testCreateIfQueryCached(array $queryDataMock, string $jsonEncode
$queryConfigMock = $queryDataMock['config'];
$queryName = $queryConfigMock['name'];
- $this->queryCacheMock->expects($this->any())
+ $this->queryCacheMock
->method('load')
->with($queryName)
->willReturn($jsonEncodeData);
@@ -162,7 +146,7 @@ public function testCreateIfQueryCached(array $queryDataMock, string $jsonEncode
->method('unserialize')
->willReturn($queryDataMock);
- $this->selectHydratorMock->expects($this->any())
+ $this->selectHydratorMock
->method('recreate')
->with([])
->willReturn($this->selectMock);
@@ -189,30 +173,28 @@ public function testCreateIfQueryNotCached(array $queryDataMock, string $jsonEnc
$queryConfigMock = $queryDataMock['config'];
$queryName = $queryConfigMock['name'];
- $selectBuilderMock = $this->getMockBuilder(SelectBuilder::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $selectBuilderMock = $this->createMock(SelectBuilder::class);
$selectBuilderMock->expects($this->once())
->method('setConnectionName')
->with($queryConfigMock['connection']);
- $selectBuilderMock->expects($this->any())
+ $selectBuilderMock
->method('create')
->willReturn($this->selectMock);
- $selectBuilderMock->expects($this->any())
+ $selectBuilderMock
->method('getConnectionName')
->willReturn($queryConfigMock['connection']);
- $this->queryCacheMock->expects($this->any())
+ $this->queryCacheMock
->method('load')
->with($queryName)
->willReturn(null);
- $this->configMock->expects($this->any())
+ $this->configMock
->method('get')
->with($queryName)
->willReturn($queryConfigMock);
- $this->selectBuilderFactoryMock->expects($this->any())
+ $this->selectBuilderFactoryMock
->method('create')
->willReturn($selectBuilderMock);
@@ -254,8 +236,8 @@ public function queryDataProvider(): array
],
'select_parts' => []
],
- 'getQueryDataJsonEncodeMock' => '{"connectionName":"default",'.
- '"config":{"name":"test_query",'.
+ 'getQueryDataJsonEncodeMock' => '{"connectionName":"default",' .
+ '"config":{"name":"test_query",' .
'"connection":"default"},"select_parts":[]}'
]
];
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryTest.php
index 947e07b569e04..d1a2afc4697c2 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryTest.php
@@ -3,22 +3,26 @@
* 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\Query;
use Magento\Analytics\ReportXml\SelectHydrator as selectHydrator;
use Magento\Framework\DB\Select;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class QueryTest extends \PHPUnit\Framework\TestCase
+class QueryTest extends TestCase
{
/**
- * @var Select|\PHPUnit_Framework_MockObject_MockObject
+ * @var Select|MockObject
*/
private $selectMock;
/**
- * @var selectHydrator|\PHPUnit_Framework_MockObject_MockObject
+ * @var selectHydrator|MockObject
*/
private $selectHydratorMock;
@@ -40,15 +44,11 @@ class QueryTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->selectMock = $this->getMockBuilder(Select::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->selectMock = $this->createMock(Select::class);
- $this->selectHydratorMock = $this->getMockBuilder(selectHydrator::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->selectHydratorMock = $this->createMock(selectHydrator::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/ReportProviderTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/ReportProviderTest.php
index 5f329993dd291..98b291c580bec 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/ReportProviderTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/ReportProviderTest.php
@@ -3,131 +3,109 @@
* 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\ConnectionFactory;
+use Magento\Analytics\ReportXml\IteratorFactory;
+use Magento\Analytics\ReportXml\Query;
+use Magento\Analytics\ReportXml\QueryFactory;
+use Magento\Analytics\ReportXml\ReportProvider;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Select;
+use Magento\Framework\DB\Statement\Pdo\Mysql;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* A unit test for testing of the reports provider.
*/
-class ReportProviderTest extends \PHPUnit\Framework\TestCase
+class ReportProviderTest extends TestCase
{
/**
- * @var \Magento\Analytics\ReportXml\ReportProvider
+ * @var ReportProvider
*/
private $subject;
/**
- * @var \Magento\Analytics\ReportXml\Query|\PHPUnit_Framework_MockObject_MockObject
+ * @var Query|MockObject
*/
private $queryMock;
/**
- * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject
+ * @var Select|MockObject
*/
private $selectMock;
/**
- * @var \IteratorIterator|\PHPUnit_Framework_MockObject_MockObject
+ * @var \IteratorIterator|MockObject
*/
private $iteratorMock;
/**
- * @var \Magento\Framework\DB\Statement\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject
+ * @var Mysql|MockObject
*/
private $statementMock;
/**
- * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AdapterInterface|MockObject
*/
private $connectionMock;
/**
- * @var \Magento\Analytics\ReportXml\QueryFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var QueryFactory|MockObject
*/
private $queryFactoryMock;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
private $objectManagerHelper;
/**
- * @var \Magento\Analytics\ReportXml\ConnectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ConnectionFactory|MockObject
*/
private $connectionFactoryMock;
/**
- * @var \Magento\Analytics\ReportXml\IteratorFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var IteratorFactory|MockObject
*/
private $iteratorFactoryMock;
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->selectMock = $this->getMockBuilder(
- \Magento\Framework\DB\Select::class
- )
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->queryMock = $this->getMockBuilder(
- \Magento\Analytics\ReportXml\Query::class
- )
- ->disableOriginalConstructor()
- ->getMock();
- $this->queryMock->expects($this->any())
+ $this->selectMock = $this->createMock(Select::class);
+
+ $this->queryMock = $this->createMock(Query::class);
+ $this->queryMock
->method('getSelect')
->willReturn($this->selectMock);
- $this->iteratorMock = $this->getMockBuilder(
- \IteratorIterator::class
- )
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->statementMock = $this->getMockBuilder(
- \Magento\Framework\DB\Statement\Pdo\Mysql::class
- )
- ->disableOriginalConstructor()
- ->getMock();
- $this->statementMock->expects($this->any())
+ $this->iteratorMock = $this->createMock(\IteratorIterator::class);
+
+ $this->statementMock = $this->createMock(Mysql::class);
+ $this->statementMock
->method('getIterator')
->willReturn($this->iteratorMock);
- $this->connectionMock = $this->getMockBuilder(
- \Magento\Framework\DB\Adapter\AdapterInterface::class
- )
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->queryFactoryMock = $this->getMockBuilder(
- \Magento\Analytics\ReportXml\QueryFactory::class
- )
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->iteratorFactoryMock = $this->getMockBuilder(
- \Magento\Analytics\ReportXml\IteratorFactory::class
- )
- ->disableOriginalConstructor()
- ->getMock();
- $this->iteratorMock = $this->getMockBuilder(
- \IteratorIterator::class
- )
- ->disableOriginalConstructor()
- ->getMock();
+ $this->connectionMock = $this->getMockForAbstractClass(AdapterInterface::class);
+
+ $this->queryFactoryMock = $this->createMock(QueryFactory::class);
+
+ $this->iteratorFactoryMock = $this->createMock(IteratorFactory::class);
+ $this->iteratorMock = $this->createMock(\IteratorIterator::class);
$this->objectManagerHelper =
- new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ new ObjectManager($this);
- $this->connectionFactoryMock = $this->getMockBuilder(
- \Magento\Analytics\ReportXml\ConnectionFactory::class
- )
- ->disableOriginalConstructor()
- ->getMock();
+ $this->connectionFactoryMock = $this->createMock(ConnectionFactory::class);
$this->subject = $this->objectManagerHelper->getObject(
- \Magento\Analytics\ReportXml\ReportProvider::class,
+ ReportProvider::class,
[
'queryFactory' => $this->queryFactoryMock,
'connectionFactory' => $this->connectionFactoryMock,
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/SelectHydratorTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/SelectHydratorTest.php
index 058c74f341eb8..36915af3d6985 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/SelectHydratorTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/SelectHydratorTest.php
@@ -3,17 +3,20 @@
* 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\SelectHydrator;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\DB\Select;
-use Magento\Framework\DB\Sql\JsonSerializableExpression;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class SelectHydratorTest extends \PHPUnit\Framework\TestCase
+class SelectHydratorTest extends TestCase
{
/**
* @var SelectHydrator
@@ -21,22 +24,22 @@ class SelectHydratorTest extends \PHPUnit\Framework\TestCase
private $selectHydrator;
/**
- * @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResourceConnection|MockObject
*/
private $resourceConnectionMock;
/**
- * @var AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AdapterInterface|MockObject
*/
private $connectionMock;
/**
- * @var Select|\PHPUnit_Framework_MockObject_MockObject
+ * @var Select|MockObject
*/
private $selectMock;
/**
- * @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ObjectManagerInterface|MockObject
*/
private $objectManagerMock;
@@ -48,23 +51,15 @@ class SelectHydratorTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->resourceConnectionMock = $this->getMockBuilder(ResourceConnection::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->resourceConnectionMock = $this->createMock(ResourceConnection::class);
- $this->connectionMock = $this->getMockBuilder(AdapterInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->connectionMock = $this->getMockForAbstractClass(AdapterInterface::class);
- $this->selectMock = $this->getMockBuilder(Select::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->selectMock = $this->createMock(Select::class);
- $this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->objectManagerMock = $this->getMockForAbstractClass(ObjectManagerInterface::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
@@ -98,7 +93,7 @@ public function testExtract()
foreach ($selectParts as $part) {
$result[$part] = "Part";
}
- $this->selectMock->expects($this->any())
+ $this->selectMock
->method('getPart')
->willReturn("Part");
$this->assertEquals($this->selectHydrator->extract($this->selectMock), $result);
@@ -169,7 +164,7 @@ public function recreateWithoutExpressionDataProvider()
* @dataProvider recreateWithExpressionDataProvider
* @param array $selectParts
* @param array $expectedParts
- * @param \PHPUnit_Framework_MockObject_MockObject[] $expressionMocks
+ * @param MockObject[] $expressionMocks
*/
public function testRecreateWithExpression(
array $selectParts,
@@ -206,9 +201,7 @@ public function testRecreateWithExpression(
*/
public function recreateWithExpressionDataProvider()
{
- $expressionMock = $this->getMockBuilder(JsonSerializableExpression::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $expressionMock = $this->createMock(\JsonSerializable::class);
return [
'Select without expressions' => [
diff --git a/app/code/Magento/Analytics/composer.json b/app/code/Magento/Analytics/composer.json
index 2ae27608dbb14..84f8af066bf11 100644
--- a/app/code/Magento/Analytics/composer.json
+++ b/app/code/Magento/Analytics/composer.json
@@ -2,7 +2,7 @@
"name": "magento/module-analytics",
"description": "N/A",
"require": {
- "php": "~7.1.3||~7.2.0||~7.3.0",
+ "php": "~7.3.0||~7.4.0",
"magento/module-backend": "*",
"magento/module-config": "*",
"magento/module-integration": "*",
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
+