Skip to content

Commit

Permalink
Merge branch '2.4-develop' into feature/cms-block
Browse files Browse the repository at this point in the history
  • Loading branch information
ihor-sviziev committed May 9, 2020
2 parents cdcad5c + 40a7876 commit c3f7bed
Show file tree
Hide file tree
Showing 7,444 changed files with 140,501 additions and 104,271 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
68 changes: 0 additions & 68 deletions .travis.yml.sample

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
* 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;

Expand All @@ -28,21 +30,16 @@ class CanViewNotificationTest extends TestCase
/** @var Log|MockObject */
private $logMock;

/** @var $cacheStorageMock MockObject|CacheInterface */
/** @var MockObject|CacheInterface $cacheStorageMock */
private $cacheStorageMock;

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,
Expand Down
15 changes: 7 additions & 8 deletions app/code/Magento/AdminAnalytics/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*",
Expand All @@ -18,12 +18,11 @@
"AFL-3.0"
],
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"Magento\\AdminAnalytics\\": ""
}
"files": [
"registration.php"
],
"psr-4": {
"Magento\\AdminAnalytics\\": ""
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,25 @@ class ActionsTest extends TestCase
*/
private $sut;

protected function setUp() : void
protected function setUp(): void
{
parent::setUp();

/** @var Escaper|MockObject $escaperMock */
$escaperMock = $this->getMockBuilder(Escaper::class)->disableOriginalConstructor()->getMock();
$escaperMock = $this->createMock(Escaper::class);
$escaperMock->expects($this->once())->method('escapeUrl')->willReturn('https://magento.com');

/** @var UrlInterface|MockObject $urlBuilder */
$urlBuilder = $this->getMockBuilder(UrlInterface::class)->getMock();
$urlBuilder = $this->getMockForAbstractClass(UrlInterface::class);
$urlBuilder->expects($this->once())->method('getUrl')->willReturn('http://magento.com');

/** @var Context|MockObject $contextMock */
$contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
$contextMock = $this->createMock(Context::class);
$contextMock->expects($this->once())->method('getEscaper')->willReturn($escaperMock);
$contextMock->expects($this->once())->method('getUrlBuilder')->willReturn($urlBuilder);

/** @var Data|MockObject $urlHelperMock */
$urlHelperMock = $this->getMockBuilder(Data::class)->disableOriginalConstructor()->getMock();
$urlHelperMock = $this->createMock(Data::class);
$urlHelperMock->expects($this->once())->method('getEncodedUrl')->willReturn('http://magento.com');

$this->sut = new Actions($contextMock, $urlHelperMock);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
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;

Expand All @@ -27,16 +27,16 @@ class NoticeTest extends TestCase
*/
private $sut;

protected function setUp() : void
protected function setUp(): void
{
parent::setUp();

/** @var Escaper|MockObject $escaperMock */
$escaperMock = $this->getMockBuilder(Escaper::class)->disableOriginalConstructor()->getMock();
$escaperMock = $this->createMock(Escaper::class);
$escaperMock->expects($this->exactly(2))->method('escapeHtml')->willReturn('<div>Some random html</div>');

/** @var Context|MockObject $contextMock */
$contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
$contextMock = $this->createMock(Context::class);
$contextMock->expects($this->once())->method('getEscaper')->willReturn($escaperMock);

$this->sut = new Notice($contextMock);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
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;

Expand All @@ -29,15 +28,15 @@ class SeverityTest extends TestCase
*/
private $sut;

protected function setUp() : void
protected function setUp(): void
{
parent::setUp();

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

/** @var Context|MockObject $contextMock */
$contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
$contextMock = $this->createMock(Context::class);

$this->sut = new Severity($contextMock, $inboxMock);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

/**
* Test class for \Magento\AdminNotification\Block\ToolbarEntry
Expand Down Expand Up @@ -30,7 +31,7 @@ protected function _getBlockInstance($unreadNotifications)
Unread::class,
['getSize', 'setCurPage', 'setPageSize']
);
$notificationList->expects($this->any())->method('getSize')->will($this->returnValue($unreadNotifications));
$notificationList->method('getSize')->willReturn($unreadNotifications);

$block = $objectManagerHelper->getObject(
ToolbarEntry::class,
Expand All @@ -52,9 +53,7 @@ public function testGetLatestUnreadNotifications()
$helper = new ObjectManager($this);

// 1. Create mocks
$notificationList = $this->getMockBuilder(Unread::class)
->disableOriginalConstructor()
->getMock();
$notificationList = $this->createMock(Unread::class);

/** @var ToolbarEntry $model */
$model = $helper->getObject(
Expand All @@ -65,8 +64,7 @@ public function testGetLatestUnreadNotifications()
// 2. Set expectations
$notificationList->expects($this->atLeastOnce())
->method('setPageSize')
->with(ToolbarEntry::NOTIFICATIONS_NUMBER)
->will($this->returnSelf());
->with(ToolbarEntry::NOTIFICATIONS_NUMBER)->willReturnSelf();

// 3. Run tested method
$result = $model->getLatestUnreadNotifications();
Expand Down
36 changes: 17 additions & 19 deletions app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\AdminNotification\Test\Unit\Model;

Expand Down Expand Up @@ -70,13 +71,12 @@ protected function setUp(): void
['create']
);
$this->curlFactory = $this->createPartialMock(CurlFactory::class, ['create']);
$this->curl = $this->getMockBuilder(Curl::class)
->disableOriginalConstructor()->getMock();
$this->curl = $this->createMock(Curl::class);
$this->appState = $this->createPartialMock(State::class, []);
$this->inboxModel = $this->createPartialMock(Inbox::class, [
'__wakeup',
'parse'
]);
'__wakeup',
'parse'
]);
$this->backendConfig = $this->createPartialMock(
ConfigInterface::class,
[
Expand All @@ -96,15 +96,13 @@ protected function setUp(): void
]
);

$this->deploymentConfig = $this->getMockBuilder(DeploymentConfig::class)
->disableOriginalConstructor()->getMock();
$this->deploymentConfig = $this->createMock(DeploymentConfig::class);

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

$this->productMetadata = $this->getMockBuilder(ProductMetadata::class)
->disableOriginalConstructor()->getMock();
$this->productMetadata = $this->createMock(ProductMetadata::class);

$this->urlBuilder = $this->createMock(UrlInterface::class);
$this->urlBuilder = $this->getMockForAbstractClass(UrlInterface::class);

$this->feed = $this->objectManagerHelper->getObject(
Feed::class,
Expand Down Expand Up @@ -145,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(
Expand All @@ -178,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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

/**
* Test class for \Magento\AdminNotification\Model\NotificationService
Expand All @@ -27,27 +28,27 @@ class NotificationServiceTest extends TestCase
protected function _getServiceInstanceForMarkAsReadTest($notificationId)
{
/**
* @var $notificationFactory MockObject|InboxFactory
* @var MockObject|InboxFactory $notificationFactory
*/
$notificationFactory = $this->createPartialMock(
InboxFactory::class,
['create']
);
$notification = $this->createPartialMock(
Inbox::class,
['load', 'getId', 'save', 'setData', '__sleep', '__wakeup']
);
$notification->expects($this->once())->method('load')->with($notificationId)->will($this->returnSelf());
$notification->expects($this->once())->method('getId')->will($this->returnValue($notificationId));
$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('setData')
->with('is_read', 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));
$notificationFactory->expects($this->once())->method('create')->willReturn($notification);
return new NotificationService($notificationFactory);
}

Expand Down
Loading

0 comments on commit c3f7bed

Please sign in to comment.