Skip to content

Commit

Permalink
Merge pull request #1329 from magento-okapis/MAGETWO-69137-upgrade_ph…
Browse files Browse the repository at this point in the history
…punit-2.2-squash

MAGETWO-69137: upgrading Magento2 Project PHPUnit version to latest
  • Loading branch information
cpartica authored Aug 5, 2017
2 parents ca9141d + 3cd92bc commit ef19ca6
Show file tree
Hide file tree
Showing 5,139 changed files with 24,858 additions and 42,460 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@ script:
- 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 != "js" ]; then phpunit -c dev/tests/$TEST_SUITE $TEST_FILTER; fi
- 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" ]; then phpunit -c dev/tests/$TEST_SUITE $TEST_FILTER; fi
- if [ $TEST_SUITE == "js" ]; then grunt $GRUNT_COMMAND; fi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
namespace Magento\AdminNotification\Test\Unit\Block;

class ToolbarEntryTest extends \PHPUnit_Framework_TestCase
class ToolbarEntryTest extends \PHPUnit\Framework\TestCase
{
/**
* Retrieve toolbar entry block instance
Expand All @@ -21,12 +21,9 @@ protected function _getBlockInstance($unreadNotifications)
{
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
// mock collection of unread notifications
$notificationList = $this->getMock(
$notificationList = $this->createPartialMock(
\Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Unread::class,
['getSize', 'setCurPage', 'setPageSize'],
[],
'',
false
['getSize', 'setCurPage', 'setPageSize']
);
$notificationList->expects($this->any())->method('getSize')->will($this->returnValue($unreadNotifications));

Expand Down
37 changes: 11 additions & 26 deletions app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

namespace Magento\AdminNotification\Test\Unit\Model;

use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use Magento\Framework\Config\ConfigOptionsListConstants;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class FeedTest extends \PHPUnit_Framework_TestCase
class FeedTest extends \PHPUnit\Framework\TestCase
{
/** @var \Magento\AdminNotification\Model\Feed */
protected $feed;
Expand Down Expand Up @@ -52,42 +52,27 @@ class FeedTest extends \PHPUnit_Framework_TestCase

protected function setUp()
{
$this->inboxFactory = $this->getMock(
$this->inboxFactory = $this->createPartialMock(
\Magento\AdminNotification\Model\InboxFactory::class,
['create'],
[],
'',
false
);
$this->curlFactory = $this->getMock(
\Magento\Framework\HTTP\Adapter\CurlFactory::class,
['create'],
[],
'',
false
['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->getMock(\Magento\Framework\App\State::class, ['getInstallDate'], [], '', false);
$this->inboxModel = $this->getMock(
\Magento\AdminNotification\Model\Inbox::class,
[
$this->appState = $this->createPartialMock(\Magento\Framework\App\State::class, ['getInstallDate']);
$this->inboxModel = $this->createPartialMock(\Magento\AdminNotification\Model\Inbox::class, [
'__wakeup',
'parse'
],
[],
'',
false
);
$this->backendConfig = $this->getMock(
]);
$this->backendConfig = $this->createPartialMock(
\Magento\Backend\App\ConfigInterface::class,
[
'getValue',
'setValue',
'isSetFlag'
]
);
$this->cacheManager = $this->getMock(
$this->cacheManager = $this->createPartialMock(
\Magento\Framework\App\CacheInterface::class,
[
'load',
Expand All @@ -106,7 +91,7 @@ protected function setUp()
$this->productMetadata = $this->getMockBuilder(\Magento\Framework\App\ProductMetadata::class)
->disableOriginalConstructor()->getMock();

$this->urlBuilder = $this->getMock(\Magento\Framework\UrlInterface::class);
$this->urlBuilder = $this->createMock(\Magento\Framework\UrlInterface::class);

$this->feed = $this->objectManagerHelper->getObject(
\Magento\AdminNotification\Model\Feed::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
namespace Magento\AdminNotification\Test\Unit\Model;

class NotificationServiceTest extends \PHPUnit_Framework_TestCase
class NotificationServiceTest extends \PHPUnit\Framework\TestCase
{
/**
* Retrieve instance of notification service model
Expand All @@ -23,19 +23,13 @@ protected function _getServiceInstanceForMarkAsReadTest($notificationId)
* @var
* $notificationFactory \PHPUnit_Framework_MockObject_MockObject|\Magento\AdminNotification\Model\InboxFactory
*/
$notificationFactory = $this->getMock(
$notificationFactory = $this->createPartialMock(
\Magento\AdminNotification\Model\InboxFactory::class,
['create'],
[],
'',
false
['create']
);
$notification = $this->getMock(
$notification = $this->createPartialMock(
\Magento\AdminNotification\Model\Inbox::class,
['load', 'getId', 'save', 'setIsRead', '__sleep', '__wakeup'],
[],
'',
false
['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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
namespace Magento\AdminNotification\Test\Unit\Model\System\Message;

class CacheOutdatedTest extends \PHPUnit_Framework_TestCase
class CacheOutdatedTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \PHPUnit_Framework_MockObject_MockObject
Expand All @@ -29,9 +29,9 @@ class CacheOutdatedTest extends \PHPUnit_Framework_TestCase

protected function setUp()
{
$this->_authorizationMock = $this->getMock(\Magento\Framework\AuthorizationInterface::class);
$this->_urlInterfaceMock = $this->getMock(\Magento\Framework\UrlInterface::class);
$this->_cacheTypeListMock = $this->getMock(\Magento\Framework\App\Cache\TypeListInterface::class);
$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);

$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$arguments = [
Expand Down Expand Up @@ -64,10 +64,10 @@ public function testGetIdentity($expectedSum, $cacheTypes)

public function getIdentityDataProvider()
{
$cacheTypeMock1 = $this->getMock(\stdClass::class, ['getCacheType']);
$cacheTypeMock1 = $this->createPartialMock(\stdClass::class, ['getCacheType']);
$cacheTypeMock1->expects($this->any())->method('getCacheType')->will($this->returnValue('Simple'));

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

return [
Expand Down Expand Up @@ -97,7 +97,7 @@ public function testIsDisplayed($expected, $allowed, $cacheTypes)

public function isDisplayedDataProvider()
{
$cacheTypesMock = $this->getMock(\stdClass::class, ['getCacheType']);
$cacheTypesMock = $this->createPartialMock(\stdClass::class, ['getCacheType']);
$cacheTypesMock->expects($this->any())->method('getCacheType')->will($this->returnValue('someVal'));
$cacheTypes = [$cacheTypesMock, $cacheTypesMock];
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
namespace Magento\AdminNotification\Test\Unit\Model\System\Message\Media\Synchronization;

class ErrorTest extends \PHPUnit_Framework_TestCase
class ErrorTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \PHPUnit_Framework_MockObject_MockObject
Expand All @@ -24,9 +24,12 @@ class ErrorTest extends \PHPUnit_Framework_TestCase

protected function setUp()
{
$this->_syncFlagMock = $this->getMock(\Magento\MediaStorage\Model\File\Storage\Flag::class, [], [], '', false);
$this->_syncFlagMock = $this->createPartialMock(
\Magento\MediaStorage\Model\File\Storage\Flag::class,
['setState', 'save', 'getFlagData']
);

$this->_fileStorage = $this->getMock(\Magento\MediaStorage\Model\File\Storage\Flag::class, [], [], '', false);
$this->_fileStorage = $this->createMock(\Magento\MediaStorage\Model\File\Storage\Flag::class);
$this->_fileStorage->expects($this->any())->method('loadSelf')->will($this->returnValue($this->_syncFlagMock));

$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
namespace Magento\AdminNotification\Test\Unit\Model\System\Message;

class SecurityTest extends \PHPUnit_Framework_TestCase
class SecurityTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \PHPUnit_Framework_MockObject_MockObject
Expand Down Expand Up @@ -35,14 +35,11 @@ class SecurityTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
//Prepare objects for constructor
$this->_cacheMock = $this->getMock(\Magento\Framework\App\CacheInterface::class);
$this->_scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
$this->_curlFactoryMock = $this->getMock(
$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,
['create'],
[],
'',
false
['create']
);

$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
Expand Down Expand Up @@ -70,7 +67,7 @@ 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));

$httpAdapterMock = $this->getMock(\Magento\Framework\HTTP\Adapter\Curl::class, [], [], '', false);
$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));

Expand Down
Loading

0 comments on commit ef19ca6

Please sign in to comment.