Skip to content

Commit

Permalink
MAGETWO-51858: Convert literal class names to \Namespace\Classname::c…
Browse files Browse the repository at this point in the history
…lass
  • Loading branch information
Stanislav Idolov committed Apr 29, 2016
1 parent 1dd0cde commit e5df4bc
Show file tree
Hide file tree
Showing 396 changed files with 3,016 additions and 2,468 deletions.
4 changes: 2 additions & 2 deletions app/code/Magento/Directory/Block/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function getCountryHtmlSelect($defValue = null, $name = 'country_id', $id
$this->_configCacheType->save(serialize($options), $cacheKey);
}
$html = $this->getLayout()->createBlock(
'Magento\Framework\View\Element\Html\Select'
\Magento\Framework\View\Element\Html\Select::class
)->setName(
$name
)->setId(
Expand Down Expand Up @@ -166,7 +166,7 @@ public function getRegionHtmlSelect()
$this->_configCacheType->save(serialize($options), $cacheKey);
}
$html = $this->getLayout()->createBlock(
'Magento\Framework\View\Element\Html\Select'
\Magento\Framework\View\Element\Html\Select::class
)->setName(
'region'
)->setTitle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function execute()
$countryId = $this->getRequest()->getParam('parent');
if (!empty($countryId)) {
$arrRegions = $this->_objectManager->create(
'Magento\Directory\Model\ResourceModel\Region\Collection'
\Magento\Directory\Model\ResourceModel\Region\Collection::class
)->addCountryFilter(
$countryId
)->load()->toOptionArray();
Expand All @@ -32,7 +32,7 @@ public function execute()
}
}
$this->getResponse()->representJson(
$this->_objectManager->get('Magento\Framework\Json\Helper\Data')->jsonEncode($arrRes)
$this->_objectManager->get(\Magento\Framework\Json\Helper\Data::class)->jsonEncode($arrRes)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SwitchAction extends \Magento\Framework\App\Action\Action
public function execute()
{
/** @var \Magento\Store\Model\StoreManagerInterface $storeManager */
$storeManager = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface');
$storeManager = $this->_objectManager->get(\Magento\Store\Model\StoreManagerInterface::class);
$currency = (string)$this->getRequest()->getParam('currency');
if ($currency) {
$storeManager->getStore()->setCurrentCurrencyCode($currency);
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Directory/Model/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct(
*/
protected function _construct()
{
$this->_init('Magento\Directory\Model\ResourceModel\Country');
$this->_init(\Magento\Directory\Model\ResourceModel\Country::class);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Directory/Model/Country/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ class Format extends \Magento\Framework\Model\AbstractModel
*/
protected function _construct()
{
$this->_init('Magento\Directory\Model\ResourceModel\Country\Format');
$this->_init(\Magento\Directory\Model\ResourceModel\Country\Format::class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(
\Magento\Framework\Config\ValidationStateInterface $validationState,
$fileName = 'zip_codes.xml',
$idAttributes = [],
$domDocumentClass = 'Magento\Framework\Config\Dom',
$domDocumentClass = \Magento\Framework\Config\Dom::class,
$defaultScope = 'global'
) {
parent::__construct(
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Directory/Model/CountryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan
*/
public function create(array $arguments = [])
{
return $this->_objectManager->create('Magento\Directory\Model\Country', $arguments, false);
return $this->_objectManager->create(\Magento\Directory\Model\Country::class, $arguments, false);
}
}
2 changes: 1 addition & 1 deletion app/code/Magento/Directory/Model/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function __construct(
*/
protected function _construct()
{
$this->_init('Magento\Directory\Model\ResourceModel\Currency');
$this->_init(\Magento\Directory\Model\ResourceModel\Currency::class);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private function getHttpClientFactory()
{
if ($this->httpClientFactory === null) {
$this->httpClientFactory = \Magento\Framework\App\ObjectManager::getInstance()
->get('Magento\Framework\HTTP\ZendClientFactory');
->get(\Magento\Framework\HTTP\ZendClientFactory::class);
}
return $this->httpClientFactory;
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Directory/Model/Region.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Region extends \Magento\Framework\Model\AbstractModel
*/
protected function _construct()
{
$this->_init('Magento\Directory\Model\ResourceModel\Region');
$this->_init(\Magento\Directory\Model\ResourceModel\Region::class);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Directory/Model/RegionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan
*/
public function create(array $arguments = [])
{
return $this->_objectManager->create('Magento\Directory\Model\Region', $arguments);
return $this->_objectManager->create(\Magento\Directory\Model\Region::class, $arguments);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function __construct(
*/
protected function _construct()
{
$this->_init('Magento\Directory\Model\Country', 'Magento\Directory\Model\ResourceModel\Country');
$this->_init(\Magento\Directory\Model\Country::class, \Magento\Directory\Model\ResourceModel\Country::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\Directory\Model\Country\Format', 'Magento\Directory\Model\ResourceModel\Country\Format');
$this->_init(
\Magento\Directory\Model\Country\Format::class,
\Magento\Directory\Model\ResourceModel\Country\Format::class
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct(
*/
protected function _construct()
{
$this->_init('Magento\Directory\Model\Region', 'Magento\Directory\Model\ResourceModel\Region');
$this->_init(\Magento\Directory\Model\Region::class, \Magento\Directory\Model\ResourceModel\Region::class);

$this->_countryTable = $this->getTable('directory_country');
$this->_regionNameTable = $this->getTable('directory_country_region_name');
Expand Down
10 changes: 5 additions & 5 deletions app/code/Magento/Directory/Test/Unit/Block/CurrencyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CurrencyTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->urlBuilder = $this->getMock(
'\Magento\Framework\UrlInterface',
\Magento\Framework\UrlInterface::class,
[],
[],
'',
Expand All @@ -36,7 +36,7 @@ protected function setUp()

/** @var \Magento\Framework\View\Element\Template\Context $context */
$context = $this->getMock(
'\Magento\Framework\View\Element\Template\Context',
\Magento\Framework\View\Element\Template\Context::class,
['getUrlBuilder'],
[],
'',
Expand All @@ -45,11 +45,11 @@ protected function setUp()
$context->expects($this->any())->method('getUrlBuilder')->will($this->returnValue($this->urlBuilder));

/** @var \Magento\Directory\Model\CurrencyFactory $currencyFactory */
$currencyFactory = $this->getMock('\Magento\Directory\Model\CurrencyFactory', [], [], '', false);
$this->postDataHelper = $this->getMock('Magento\Framework\Data\Helper\PostHelper', [], [], '', false);
$currencyFactory = $this->getMock(\Magento\Directory\Model\CurrencyFactory::class, [], [], '', false);
$this->postDataHelper = $this->getMock(\Magento\Framework\Data\Helper\PostHelper::class, [], [], '', false);

/** @var \Magento\Framework\Locale\ResolverInterface $localeResolver */
$localeResolver = $this->getMock('\Magento\Framework\Locale\ResolverInterface', [], [], '', false);
$localeResolver = $this->getMock(\Magento\Framework\Locale\ResolverInterface::class, [], [], '', false);

$this->object = new \Magento\Directory\Block\Currency(
$context,
Expand Down
28 changes: 14 additions & 14 deletions app/code/Magento/Directory/Test/Unit/Block/DataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ protected function setUp()
{
$this->prepareContext();

$this->helperData = $this->getMockBuilder('Magento\Directory\Helper\Data')
$this->helperData = $this->getMockBuilder(\Magento\Directory\Helper\Data::class)
->disableOriginalConstructor()
->getMock();

$this->jsonEncoder = $this->getMockBuilder('Magento\Framework\Json\EncoderInterface')
$this->jsonEncoder = $this->getMockBuilder(\Magento\Framework\Json\EncoderInterface::class)
->getMockForAbstractClass();

$this->cacheTypeConfig = $this->getMockBuilder('Magento\Framework\App\Cache\Type\Config')
$this->cacheTypeConfig = $this->getMockBuilder(\Magento\Framework\App\Cache\Type\Config::class)
->disableOriginalConstructor()
->getMock();

$this->regionCollectionFactory = $this->getMockBuilder(
'Magento\Directory\Model\ResourceModel\Region\CollectionFactory'
\Magento\Directory\Model\ResourceModel\Region\CollectionFactory::class
)
->disableOriginalConstructor()
->getMock();
Expand All @@ -95,24 +95,24 @@ protected function setUp()

protected function prepareContext()
{
$this->store = $this->getMockBuilder('Magento\Store\Model\Store')
$this->store = $this->getMockBuilder(\Magento\Store\Model\Store::class)
->disableOriginalConstructor()
->getMock();

$this->scopeConfig = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface')
$this->scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class)
->getMockForAbstractClass();

$this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface')
$this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
->getMockForAbstractClass();

$this->storeManager->expects($this->any())
->method('getStore')
->willReturn($this->store);

$this->layout = $this->getMockBuilder('Magento\Framework\View\LayoutInterface')
$this->layout = $this->getMockBuilder(\Magento\Framework\View\LayoutInterface::class)
->getMockForAbstractClass();

$this->context = $this->getMockBuilder('Magento\Framework\View\Element\Template\Context')
$this->context = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class)
->disableOriginalConstructor()
->getMock();

Expand All @@ -131,12 +131,12 @@ protected function prepareContext()

protected function prepareCountryCollection()
{
$this->countryCollection = $this->getMockBuilder('Magento\Directory\Model\ResourceModel\Country\Collection')
->disableOriginalConstructor()
->getMock();
$this->countryCollection = $this->getMockBuilder(
\Magento\Directory\Model\ResourceModel\Country\Collection::class
)->disableOriginalConstructor()->getMock();

$this->countryCollectionFactory = $this->getMockBuilder(
'Magento\Directory\Model\ResourceModel\Country\CollectionFactory'
\Magento\Directory\Model\ResourceModel\Country\CollectionFactory::class
)
->disableOriginalConstructor()
->setMethods([
Expand Down Expand Up @@ -283,7 +283,7 @@ protected function mockElementHtmlSelect($defaultCountry, $options, $resultHtml)
$id = 'country';
$title = 'Country';

$elementHtmlSelect = $this->getMockBuilder('Magento\Framework\View\Element\Html\Select')
$elementHtmlSelect = $this->getMockBuilder(\Magento\Framework\View\Element\Html\Select::class)
->disableOriginalConstructor()
->setMethods([
'setName',
Expand Down
27 changes: 15 additions & 12 deletions app/code/Magento/Directory/Test/Unit/Helper/DataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

use Magento\Directory\Helper\Data;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class DataTest extends \PHPUnit_Framework_TestCase
{
/**
Expand Down Expand Up @@ -42,31 +45,31 @@ class DataTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface');
$context = $this->getMock('Magento\Framework\App\Helper\Context', [], [], '', false);
$this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
$context = $this->getMock(\Magento\Framework\App\Helper\Context::class, [], [], '', false);
$context->expects($this->any())
->method('getScopeConfig')
->willReturn($this->scopeConfigMock);

$configCacheType = $this->getMock('Magento\Framework\App\Cache\Type\Config', [], [], '', false);
$configCacheType = $this->getMock(\Magento\Framework\App\Cache\Type\Config::class, [], [], '', false);

$this->_countryCollection = $this->getMock(
'Magento\Directory\Model\ResourceModel\Country\Collection',
\Magento\Directory\Model\ResourceModel\Country\Collection::class,
[],
[],
'',
false
);

$this->_regionCollection = $this->getMock(
'Magento\Directory\Model\ResourceModel\Region\Collection',
\Magento\Directory\Model\ResourceModel\Region\Collection::class,
[],
[],
'',
false
);
$regCollectionFactory = $this->getMock(
'Magento\Directory\Model\ResourceModel\Region\CollectionFactory',
\Magento\Directory\Model\ResourceModel\Region\CollectionFactory::class,
['create'],
[],
'',
Expand All @@ -80,13 +83,13 @@ protected function setUp()
$this->returnValue($this->_regionCollection)
);

$this->jsonHelperMock = $this->getMock('Magento\Framework\Json\Helper\Data', [], [], '', false);
$this->jsonHelperMock = $this->getMock(\Magento\Framework\Json\Helper\Data::class, [], [], '', false);

$this->_store = $this->getMock('Magento\Store\Model\Store', [], [], '', false);
$storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false);
$this->_store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false);
$storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false);
$storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->_store));

$currencyFactory = $this->getMock('Magento\Directory\Model\CurrencyFactory', [], [], '', false);
$currencyFactory = $this->getMock(\Magento\Directory\Model\CurrencyFactory::class, [], [], '', false);

$arguments = [
'context' => $context,
Expand All @@ -97,7 +100,7 @@ protected function setUp()
'storeManager' => $storeManager,
'currencyFactory' => $currencyFactory,
];
$this->_object = $objectManager->getObject('Magento\Directory\Helper\Data', $arguments);
$this->_object = $objectManager->getObject(\Magento\Directory\Helper\Data::class, $arguments);
}

public function testGetRegionJson()
Expand Down Expand Up @@ -248,7 +251,7 @@ public function testGetCountryCollection()
$this->returnValue(0)
);

$store = $this->getMock('Magento\Store\Model\Store', [], [], '', false);
$store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false);
$this->_countryCollection->expects(
$this->once()
)->method(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ protected function setUp()
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);

$countryCollectionFactory = $this->getMockBuilder(
'Magento\Directory\Model\ResourceModel\Country\CollectionFactory'
\Magento\Directory\Model\ResourceModel\Country\CollectionFactory::class
)->setMethods(['create', '__wakeup', '__sleep'])->disableOriginalConstructor()->getMock();

$this->countryCollection = $this->getMockBuilder('Magento\Directory\Model\ResourceModel\Country\Collection')
->setMethods(['load', 'toOptionArray', '__wakeup', '__sleep'])
$this->countryCollection = $this->getMockBuilder(
\Magento\Directory\Model\ResourceModel\Country\Collection::class
)->setMethods(['load', 'toOptionArray', '__wakeup', '__sleep'])
->disableOriginalConstructor()
->getMock();
$countryCollectionFactory->expects($this->once())
Expand All @@ -42,9 +43,9 @@ protected function setUp()
->will($this->returnSelf());

$regionCollectionFactory = $this->getMockBuilder(
'Magento\Directory\Model\ResourceModel\Region\CollectionFactory'
\Magento\Directory\Model\ResourceModel\Region\CollectionFactory::class
)->disableOriginalConstructor()->setMethods(['create', '__wakeup', '__sleep'])->getMock();
$this->regionCollection = $this->getMockBuilder('Magento\Directory\Model\ResourceModel\Region\Collection')
$this->regionCollection = $this->getMockBuilder(\Magento\Directory\Model\ResourceModel\Region\Collection::class)
->disableOriginalConstructor()
->setMethods(['load', 'getIterator', '__wakeup', '__sleep'])
->getMock();
Expand All @@ -56,7 +57,7 @@ protected function setUp()
->will($this->returnValue($this->regionCollection));

$this->model = $objectManagerHelper->getObject(
'Magento\Directory\Model\Config\Source\Allregion',
\Magento\Directory\Model\Config\Source\Allregion::class,
[
'countryCollectionFactory' => $countryCollectionFactory,
'regionCollectionFactory' => $regionCollectionFactory
Expand Down Expand Up @@ -200,7 +201,7 @@ private function generateCountry($countryLabel, $countryValue)
*/
private function generateRegion($countryId, $id, $defaultName)
{
$region = $this->getMockBuilder('Magento\Directory\Model\Region')
$region = $this->getMockBuilder(\Magento\Directory\Model\Region::class)
->disableOriginalConstructor()
->setMethods(['getCountryId', 'getId', 'getDefaultName', '__wakeup', '__sleep'])
->getMock();
Expand Down
Loading

0 comments on commit e5df4bc

Please sign in to comment.