Skip to content

Commit

Permalink
Merge pull request #202 from magento-folks/literal_classname_to_names…
Browse files Browse the repository at this point in the history
…pace

[Folks] Literal classname to namespace
  • Loading branch information
dvoskoboinikov authored Aug 1, 2016
2 parents a7bcac3 + 8066d51 commit 2638640
Show file tree
Hide file tree
Showing 6,318 changed files with 41,224 additions and 34,455 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function execute()
$responseData = [];
try {
$this->_objectManager->create(
'Magento\AdminNotification\Model\NotificationService'
\Magento\AdminNotification\Model\NotificationService::class
)->markAsRead(
$notificationId
);
Expand All @@ -31,7 +31,7 @@ public function execute()
$responseData['success'] = false;
}
$this->getResponse()->representJson(
$this->_objectManager->create('Magento\Framework\Json\Helper\Data')->jsonEncode($responseData)
$this->_objectManager->create(\Magento\Framework\Json\Helper\Data::class)->jsonEncode($responseData)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function execute()
if ($notificationId) {
try {
$this->_objectManager->create(
'Magento\AdminNotification\Model\NotificationService'
\Magento\AdminNotification\Model\NotificationService::class
)->markAsRead(
$notificationId
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function execute()
} else {
try {
foreach ($ids as $id) {
$model = $this->_objectManager->create('Magento\AdminNotification\Model\Inbox')->load($id);
$model = $this->_objectManager->create(\Magento\AdminNotification\Model\Inbox::class)->load($id);
if ($model->getId()) {
$model->setIsRead(1)->save();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function execute()
} else {
try {
foreach ($ids as $id) {
$model = $this->_objectManager->create('Magento\AdminNotification\Model\Inbox')->load($id);
$model = $this->_objectManager->create(\Magento\AdminNotification\Model\Inbox::class)->load($id);
if ($model->getId()) {
$model->setIsRemove(1)->save();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Remove extends \Magento\AdminNotification\Controller\Adminhtml\Notificatio
public function execute()
{
if ($id = $this->getRequest()->getParam('id')) {
$model = $this->_objectManager->create('Magento\AdminNotification\Model\Inbox')->load($id);
$model = $this->_objectManager->create(\Magento\AdminNotification\Model\Inbox::class)->load($id);

if (!$model->getId()) {
$this->_redirect('adminhtml/*/');
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/AdminNotification/Model/Inbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Inbox extends \Magento\Framework\Model\AbstractModel implements NotifierIn
*/
protected function _construct()
{
$this->_init('Magento\AdminNotification\Model\ResourceModel\Inbox');
$this->_init(\Magento\AdminNotification\Model\ResourceModel\Inbox::class);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
*/
protected function _construct()
{
$this->_init('Magento\AdminNotification\Model\Inbox', 'Magento\AdminNotification\Model\ResourceModel\Inbox');
$this->_init(
\Magento\AdminNotification\Model\Inbox::class,
\Magento\AdminNotification\Model\ResourceModel\Inbox::class
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class Critical extends \Magento\Framework\Model\ResourceModel\Db\Collection\Abst
*/
protected function _construct()
{
$this->_init('Magento\AdminNotification\Model\Inbox', 'Magento\AdminNotification\Model\ResourceModel\Inbox');
$this->_init(
\Magento\AdminNotification\Model\Inbox::class,
\Magento\AdminNotification\Model\ResourceModel\Inbox::class
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public function __construct(
protected function _construct()
{
$this->_init(
'Magento\AdminNotification\Model\System\Message',
'Magento\AdminNotification\Model\ResourceModel\System\Message'
\Magento\AdminNotification\Model\System\Message::class,
\Magento\AdminNotification\Model\ResourceModel\System\Message::class
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Message extends \Magento\Framework\Model\AbstractModel implements \Magento
*/
protected function _construct()
{
$this->_init('Magento\AdminNotification\Model\ResourceModel\System\Message');
$this->_init(\Magento\AdminNotification\Model\ResourceModel\System\Message::class);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function _getBlockInstance($unreadNotifications)
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
// mock collection of unread notifications
$notificationList = $this->getMock(
'Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Unread',
\Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Unread::class,
['getSize', 'setCurPage', 'setPageSize'],
[],
'',
Expand All @@ -33,7 +33,7 @@ protected function _getBlockInstance($unreadNotifications)
$notificationList->expects($this->any())->method('getSize')->will($this->returnValue($unreadNotifications));

$block = $objectManagerHelper->getObject(
'Magento\AdminNotification\Block\ToolbarEntry',
\Magento\AdminNotification\Block\ToolbarEntry::class,
['notificationList' => $notificationList]
);

Expand All @@ -52,12 +52,14 @@ public function testGetLatestUnreadNotifications()
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);

// 1. Create mocks
$notificationList = $this->getMockBuilder('Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Unread')
$notificationList = $this->getMockBuilder(
\Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Unread::class)
->disableOriginalConstructor()
->getMock();

/** @var \Magento\AdminNotification\Block\ToolbarEntry $model */
$model = $helper->getObject('Magento\AdminNotification\Block\ToolbarEntry',
$model = $helper->getObject(
\Magento\AdminNotification\Block\ToolbarEntry::class,
['notificationList' => $notificationList]
);

Expand Down
34 changes: 23 additions & 11 deletions app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,25 @@ class FeedTest extends \PHPUnit_Framework_TestCase

protected function setUp()
{
$this->inboxFactory = $this->getMock('Magento\AdminNotification\Model\InboxFactory', ['create'], [], '', false);
$this->curlFactory = $this->getMock('Magento\Framework\HTTP\Adapter\CurlFactory', ['create'], [], '', false);
$this->curl = $this->getMockBuilder('Magento\Framework\HTTP\Adapter\Curl')
$this->inboxFactory = $this->getMock(
\Magento\AdminNotification\Model\InboxFactory::class,
['create'],
[],
'',
false
);
$this->curlFactory = $this->getMock(
\Magento\Framework\HTTP\Adapter\CurlFactory::class,
['create'],
[],
'',
false
);
$this->curl = $this->getMockBuilder(\Magento\Framework\HTTP\Adapter\Curl::class)
->disableOriginalConstructor()->getMock();
$this->appState = $this->getMock('Magento\Framework\App\State', ['getInstallDate'], [], '', false);
$this->appState = $this->getMock(\Magento\Framework\App\State::class, ['getInstallDate'], [], '', false);
$this->inboxModel = $this->getMock(
'Magento\AdminNotification\Model\Inbox',
\Magento\AdminNotification\Model\Inbox::class,
[
'__wakeup',
'parse'
Expand All @@ -68,15 +80,15 @@ protected function setUp()
false
);
$this->backendConfig = $this->getMock(
'Magento\Backend\App\ConfigInterface',
\Magento\Backend\App\ConfigInterface::class,
[
'getValue',
'setValue',
'isSetFlag'
]
);
$this->cacheManager = $this->getMock(
'Magento\Framework\App\CacheInterface',
\Magento\Framework\App\CacheInterface::class,
[
'load',
'getFrontend',
Expand All @@ -86,18 +98,18 @@ protected function setUp()
]
);

$this->deploymentConfig = $this->getMockBuilder('Magento\Framework\App\DeploymentConfig')
$this->deploymentConfig = $this->getMockBuilder(\Magento\Framework\App\DeploymentConfig::class)
->disableOriginalConstructor()->getMock();

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

$this->productMetadata = $this->getMockBuilder('Magento\Framework\App\ProductMetadata')
$this->productMetadata = $this->getMockBuilder(\Magento\Framework\App\ProductMetadata::class)
->disableOriginalConstructor()->getMock();

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

$this->feed = $this->objectManagerHelper->getObject(
'Magento\AdminNotification\Model\Feed',
\Magento\AdminNotification\Model\Feed::class,
[
'backendConfig' => $this->backendConfig,
'cacheManager' => $this->cacheManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ protected function _getServiceInstanceForMarkAsReadTest($notificationId)
* $notificationFactory \PHPUnit_Framework_MockObject_MockObject|\Magento\AdminNotification\Model\InboxFactory
*/
$notificationFactory = $this->getMock(
'Magento\AdminNotification\Model\InboxFactory',
\Magento\AdminNotification\Model\InboxFactory::class,
['create'],
[],
'',
false
);
$notification = $this->getMock(
'Magento\AdminNotification\Model\Inbox',
\Magento\AdminNotification\Model\Inbox::class,
['load', 'getId', 'save', 'setIsRead', '__sleep', '__wakeup'],
[],
'',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class CacheOutdatedTest extends \PHPUnit_Framework_TestCase

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

$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$arguments = [
Expand All @@ -40,7 +40,7 @@ protected function setUp()
'cacheTypeList' => $this->_cacheTypeListMock,
];
$this->_messageModel = $objectManagerHelper->getObject(
'Magento\AdminNotification\Model\System\Message\CacheOutdated',
\Magento\AdminNotification\Model\System\Message\CacheOutdated::class,
$arguments
);
}
Expand All @@ -64,10 +64,10 @@ public function testGetIdentity($expectedSum, $cacheTypes)

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

$cacheTypeMock2 = $this->getMock('stdClass', ['getCacheType']);
$cacheTypeMock2 = $this->getMock(\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', ['getCacheType']);
$cacheTypesMock = $this->getMock(\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 @@ -24,15 +24,15 @@ class ErrorTest extends \PHPUnit_Framework_TestCase

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

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

$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$arguments = ['fileStorage' => $this->_fileStorage];
$this->_model = $objectManagerHelper->getObject(
'Magento\AdminNotification\Model\System\Message\Media\Synchronization\Error',
\Magento\AdminNotification\Model\System\Message\Media\Synchronization\Error::class,
$arguments
);
}
Expand All @@ -56,7 +56,7 @@ public function testIsDisplayed($expectedFirstRun, $data)
// 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 */
$model = $objectManagerHelper->getObject(
'Magento\AdminNotification\Model\System\Message\Media\Synchronization\Error',
\Magento\AdminNotification\Model\System\Message\Media\Synchronization\Error::class,
$arguments
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ class SecurityTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
//Prepare objects for constructor
$this->_cacheMock = $this->getMock('Magento\Framework\App\CacheInterface');
$this->_scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface');
$this->_cacheMock = $this->getMock(\Magento\Framework\App\CacheInterface::class);
$this->_scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
$this->_curlFactoryMock = $this->getMock(
'Magento\Framework\HTTP\Adapter\CurlFactory',
\Magento\Framework\HTTP\Adapter\CurlFactory::class,
['create'],
[],
'',
Expand All @@ -52,7 +52,7 @@ protected function setUp()
'curlFactory' => $this->_curlFactoryMock,
];
$this->_messageModel = $objectManagerHelper->getObject(
'Magento\AdminNotification\Model\System\Message\Security',
\Magento\AdminNotification\Model\System\Message\Security::class,
$arguments
);
}
Expand All @@ -70,7 +70,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', [], [], '', false);
$httpAdapterMock = $this->getMock(\Magento\Framework\HTTP\Adapter\Curl::class, [], [], '', false);
$httpAdapterMock->expects($this->any())->method('read')->will($this->returnValue($response));
$this->_curlFactoryMock->expects($this->any())->method('create')->will($this->returnValue($httpAdapterMock));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function execute()
/** @var $attrFilterBlock \Magento\ImportExport\Block\Adminhtml\Export\Filter */
$attrFilterBlock = $resultLayout->getLayout()->getBlock('export.filter');
/** @var $export \Magento\ImportExport\Model\Export */
$export = $this->_objectManager->create('Magento\ImportExport\Model\Export');
$export = $this->_objectManager->create(\Magento\ImportExport\Model\Export::class);
$export->setData($data);
$export->filterAttributeCollection(
$attrFilterBlock->prepareCollection($export->getEntityAttributeCollection())
Expand Down
Loading

0 comments on commit 2638640

Please sign in to comment.