Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/phpunit8' into phpunit8/module-C…
Browse files Browse the repository at this point in the history
…onfigurableProduct
  • Loading branch information
lbajsarowicz committed Apr 16, 2020
2 parents 2e9a643 + 1dcb9b8 commit a7561ed
Show file tree
Hide file tree
Showing 2,038 changed files with 41,032 additions and 30,644 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
Expand All @@ -8,9 +8,9 @@
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 @@ -35,14 +35,9 @@ 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->createMock(ProductMetadataInterface::class);
$objectManager = new ObjectManager($this);
$this->canViewNotification = $objectManager->getObject(
CanViewNotification::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ 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->createMock(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 @@ -32,11 +32,11 @@ 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 @@ -34,10 +33,10 @@ 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
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
Expand Down Expand Up @@ -30,7 +30,7 @@ protected function _getBlockInstance($unreadNotifications)
Unread::class,
['getSize', 'setCurPage', 'setPageSize']
);
$notificationList->expects($this->any())->method('getSize')->will($this->returnValue($unreadNotifications));
$notificationList->method('getSize')->will($this->returnValue($unreadNotifications));

$block = $objectManagerHelper->getObject(
ToolbarEntry::class,
Expand All @@ -52,9 +52,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 Down
11 changes: 4 additions & 7 deletions app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
Expand Down Expand Up @@ -70,8 +70,7 @@ 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',
Expand All @@ -96,13 +95,11 @@ 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);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
Expand Down Expand Up @@ -60,9 +60,7 @@ protected function setUp(): void
*/
public function testGetIdentity($expectedSum, $cacheTypes)
{
$this->_cacheTypeListMock->expects(
$this->any()
)->method(
$this->_cacheTypeListMock->method(
'getInvalidated'
)->will(
$this->returnValue($cacheTypes)
Expand All @@ -76,10 +74,10 @@ 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->method('getCacheType')->will($this->returnValue('Simple'));

$cacheTypeMock2 = $this->createPartialMock(\stdClass::class, ['getCacheType']);
$cacheTypeMock2->expects($this->any())->method('getCacheType')->will($this->returnValue('Advanced'));
$cacheTypeMock2->method('getCacheType')->will($this->returnValue('Advanced'));

return [
['c13cfaddc2c53e8d32f59bfe89719beb', [$cacheTypeMock1]],
Expand All @@ -96,9 +94,7 @@ 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->_cacheTypeListMock->method(
'getInvalidated'
)->will(
$this->returnValue($cacheTypes)
Expand All @@ -112,7 +108,7 @@ 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->method('getCacheType')->will($this->returnValue('someVal'));
$cacheTypes = [$cacheTypesMock, $cacheTypesMock];
return [
[false, false, []],
Expand All @@ -126,7 +122,7 @@ public function testGetText()
{
$messageText = 'One or more of the Cache Types are invalidated';

$this->_cacheTypeListMock->expects($this->any())->method('getInvalidated')->will($this->returnValue([]));
$this->_cacheTypeListMock->method('getInvalidated')->will($this->returnValue([]));
$this->_urlInterfaceMock->expects($this->once())->method('getUrl')->will($this->returnValue('someURL'));
$this->assertContains($messageText, $this->_messageModel->getText());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
Expand Down Expand Up @@ -37,7 +37,7 @@ protected function setUp(): void
);

$this->_fileStorage = $this->createMock(Flag::class);
$this->_fileStorage->expects($this->any())->method('loadSelf')->will($this->returnValue($this->_syncFlagMock));
$this->_fileStorage->method('loadSelf')->will($this->returnValue($this->_syncFlagMock));

$objectManagerHelper = new ObjectManager($this);
$arguments = ['fileStorage' => $this->_fileStorage];
Expand Down Expand Up @@ -69,8 +69,8 @@ public function testIsDisplayed($expectedFirstRun, $data)
$arguments
);

$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')->will($this->returnValue($data));
//check first call
$this->assertEquals($expectedFirstRun, $model->isDisplayed());
//check second call(another branch of if operator)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
Expand Down Expand Up @@ -68,14 +68,14 @@ protected function setUp(): void
*/
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')->will($this->returnValue($cached));
$this->cacheMock->method('save')->will($this->returnValue(null));

$httpAdapterMock = $this->createMock(Curl::class);
$httpAdapterMock->expects($this->any())->method('read')->will($this->returnValue($response));
$this->curlFactoryMock->expects($this->any())->method('create')->will($this->returnValue($httpAdapterMock));
$httpAdapterMock->method('read')->will($this->returnValue($response));
$this->curlFactoryMock->method('create')->will($this->returnValue($httpAdapterMock));

$this->scopeConfigMock->expects($this->any())->method('getValue')->will($this->returnValue(null));
$this->scopeConfigMock->method('getValue')->will($this->returnValue(null));

$this->assertEquals($expectedResult, $this->messageModel->isDisplayed());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
Expand Down
Loading

0 comments on commit a7561ed

Please sign in to comment.