From ccc1158a773097d0754c651863b2d38be8dfa849 Mon Sep 17 00:00:00 2001 From: Roman Ganin <rganin@ebay.com> Date: Wed, 24 Jun 2015 19:00:44 +0300 Subject: [PATCH] MAGETWO-39187: Remove @codingStandardsIgnoreFile directive from code assigned to Troll team --- .../Controller/Adminhtml/Promo/Catalog.php | 13 +++- .../CatalogRule/Test/Unit/Model/CronTest.php | 26 +++++--- .../Test/Unit/Plugin/Indexer/CategoryTest.php | 51 ++++++++++----- .../Unit/Plugin/Indexer/CustomerGroupTest.php | 37 ++++++++--- .../Unit/Plugin/Indexer/ImportExportTest.php | 29 ++++++--- .../Test/Unit/Plugin/Indexer/WebsiteTest.php | 29 ++++++--- .../Test/Unit/Controller/Index/IndexTest.php | 18 ++++-- .../Test/Unit/Controller/IndexTest.php | 63 +++++++++--------- .../Contact/Test/Unit/Helper/DataTest.php | 22 +++++-- .../Model/Processor/InvalidateCacheTest.php | 47 ++++++++------ .../Reports/Block/Adminhtml/Filter/Form.php | 25 +++++--- .../Magento/Reports/Block/Adminhtml/Grid.php | 16 ++--- .../Block/Adminhtml/Grid/AbstractGrid.php | 4 ++ .../Grid/Column/Renderer/Currency.php | 8 +-- .../Block/Adminhtml/Sales/Invoiced/Grid.php | 17 +++-- .../Block/Adminhtml/Sales/Refunded/Grid.php | 17 +++-- .../Block/Adminhtml/Sales/Sales/Grid.php | 18 +++--- .../Block/Adminhtml/Sales/Shipping/Grid.php | 17 +++-- .../Block/Adminhtml/Sales/Tax/Grid.php | 21 +++--- .../Reports/Block/Adminhtml/Wishlist.php | 38 ++--------- .../Reports/Block/Product/Compared.php | 10 ++- .../Magento/Reports/Block/Product/Viewed.php | 13 ++-- app/code/Magento/Reports/Helper/Data.php | 12 ++-- .../Model/Resource/Order/Collection.php | 64 ++++++++++++++----- .../Resource/Product/Index/AbstractIndex.php | 16 +++-- .../Model/Resource/Report/AbstractReport.php | 18 ++++-- .../Model/Resource/Report/Product/Viewed.php | 8 ++- .../Magento/Reports/Setup/InstallData.php | 4 +- .../Collection/AbstractCollectionTest.php | 20 +++--- app/code/Magento/Rule/Model/AbstractModel.php | 8 ++- .../Condition/Product/AbstractProductTest.php | 28 +++++--- 31 files changed, 442 insertions(+), 275 deletions(-) diff --git a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog.php b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog.php index 3b20dec460b..5ab7a97bf4a 100644 --- a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog.php +++ b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - /** * Backend Catalog Price Rules controller * @@ -36,11 +34,15 @@ class Catalog extends Action protected $_coreRegistry = null; /** + * Date filter instance + * * @var \Magento\Framework\Stdlib\DateTime\Filter\Date */ protected $_dateFilter; /** + * Constructor + * * @param Context $context * @param Registry $coreRegistry * @param Date $dateFilter @@ -53,6 +55,8 @@ class Catalog extends Action } /** + * Init action + * * @return $this */ protected function _initAction() @@ -68,6 +72,8 @@ class Catalog extends Action } /** + * Is access to section allowed + * * @return bool */ protected function _isAllowed() @@ -94,7 +100,8 @@ class Catalog extends Action public function getDirtyRulesNoticeMessage() { $defaultMessage = __( - 'There are rules that have been changed but were not applied. Please, click Apply Rules in order to see immediate effect in the catalog.' + 'There are rules that have been changed but were not applied. ' + . 'Please, click Apply Rules in order to see immediate effect in the catalog.' ); return $this->_dirtyRulesNoticeMessage ? $this->_dirtyRulesNoticeMessage : $defaultMessage; } diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/CronTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/CronTest.php index 07e27c6398a..2d8f4b8b8a6 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/CronTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/CronTest.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\CatalogRule\Test\Unit\Model; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -13,23 +11,35 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class CronTest extends \PHPUnit_Framework_TestCase { /** + * Processor + * * @var \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor|\PHPUnit_Framework_MockObject_MockObject */ protected $ruleProductProcessor; /** + * Cron object + * * @var \Magento\CatalogRule\Model\Cron */ protected $cron; protected function setUp() { - $this->ruleProductProcessor = $this->getMock('Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', - [], [], '', false); - - $this->cron = (new ObjectManager($this))->getObject('Magento\CatalogRule\Model\Cron', [ - 'ruleProductProcessor' => $this->ruleProductProcessor, - ]); + $this->ruleProductProcessor = $this->getMock( + 'Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', + [], + [], + '', + false + ); + + $this->cron = (new ObjectManager($this))->getObject( + 'Magento\CatalogRule\Model\Cron', + [ + 'ruleProductProcessor' => $this->ruleProductProcessor, + ] + ); } public function testDailyCatalogUpdate() diff --git a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CategoryTest.php b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CategoryTest.php index 4814767f39d..59bd89d0057 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CategoryTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CategoryTest.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\CatalogRule\Test\Unit\Plugin\Indexer; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -29,20 +27,37 @@ class CategoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->productRuleProcessor = $this->getMock('Magento\CatalogRule\Model\Indexer\Product\ProductRuleProcessor', - [], [], '', false); - $this->subject = $this->getMock('Magento\Catalog\Model\Category', ['getAffectedProductIds', '__wakeUp'], [], - '', false); - - $this->plugin = (new ObjectManager($this))->getObject('Magento\CatalogRule\Plugin\Indexer\Category', [ - 'productRuleProcessor' => $this->productRuleProcessor, - ]); + $this->productRuleProcessor = $this->getMock( + 'Magento\CatalogRule\Model\Indexer\Product\ProductRuleProcessor', + [], + [], + '', + false + ); + $this->subject = $this->getMock( + 'Magento\Catalog\Model\Category', + ['getAffectedProductIds', '__wakeUp'], + [], + '', + false + ); + + $this->plugin = (new ObjectManager($this))->getObject( + 'Magento\CatalogRule\Plugin\Indexer\Category', + [ + 'productRuleProcessor' => $this->productRuleProcessor, + ] + ); } public function testAfterSaveWithoutAffectedProductIds() { - $this->subject->expects($this->any())->method('getAffectedProductIds')->will($this->returnValue([])); - $this->productRuleProcessor->expects($this->never())->method('reindexList'); + $this->subject->expects($this->any()) + ->method('getAffectedProductIds') + ->will($this->returnValue([])); + + $this->productRuleProcessor->expects($this->never()) + ->method('reindexList'); $this->assertEquals($this->subject, $this->plugin->afterSave($this->subject, $this->subject)); } @@ -51,15 +66,21 @@ class CategoryTest extends \PHPUnit_Framework_TestCase { $productIds = [1, 2, 3]; - $this->subject->expects($this->any())->method('getAffectedProductIds')->will($this->returnValue($productIds)); - $this->productRuleProcessor->expects($this->once())->method('reindexList')->with($productIds); + $this->subject->expects($this->any()) + ->method('getAffectedProductIds') + ->will($this->returnValue($productIds)); + + $this->productRuleProcessor->expects($this->once()) + ->method('reindexList') + ->with($productIds); $this->assertEquals($this->subject, $this->plugin->afterSave($this->subject, $this->subject)); } public function testAfterDelete() { - $this->productRuleProcessor->expects($this->once())->method('markIndexerAsInvalid'); + $this->productRuleProcessor->expects($this->once()) + ->method('markIndexerAsInvalid'); $this->assertEquals($this->subject, $this->plugin->afterDelete($this->subject, $this->subject)); } diff --git a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CustomerGroupTest.php b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CustomerGroupTest.php index f0c7283f1d4..fb911fb1cdb 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CustomerGroupTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CustomerGroupTest.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\CatalogRule\Test\Unit\Plugin\Indexer; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -13,34 +11,55 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class CustomerGroupTest extends \PHPUnit_Framework_TestCase { /** + * Rule processor mock + * * @var \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor|\PHPUnit_Framework_MockObject_MockObject */ protected $ruleProductProcessor; /** + * Subject group + * * @var \Magento\Customer\Model\Group|\PHPUnit_Framework_MockObject_MockObject */ protected $subject; /** + * Tested plugin + * * @var \Magento\CatalogRule\Plugin\Indexer\CustomerGroup */ protected $plugin; protected function setUp() { - $this->ruleProductProcessor = $this->getMock('Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', - [], [], '', false); - $this->subject = $this->getMock('Magento\Customer\Model\Group', [], [], '', false); + $this->ruleProductProcessor = $this->getMock( + 'Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', + [], + [], + '', + false + ); + $this->subject = $this->getMock( + 'Magento\Customer\Model\Group', + [], + [], + '', + false + ); - $this->plugin = (new ObjectManager($this))->getObject('Magento\CatalogRule\Plugin\Indexer\CustomerGroup', [ - 'ruleProductProcessor' => $this->ruleProductProcessor, - ]); + $this->plugin = (new ObjectManager($this))->getObject( + 'Magento\CatalogRule\Plugin\Indexer\CustomerGroup', + [ + 'ruleProductProcessor' => $this->ruleProductProcessor, + ] + ); } public function testAfterDelete() { - $this->ruleProductProcessor->expects($this->once())->method('markIndexerAsInvalid'); + $this->ruleProductProcessor->expects($this->once()) + ->method('markIndexerAsInvalid'); $this->assertEquals($this->subject, $this->plugin->afterDelete($this->subject, $this->subject)); } diff --git a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/ImportExportTest.php b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/ImportExportTest.php index eac185dcc12..68a4dae5ef0 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/ImportExportTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/ImportExportTest.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\CatalogRule\Test\Unit\Plugin\Indexer; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -13,36 +11,51 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class ImportExportTest extends \PHPUnit_Framework_TestCase { /** + * Indexer processor mock + * * @var \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor|\PHPUnit_Framework_MockObject_MockObject */ protected $ruleProductProcessor; /** + * Import model mock + * * @var \Magento\ImportExport\Model\Import|\PHPUnit_Framework_MockObject_MockObject */ protected $subject; /** + * Tested plugin + * * @var \Magento\CatalogRule\Plugin\Indexer\ImportExport */ protected $plugin; protected function setUp() { - $this->ruleProductProcessor = $this->getMock('Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', - [], [], '', false); + $this->ruleProductProcessor = $this->getMock( + 'Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', + [], + [], + '', + false + ); $this->subject = $this->getMock('Magento\ImportExport\Model\Import', [], [], '', false); - $this->plugin = (new ObjectManager($this))->getObject('Magento\CatalogRule\Plugin\Indexer\ImportExport', [ - 'ruleProductProcessor' => $this->ruleProductProcessor, - ]); + $this->plugin = (new ObjectManager($this))->getObject( + 'Magento\CatalogRule\Plugin\Indexer\ImportExport', + [ + 'ruleProductProcessor' => $this->ruleProductProcessor, + ] + ); } public function testAfterImportSource() { $result = true; - $this->ruleProductProcessor->expects($this->once())->method('markIndexerAsInvalid'); + $this->ruleProductProcessor->expects($this->once()) + ->method('markIndexerAsInvalid'); $this->assertEquals($result, $this->plugin->afterImportSource($this->subject, $result)); } diff --git a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/WebsiteTest.php b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/WebsiteTest.php index 2fca372e8e4..39571d32c38 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/WebsiteTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/WebsiteTest.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\CatalogRule\Test\Unit\Plugin\Indexer; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -13,34 +11,49 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class WebsiteTest extends \PHPUnit_Framework_TestCase { /** + * Indexer processor mock + * * @var \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor|\PHPUnit_Framework_MockObject_MockObject */ protected $ruleProductProcessor; /** + * Website mock + * * @var \Magento\Store\Model\Website|\PHPUnit_Framework_MockObject_MockObject */ protected $subject; /** + * Tested plugin + * * @var \Magento\CatalogRule\Plugin\Indexer\Website */ protected $plugin; protected function setUp() { - $this->ruleProductProcessor = $this->getMock('Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', - [], [], '', false); + $this->ruleProductProcessor = $this->getMock( + 'Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', + [], + [], + '', + false + ); $this->subject = $this->getMock('Magento\Store\Model\Website', [], [], '', false); - $this->plugin = (new ObjectManager($this))->getObject('Magento\CatalogRule\Plugin\Indexer\Website', [ - 'ruleProductProcessor' => $this->ruleProductProcessor, - ]); + $this->plugin = (new ObjectManager($this))->getObject( + 'Magento\CatalogRule\Plugin\Indexer\Website', + [ + 'ruleProductProcessor' => $this->ruleProductProcessor, + ] + ); } public function testAfterDelete() { - $this->ruleProductProcessor->expects($this->once())->method('markIndexerAsInvalid'); + $this->ruleProductProcessor->expects($this->once()) + ->method('markIndexerAsInvalid'); $this->assertEquals($this->subject, $this->plugin->afterDelete($this->subject, $this->subject)); } diff --git a/app/code/Magento/Contact/Test/Unit/Controller/Index/IndexTest.php b/app/code/Magento/Contact/Test/Unit/Controller/Index/IndexTest.php index bb59c0e78c7..ccaec64fabb 100644 --- a/app/code/Magento/Contact/Test/Unit/Controller/Index/IndexTest.php +++ b/app/code/Magento/Contact/Test/Unit/Controller/Index/IndexTest.php @@ -1,32 +1,37 @@ <?php /** - * * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Contact\Test\Unit\Controller\Index; class IndexTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Contact\Controller\Index\Index|\PHPUnit_Framework_MockObject_MockObject + * Controller + * + * @var \Magento\Contact\Controller\Index\Index */ protected $_controller; /** + * Scope config mock + * * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_scopeConfig; /** + * View mock + * * @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_view; /** + * Url mock + * * @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_url; @@ -34,7 +39,10 @@ class IndexTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->_scopeConfig = $this->getMockForAbstractClass( - '\Magento\Framework\App\Config\ScopeConfigInterface', ['isSetFlag'], '', false + '\Magento\Framework\App\Config\ScopeConfigInterface', + ['isSetFlag'], + '', + false ); $context = $this->getMock( '\Magento\Framework\App\Action\Context', diff --git a/app/code/Magento/Contact/Test/Unit/Controller/IndexTest.php b/app/code/Magento/Contact/Test/Unit/Controller/IndexTest.php index 9db82a0300c..609eaddcc4b 100644 --- a/app/code/Magento/Contact/Test/Unit/Controller/IndexTest.php +++ b/app/code/Magento/Contact/Test/Unit/Controller/IndexTest.php @@ -4,18 +4,20 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Contact\Test\Unit\Controller; class IndexTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Contact\Controller\Index|\PHPUnit_Framework_MockObject_MockObject + * Controller instance + * + * @var \Magento\Contact\Controller\Index */ protected $_controller; /** + * Scope config instance + * * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_scopeConfig; @@ -23,7 +25,10 @@ class IndexTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->_scopeConfig = $this->getMockForAbstractClass( - '\Magento\Framework\App\Config\ScopeConfigInterface', ['isSetFlag'], '', false + '\Magento\Framework\App\Config\ScopeConfigInterface', + ['isSetFlag'], + '', + false ); $context = $this->getMock( '\Magento\Framework\App\Action\Context', @@ -33,23 +38,21 @@ class IndexTest extends \PHPUnit_Framework_TestCase false ); - $context->expects( - $this->any() - )->method( - 'getRequest' - )->will( - $this->returnValue($this->getMockForAbstractClass('\Magento\Framework\App\RequestInterface', [], '', false)) - ); + $context->expects($this->any()) + ->method('getRequest') + ->will( + $this->returnValue( + $this->getMockForAbstractClass('\Magento\Framework\App\RequestInterface', [], '', false) + ) + ); - $context->expects( - $this->any() - )->method( - 'getResponse' - )->will( - $this->returnValue( - $this->getMockForAbstractClass('\Magento\Framework\App\ResponseInterface', [], '', false) - ) - ); + $context->expects($this->any()) + ->method('getResponse') + ->will( + $this->returnValue( + $this->getMockForAbstractClass('\Magento\Framework\App\ResponseInterface', [], '', false) + ) + ); $this->_controller = new \Magento\Contact\Controller\Index( $context, @@ -61,20 +64,20 @@ class IndexTest extends \PHPUnit_Framework_TestCase } /** + * Dispatch test + * * @expectedException \Magento\Framework\Exception\NotFoundException */ public function testDispatch() { - $this->_scopeConfig->expects( - $this->once() - )->method( - 'isSetFlag' - )->with( - \Magento\Contact\Controller\Index::XML_PATH_ENABLED, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - )->will( - $this->returnValue(false) - ); + $this->_scopeConfig->expects($this->once()) + ->method('isSetFlag') + ->with( + \Magento\Contact\Controller\Index::XML_PATH_ENABLED, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ) + ->will($this->returnValue(false)); + $this->_controller->dispatch( $this->getMockForAbstractClass('\Magento\Framework\App\RequestInterface', [], '', false) ); diff --git a/app/code/Magento/Contact/Test/Unit/Helper/DataTest.php b/app/code/Magento/Contact/Test/Unit/Helper/DataTest.php index cffd617f422..d95987107eb 100644 --- a/app/code/Magento/Contact/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Contact/Test/Unit/Helper/DataTest.php @@ -4,28 +4,34 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Contact\Test\Unit\Helper; class DataTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Contact\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + * Helper + * + * @var \Magento\Contact\Helper\Data */ protected $_helper; /** + * Scope config mock + * * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_scopeConfig; /** + * Customer session mock + * * @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject */ protected $_customerSession; /** + * Customer view helper mock + * * @var \Magento\Customer\Helper\View|\PHPUnit_Framework_MockObject_MockObject */ protected $_customerViewHelper; @@ -35,7 +41,9 @@ class DataTest extends \PHPUnit_Framework_TestCase $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $className = '\Magento\Contact\Helper\Data'; $arguments = $objectManagerHelper->getConstructArguments($className); - /** @var \Magento\Framework\App\Helper\Context $context */ + /** + * @var \Magento\Framework\App\Helper\Context $context + */ $context = $arguments['context']; $this->_scopeConfig = $context->getScopeConfig(); $this->_customerSession = $arguments['customerSession']; @@ -104,8 +112,12 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->_customerSession->expects($this->once()) ->method('isLoggedIn') ->will($this->returnValue(true)); + $customerDataObject = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); - $customerDataObject->expects($this->once())->method('getEmail')->will($this->returnValue('customer@email.com')); + $customerDataObject->expects($this->once()) + ->method('getEmail') + ->will($this->returnValue('customer@email.com')); + $this->_customerSession->expects($this->once()) ->method('getCustomerDataObject') ->will($this->returnValue($customerDataObject)); diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Processor/InvalidateCacheTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Processor/InvalidateCacheTest.php index 29628de82f5..90c5606b85d 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Processor/InvalidateCacheTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Processor/InvalidateCacheTest.php @@ -4,33 +4,41 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Indexer\Test\Unit\Model\Processor; class InvalidateCacheTest extends \PHPUnit_Framework_TestCase { /** + * Tested plugin + * * @var \Magento\Indexer\Model\Processor\InvalidateCache */ protected $plugin; /** + * Mock for context + * * @var \Magento\Indexer\Model\CacheContext|\PHPUnit_Framework_MockObject_MockObject */ protected $contextMock; /** + * Subject mock + * * @var \Magento\Indexer\Model\ActionInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $subjectMock; /** + * Event manager mock + * * @var \Magento\Framework\Event\Manager|\PHPUnit_Framework_MockObject_MockObject */ protected $eventManagerMock; /** + * Module manager mock + * * @var \Magento\Framework\Module\Manager|\PHPUnit_Framework_MockObject_MockObject */ protected $moduleManager; @@ -40,20 +48,21 @@ class InvalidateCacheTest extends \PHPUnit_Framework_TestCase */ public function setUp() { - $this->subjectMock = $this->getMock('Magento\Indexer\Model\Processor', - [], [], '', false); - $this->contextMock = $this->getMock('Magento\Indexer\Model\CacheContext', - [], [], '', false); - $this->eventManagerMock = $this->getMock('Magento\Framework\Event\Manager', - [], [], '', false); - $this->moduleManager = $this->getMock('Magento\Framework\Module\Manager', - [], [], '', false); + $this->subjectMock = $this->getMock('Magento\Indexer\Model\Processor', [], [], '', false); + $this->contextMock = $this->getMock('Magento\Indexer\Model\CacheContext', [], [], '', false); + $this->eventManagerMock = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false); + $this->moduleManager = $this->getMock('Magento\Framework\Module\Manager', [], [], '', false); $this->plugin = new \Magento\Indexer\Model\Processor\InvalidateCache( - $this->contextMock, $this->eventManagerMock, $this->moduleManager); + $this->contextMock, + $this->eventManagerMock, + $this->moduleManager + ); } /** * Test afterUpdateMview with enabled PageCache module + * + * @return void */ public function testAfterUpdateMviewPageCacheEnabled() { @@ -63,14 +72,17 @@ class InvalidateCacheTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(true)); $this->eventManagerMock->expects($this->once()) ->method('dispatch') - ->with($this->equalTo('clean_cache_after_reindex'), - $this->equalTo(['object' => $this->contextMock])); - $actualResult = $this->plugin->afterUpdateMview($this->subjectMock); - $this->assertNull($actualResult); + ->with( + $this->equalTo('clean_cache_after_reindex'), + $this->equalTo(['object' => $this->contextMock]) + ); + $this->plugin->afterUpdateMview($this->subjectMock); } /** - * afterUpdateMview with disabled PageCache module + * Test afterUpdateMview with disabled PageCache module + * + * @return void */ public function testAfterUpdateMviewPageCacheDisabled() { @@ -80,7 +92,6 @@ class InvalidateCacheTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(false)); $this->eventManagerMock->expects($this->never()) ->method('dispatch'); - $actualResult = $this->plugin->afterUpdateMview($this->subjectMock); - $this->assertNull($actualResult); + $this->plugin->afterUpdateMview($this->subjectMock); } } diff --git a/app/code/Magento/Reports/Block/Adminhtml/Filter/Form.php b/app/code/Magento/Reports/Block/Adminhtml/Filter/Form.php index fa27e2dd1c1..63005ada548 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Filter/Form.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Filter/Form.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Adminhtml\Filter; /** @@ -18,30 +16,31 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic /** * Report type options * - * @var array + * @var [] */ protected $_reportTypeOptions = []; /** * Report field visibility * - * @var array + * @var [] */ protected $_fieldVisibility = []; /** * Report field opions * - * @var array + * @var [] */ protected $_fieldOptions = []; /** * Set field visibility - * @codeCoverageIgnore * * @param string $fieldId * @param bool $visibility + * + * @codeCoverageIgnore * @return void */ public function setFieldVisibility($fieldId, $visibility) @@ -113,7 +112,13 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic /** @var \Magento\Framework\Data\Form $form */ $form = $this->_formFactory->create( - ['data' => ['id' => 'filter_form', 'action' => $actionUrl, 'method' => 'get']] + [ + 'data' => [ + 'id' => 'filter_form', + 'action' => $actionUrl, + 'method' => 'get' + ] + ] ); $htmlIdPrefix = 'sales_report_'; @@ -127,7 +132,11 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic $fieldset->addField( 'report_type', 'select', - ['name' => 'report_type', 'options' => $this->_reportTypeOptions, 'label' => __('Match Period To')] + [ + 'name' => 'report_type', + 'options' => $this->_reportTypeOptions, + 'label' => __('Match Period To') + ] ); $fieldset->addField( diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Grid.php index 3fd93b0d6b1..d47bd96fc9a 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Adminhtml; /** @@ -32,14 +30,14 @@ class Grid extends \Magento\Backend\Block\Widget\Grid /** * Filters array * - * @var array + * @var [] */ protected $_filters = []; /** * Default filters values * - * @var array + * @var [] */ protected $_defaultFilters = ['report_from' => '', 'report_to' => '', 'report_period' => 'day']; @@ -53,7 +51,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid /** * Errors messages aggregated array * - * @var array + * @var [] */ protected $_errors = []; @@ -67,7 +65,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid /** * Filter values array * - * @var array + * @var [] */ protected $_filterValues; @@ -81,7 +79,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid { $filter = $this->getParam($this->getVarNameFilter(), null); - if (is_null($filter)) { + if (null === $filter) { $filter = $this->_defaultFilter; } @@ -154,7 +152,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid /** * Get allowed stores * - * @return array + * @return array|\int[] */ protected function _getAllowedStoreIds() { @@ -203,9 +201,9 @@ class Grid extends \Magento\Backend\Block\Widget\Grid /** * Set visibility of store switcher - * @codeCoverageIgnore * * @param bool $visible + * @codeCoverageIgnore * @return void */ public function setStoreSwitcherVisibility($visible = true) diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php b/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php index 0d457a21808..41a277f9b69 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php @@ -71,6 +71,8 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended } /** + * Pseudo constructor + * * @return void */ protected function _construct() @@ -86,6 +88,8 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended } /** + * Get resource collection name + * * @codeCoverageIgnore * * @return string diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Currency.php b/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Currency.php index ac9cf8c700b..30555dbca8d 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Currency.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Currency.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Adminhtml\Grid\Column\Renderer; /** @@ -24,15 +22,15 @@ class Currency extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Curren public function render(\Magento\Framework\Object $row) { $data = $row->getData($this->getColumn()->getIndex()); - $currency_code = $this->_getCurrencyCode($row); + $currencyCode = $this->_getCurrencyCode($row); - if (!$currency_code) { + if (!$currencyCode) { return $data; } $data = floatval($data) * $this->_getRate($row); $data = sprintf("%f", $data); - $data = $this->_localeCurrency->getCurrency($currency_code)->toCurrency($data); + $data = $this->_localeCurrency->getCurrency($currencyCode)->toCurrency($data); return $data; } } diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced/Grid.php index 414c2e77587..a74edde82b6 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced/Grid.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Adminhtml\Sales\Invoiced; /** @@ -17,12 +15,14 @@ namespace Magento\Reports\Block\Adminhtml\Sales\Invoiced; class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { /** + * GROUP BY condition + * * @var string */ protected $_columnGroupBy = 'period'; /** - * @return void + * {@inheritdoc} */ protected function _construct() { @@ -31,18 +31,17 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid } /** - * @return string + * {@inheritdoc} */ public function getResourceCollectionName() { - return $this->getFilterData()->getData( - 'report_type' - ) == - 'created_at_invoice' ? 'Magento\Sales\Model\Resource\Report\Invoiced\Collection\Invoiced' : 'Magento\Sales\Model\Resource\Report\Invoiced\Collection\Order'; + return ($this->getFilterData()->getData('report_type')) == 'created_at_invoice' + ? 'Magento\Sales\Model\Resource\Report\Invoiced\Collection\Invoiced' + : 'Magento\Sales\Model\Resource\Report\Invoiced\Collection\Order'; } /** - * @return \Magento\Backend\Block\Widget\Grid\Extended + * {@inheritdoc} */ protected function _prepareColumns() { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded/Grid.php index e5f68a315f7..ec6cd002e21 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded/Grid.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Adminhtml\Sales\Refunded; /** @@ -17,12 +15,14 @@ namespace Magento\Reports\Block\Adminhtml\Sales\Refunded; class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { /** + * GROUP BY criteria + * * @var string */ protected $_columnGroupBy = 'period'; /** - * @return void + * {@inheritdoc} */ protected function _construct() { @@ -31,18 +31,17 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid } /** - * @return string + * {@inheritdoc} */ public function getResourceCollectionName() { - return $this->getFilterData()->getData( - 'report_type' - ) == - 'created_at_refunded' ? 'Magento\Sales\Model\Resource\Report\Refunded\Collection\Refunded' : 'Magento\Sales\Model\Resource\Report\Refunded\Collection\Order'; + return $this->getFilterData()->getData('report_type') == 'created_at_refunded' + ? 'Magento\Sales\Model\Resource\Report\Refunded\Collection\Refunded' + : 'Magento\Sales\Model\Resource\Report\Refunded\Collection\Order'; } /** - * @return \Magento\Backend\Block\Widget\Grid\Extended + * {@inheritdoc} */ protected function _prepareColumns() { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php index 012e170b2c2..98e09bede80 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Adminhtml\Sales\Sales; /** @@ -17,12 +15,14 @@ namespace Magento\Reports\Block\Adminhtml\Sales\Sales; class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { /** + * GROUP BY criteria + * * @var string */ protected $_columnGroupBy = 'period'; /** - * @return void + * {@inheritdoc} */ protected function _construct() { @@ -31,18 +31,18 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid } /** - * @return string + * {@inheritdoc} */ public function getResourceCollectionName() { - return $this->getFilterData()->getData( - 'report_type' - ) == - 'updated_at_order' ? 'Magento\Sales\Model\Resource\Report\Order\Updatedat\Collection' : 'Magento\Sales\Model\Resource\Report\Order\Collection'; + return $this->getFilterData()->getData('report_type') == 'updated_at_order' + ? 'Magento\Sales\Model\Resource\Report\Order\Updatedat\Collection' + : 'Magento\Sales\Model\Resource\Report\Order\Collection'; } /** - * @return \Magento\Backend\Block\Widget\Grid\Extended + * {@inheritdoc} + * * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function _prepareColumns() diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping/Grid.php index ee594aaa344..3ce177f0394 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping/Grid.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Adminhtml\Sales\Shipping; /** @@ -17,12 +15,14 @@ namespace Magento\Reports\Block\Adminhtml\Sales\Shipping; class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { /** + * Group by criteria + * * @var string */ protected $_columnGroupBy = 'period'; /** - * @return void + * {@inheritdoc} */ protected function _construct() { @@ -32,18 +32,17 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid } /** - * @return string + * {@inheritdoc} */ public function getResourceCollectionName() { - return $this->getFilterData()->getData( - 'report_type' - ) == - 'created_at_shipment' ? 'Magento\Sales\Model\Resource\Report\Shipping\Collection\Shipment' : 'Magento\Sales\Model\Resource\Report\Shipping\Collection\Order'; + return $this->getFilterData()->getData('report_type') == 'created_at_shipment' + ? 'Magento\Sales\Model\Resource\Report\Shipping\Collection\Shipment' + : 'Magento\Sales\Model\Resource\Report\Shipping\Collection\Order'; } /** - * @return \Magento\Backend\Block\Widget\Grid\Extended + * {@inheritdoc} */ protected function _prepareColumns() { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php index 48c3a647299..c55d866d32c 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Adminhtml\Sales\Tax; /** @@ -17,16 +15,22 @@ namespace Magento\Reports\Block\Adminhtml\Sales\Tax; class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { /** + * GROUP BY criteria + * * @var string */ protected $_columnGroupBy = 'period'; /** + * Config factory + * * @var \Magento\Sales\Model\Order\ConfigFactory */ protected $_configFactory; /** + * Constructor + * * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Reports\Model\Resource\Report\Collection\Factory $resourceFactory @@ -49,7 +53,7 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid } /** - * @return void + * {@inheritdoc} */ protected function _construct() { @@ -59,18 +63,17 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid } /** - * @return string + * {@inheritdoc} */ public function getResourceCollectionName() { - return $this->getFilterData()->getData( - 'report_type' - ) == - 'updated_at_order' ? 'Magento\Tax\Model\Resource\Report\Updatedat\Collection' : 'Magento\Tax\Model\Resource\Report\Collection'; + return $this->getFilterData()->getData('report_type') == 'updated_at_order' + ? 'Magento\Tax\Model\Resource\Report\Updatedat\Collection' + : 'Magento\Tax\Model\Resource\Report\Collection'; } /** - * @return \Magento\Backend\Block\Widget\Grid\Extended + * {@inheritdoc} */ protected function _prepareColumns() { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Wishlist.php b/app/code/Magento/Reports/Block/Adminhtml/Wishlist.php index 690c98b4d69..f810a435a6c 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Wishlist.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Wishlist.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Adminhtml; /** @@ -15,36 +13,6 @@ namespace Magento\Reports\Block\Adminhtml; */ class Wishlist extends \Magento\Backend\Block\Template { - /** - * @var int - */ - public $wishlists_count; - - /** - * @var int - */ - public $items_bought; - - /** - * @var int - */ - public $shared_count; - - /** - * @var int - */ - public $referrals_count; - - /** - * @var int - */ - public $conversions_count; - - /** - * @var int - */ - public $customer_with_wishlist; - /** * @var string */ @@ -58,6 +26,8 @@ class Wishlist extends \Magento\Backend\Block\Template protected $_wishlistFactory; /** + * Constructor + * * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Reports\Model\Resource\Wishlist\CollectionFactory $wishlistFactory * @param array $data @@ -72,9 +42,9 @@ class Wishlist extends \Magento\Backend\Block\Template } /** - * @return $this + * {@inheritdoc} */ - public function _beforeToHtml() + protected function _beforeToHtml() { $this->setChild( 'grid', diff --git a/app/code/Magento/Reports/Block/Product/Compared.php b/app/code/Magento/Reports/Block/Product/Compared.php index 6693d0053ea..67e3d641b82 100644 --- a/app/code/Magento/Reports/Block/Product/Compared.php +++ b/app/code/Magento/Reports/Block/Product/Compared.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Product; /** @@ -15,6 +13,9 @@ namespace Magento\Reports\Block\Product; */ class Compared extends \Magento\Reports\Block\Product\AbstractProduct { + /** + * Config path for compared products count + */ const XML_PATH_RECENTLY_COMPARED_COUNT = 'catalog/recently_products/compared_count'; /** @@ -34,7 +35,10 @@ class Compared extends \Magento\Reports\Block\Product\AbstractProduct if ($this->hasData('page_size')) { return $this->getData('page_size'); } - return $this->_scopeConfig->getValue(self::XML_PATH_RECENTLY_COMPARED_COUNT, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); + return $this->_scopeConfig->getValue( + self::XML_PATH_RECENTLY_COMPARED_COUNT, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); } /** diff --git a/app/code/Magento/Reports/Block/Product/Viewed.php b/app/code/Magento/Reports/Block/Product/Viewed.php index 947c90c8950..9e03d65dd7c 100644 --- a/app/code/Magento/Reports/Block/Product/Viewed.php +++ b/app/code/Magento/Reports/Block/Product/Viewed.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Product; /** @@ -13,8 +11,12 @@ namespace Magento\Reports\Block\Product; * * @author Magento Core Team <core@magentocommerce.com> */ -class Viewed extends \Magento\Reports\Block\Product\AbstractProduct implements \Magento\Framework\Object\IdentityInterface +class Viewed extends \Magento\Reports\Block\Product\AbstractProduct + implements \Magento\Framework\Object\IdentityInterface { + /** + * Config path to recently viewed product count + */ const XML_PATH_RECENTLY_VIEWED_COUNT = 'catalog/recently_products/viewed_count'; /** @@ -34,7 +36,10 @@ class Viewed extends \Magento\Reports\Block\Product\AbstractProduct implements \ if ($this->hasData('page_size')) { return $this->getData('page_size'); } - return $this->_scopeConfig->getValue(self::XML_PATH_RECENTLY_VIEWED_COUNT, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); + return $this->_scopeConfig->getValue( + self::XML_PATH_RECENTLY_VIEWED_COUNT, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); } /** diff --git a/app/code/Magento/Reports/Helper/Data.php b/app/code/Magento/Reports/Helper/Data.php index b81544d5e7a..c33b0791a55 100644 --- a/app/code/Magento/Reports/Helper/Data.php +++ b/app/code/Magento/Reports/Helper/Data.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - /** * Reports data helper */ @@ -23,16 +21,22 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper const REPORT_PERIOD_TYPE_YEAR = 'year'; /** + * Item factory + * * @var \Magento\Reports\Model\ItemFactory */ protected $_itemFactory; /** + * Constructor + * * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Reports\Model\ItemFactory $itemFactory */ - public function __construct(\Magento\Framework\App\Helper\Context $context, \Magento\Reports\Model\ItemFactory $itemFactory) - { + public function __construct( + \Magento\Framework\App\Helper\Context $context, + \Magento\Reports\Model\ItemFactory $itemFactory + ) { parent::__construct($context); $this->_itemFactory = $itemFactory; } diff --git a/app/code/Magento/Reports/Model/Resource/Order/Collection.php b/app/code/Magento/Reports/Model/Resource/Order/Collection.php index 60b24016381..5ab7ce03f2e 100644 --- a/app/code/Magento/Reports/Model/Resource/Order/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Order/Collection.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Model\Resource\Order; use Magento\Framework\DB\Select; @@ -40,26 +38,36 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection protected $_scopeConfig; /** + * Store manager instance + * * @var \Magento\Store\Model\StoreManagerInterface */ protected $_storeManager; /** + * Locale date instance + * * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface */ protected $_localeDate; /** + * Order config instance + * * @var \Magento\Sales\Model\Order\Config */ protected $_orderConfig; /** + * Reports order factory + * * @var \Magento\Sales\Model\Resource\Report\OrderFactory */ protected $_reportOrderFactory; /** + * Constructor + * * @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory * @param \Psr\Log\LoggerInterface $logger * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy @@ -162,7 +170,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection */ protected function _getSalesAmountExpression() { - if (is_null($this->_salesAmountExpression)) { + if (null === $this->_salesAmountExpression) { $adapter = $this->getConnection(); $expressionTransferObject = new \Magento\Framework\Object( [ @@ -257,8 +265,8 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * Prepare report summary from aggregated data * * @param string $range - * @param mixed $customStart - * @param mixed $customEnd + * @param string|null $customStart + * @param string|null $customEnd * @return $this */ protected function _prepareSummaryAggregated($range, $customStart, $customEnd) @@ -271,13 +279,13 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection $rangePeriod = $this->_getRangeExpressionForAttribute($range, 'main_table.period'); $tableName = $this->getConnection()->quoteIdentifier('main_table.period'); - $rangePeriod2 = str_replace($tableName, "MIN({$tableName})", $rangePeriod); + $rangePeriodAggregateStmt = str_replace($tableName, "MIN({$tableName})", $rangePeriod); $this->getSelect()->columns( [ 'revenue' => 'SUM(main_table.total_revenue_amount)', 'quantity' => 'SUM(main_table.orders_count)', - 'range' => $rangePeriod2, + 'range' => $rangePeriodAggregateStmt, ] )->order( 'range' @@ -349,8 +357,8 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * * @param string $range * @param string $attribute - * @param mixed $from - * @param mixed $to + * @param string|null $from + * @param string|null $to * @return string */ protected function _getTZRangeOffsetExpression($range, $attribute, $from = null, $to = null) @@ -665,7 +673,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection /** * Set store filter collection * - * @param array $storeIds + * @param int[] $storeIds * @return $this */ public function setStoreIds($storeIds) @@ -778,16 +786,15 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection */ public function addSumAvgTotals($storeId = 0) { - $adapter = $this->getConnection(); - $baseSubtotalRefunded = $adapter->getIfNullSql('main_table.base_subtotal_refunded', 0); - $baseSubtotalCanceled = $adapter->getIfNullSql('main_table.base_subtotal_canceled', 0); - $baseDiscountCanceled = $adapter->getIfNullSql('main_table.base_discount_canceled', 0); - /** * calculate average and total amount */ - $expr = $storeId == - 0 ? "(main_table.base_subtotal -\n {$baseSubtotalRefunded} - {$baseSubtotalCanceled} - ABS(main_table.base_discount_amount) -\n {$baseDiscountCanceled}) * main_table.base_to_global_rate" : "main_table.base_subtotal - {$baseSubtotalCanceled} - {$baseSubtotalRefunded} -\n ABS(main_table.base_discount_amount) - {$baseDiscountCanceled}"; + $expr = $this->getTotalsExpression( + $storeId, + $this->getConnection()->getIfNullSql('main_table.base_subtotal_refunded', 0), + $this->getConnection()->getIfNullSql('main_table.base_subtotal_canceled', 0), + $this->getConnection()->getIfNullSql('main_table.base_discount_canceled', 0) + ); $this->getSelect()->columns( ['orders_avg_amount' => "AVG({$expr})"] @@ -798,6 +805,28 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection return $this; } + /** + * Get SQL expression for totals + * + * @param int $storeId + * @param string $baseSubtotalRefunded + * @param string $baseSubtotalCanceled + * @param string $baseDiscountCanceled + * @return string + */ + protected function getTotalsExpression( + $storeId, + $baseSubtotalRefunded, + $baseSubtotalCanceled, + $baseDiscountCanceled + ) { + $template = ($storeId != 0) + ? 'main_table.base_subtotal - %2$s - %1$s - ABS(main_table.base_discount_amount) - %3$s' + : '(main_table.base_subtotal - %1$s - %2$s - ABS(main_table.base_discount_amount) - %3$s) ' + . ' * main_table.base_to_global_rate'; + return sprintf($template, $baseSubtotalRefunded, $baseSubtotalCanceled, $baseDiscountCanceled); + } + /** * Sort order by total amount * @@ -869,6 +898,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * Initialize initial fields to select * * @return $this + * @codeCoverageIgnore */ protected function _initInitialFieldsToSelect() { diff --git a/app/code/Magento/Reports/Model/Resource/Product/Index/AbstractIndex.php b/app/code/Magento/Reports/Model/Resource/Product/Index/AbstractIndex.php index 52d72406cb1..45b1c2c5e9d 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Index/AbstractIndex.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Index/AbstractIndex.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Model\Resource\Product\Index; /** @@ -14,16 +12,22 @@ namespace Magento\Reports\Model\Resource\Product\Index; abstract class AbstractIndex extends \Magento\Framework\Model\Resource\Db\AbstractDb { /** + * DateItime instance + * * @var \Magento\Framework\Stdlib\DateTime */ protected $dateTime; /** + * Reports helper + * * @var \Magento\Reports\Model\Resource\Helper */ protected $_resourceHelper; /** + * Constructor + * * @param \Magento\Framework\Model\Resource\Db\Context $context * @param \Magento\Reports\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Stdlib\DateTime $dateTime @@ -55,7 +59,9 @@ abstract class AbstractIndex extends \Magento\Framework\Model\Resource\Db\Abstra return $this; } $adapter = $this->_getWriteAdapter(); - $select = $adapter->select()->from($this->getMainTable())->where('visitor_id = ?', $object->getVisitorId()); + $select = $adapter->select() + ->from($this->getMainTable()) + ->where('visitor_id = ?', $object->getVisitorId()); $rowSet = $select->query()->fetchAll(); foreach ($rowSet as $row) { @@ -76,7 +82,7 @@ abstract class AbstractIndex extends \Magento\Framework\Model\Resource\Db\Abstra if ($idx) { /** - * If we are here it means that we have two rows: one with known customer, but second just visitor is set + * If we are here it means that we have two rows: one with known customer and second with guest visitor * One row should be updated with customer_id, second should be deleted */ $adapter->delete($this->getMainTable(), ['index_id = ?' => $row['index_id']]); @@ -192,7 +198,7 @@ abstract class AbstractIndex extends \Magento\Framework\Model\Resource\Db\Abstra * Add information about product ids to visitor/customer * * @param \Magento\Framework\Object|\Magento\Reports\Model\Product\Index\AbstractIndex $object - * @param array $productIds + * @param int[] $productIds * @return $this */ public function registerIds(\Magento\Framework\Object $object, $productIds) diff --git a/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php b/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php index 84a6d7d6a25..777d13232b2 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php +++ b/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Model\Resource\Report; /** @@ -22,21 +20,29 @@ abstract class AbstractReport extends \Magento\Framework\Model\Resource\Db\Abstr protected $_flag = null; /** + * Logger instance + * * @var \Psr\Log\LoggerInterface */ protected $_logger; /** + * Locale date instance + * * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface */ protected $_localeDate; /** + * Reports flag factory + * * @var \Magento\Reports\Model\FlagFactory */ protected $_reportsFlagFactory; /** + * Constructor + * * @param \Magento\Framework\Model\Resource\Db\Context $context * @param \Psr\Log\LoggerInterface $logger * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate @@ -179,7 +185,7 @@ abstract class AbstractReport extends \Magento\Framework\Model\Resource\Db\Abstr * @param string $whereColumn * @param null|string|\DateTime $from * @param null|string|\DateTime $to - * @param array $additionalWhere + * @param [][] $additionalWhere * @param string $alias * @return \Magento\Framework\DB\Select */ @@ -281,12 +287,12 @@ abstract class AbstractReport extends \Magento\Framework\Model\Resource\Db\Abstr * * @param string $table * @param string $relatedTable - * @param array $joinCondition + * @param [] $joinCondition * @param string $column * @param string $whereColumn * @param string|null $from * @param string|null $to - * @param array $additionalWhere + * @param [][] $additionalWhere * @param string $alias * @param string $relatedAlias * @return \Magento\Framework\DB\Select @@ -353,7 +359,7 @@ abstract class AbstractReport extends \Magento\Framework\Model\Resource\Db\Abstr /** * Retrieve query for attribute with timezone conversion * - * @param string|array $table + * @param string|[] $table * @param string $column * @param null|mixed $from * @param null|mixed $to diff --git a/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php b/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php index 56e658e56db..432ebc9b5d4 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php +++ b/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - /** * Most viewed product report aggregate resource model * @@ -31,16 +29,22 @@ class Viewed extends \Magento\Sales\Model\Resource\Report\AbstractReport const AGGREGATION_YEARLY = 'report_viewed_product_aggregated_yearly'; /** + * Product resource instance + * * @var \Magento\Catalog\Model\Resource\Product */ protected $_productResource; /** + * Resource helper instance + * * @var \Magento\Reports\Model\Resource\Helper */ protected $_resourceHelper; /** + * Constructor + * * @param \Magento\Framework\Model\Resource\Db\Context $context * @param \Psr\Log\LoggerInterface $logger * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate diff --git a/app/code/Magento/Reports/Setup/InstallData.php b/app/code/Magento/Reports/Setup/InstallData.php index 071ed7c2964..fef292ffb21 100644 --- a/app/code/Magento/Reports/Setup/InstallData.php +++ b/app/code/Magento/Reports/Setup/InstallData.php @@ -7,8 +7,6 @@ namespace Magento\Reports\Setup; -// @codingStandardsIgnoreFile - use Magento\Cms\Model\PageFactory; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; @@ -82,11 +80,13 @@ class InstallData implements \Magento\Framework\Setup\InstallDataInterface $cms = $this->pageFactory->create(); $cms->load('home', 'identifier'); + // @codingStandardsIgnoreStart $reportLayoutUpdate = '<!-- <referenceContainer name="right"> <action method="unsetChild"><argument name="alias" xsi:type="string">right.reports.product.viewed</argument></action> <action method="unsetChild"><argument name="alias" xsi:type="string">right.reports.product.compared</argument></action> </referenceContainer>-->'; + // @codingStandardsIgnoreEnd /* * Merge and save old layout update data with report layout data diff --git a/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/Collection/AbstractCollectionTest.php b/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/Collection/AbstractCollectionTest.php index 96ad13c9b21..ed5075a8bf7 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/Collection/AbstractCollectionTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/Collection/AbstractCollectionTest.php @@ -4,16 +4,16 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Test\Unit\Model\Resource\Report\Collection; class AbstractCollectionTest extends \PHPUnit_Framework_TestCase { /** - * @var AbstractCollection + * Tested collection + * + * @var \Magento\Reports\Model\Resource\Report\Collection\AbstractCollection */ - protected $_model; + protected $collection; protected function setUp() { @@ -29,7 +29,7 @@ class AbstractCollectionTest extends \PHPUnit_Framework_TestCase ->getMockForAbstractClass(); $resource->method('getReadConnection')->willReturn($connection); - $this->_model = new \Magento\Reports\Model\Resource\Report\Collection\AbstractCollection( + $this->collection = new \Magento\Reports\Model\Resource\Report\Collection\AbstractCollection( $entityFactory, $logger, $fetchStrategy, @@ -41,15 +41,15 @@ class AbstractCollectionTest extends \PHPUnit_Framework_TestCase public function testIsSubtotalsGetDefault() { - $this->assertFalse($this->_model->isSubTotals()); + $this->assertFalse($this->collection->isSubTotals()); } public function testSetIsSubtotals() { - $this->_model->setIsSubTotals(true); - $this->assertTrue($this->_model->isSubTotals()); + $this->collection->setIsSubTotals(true); + $this->assertTrue($this->collection->isSubTotals()); - $this->_model->setIsSubTotals(false); - $this->assertFalse($this->_model->isSubTotals()); + $this->collection->setIsSubTotals(false); + $this->assertFalse($this->collection->isSubTotals()); } } diff --git a/app/code/Magento/Rule/Model/AbstractModel.php b/app/code/Magento/Rule/Model/AbstractModel.php index 8aedb81590e..e343115e297 100644 --- a/app/code/Magento/Rule/Model/AbstractModel.php +++ b/app/code/Magento/Rule/Model/AbstractModel.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - /** * Abstract Rule entity data model */ @@ -63,16 +61,22 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractModel abstract public function getActionsInstance(); /** + * Form factory + * * @var \Magento\Framework\Data\FormFactory */ protected $_formFactory; /** + * Timezone instance + * * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface */ protected $_localeDate; /** + * Constructor + * * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Data\FormFactory $formFactory diff --git a/app/code/Magento/Rule/Test/Unit/Model/Condition/Product/AbstractProductTest.php b/app/code/Magento/Rule/Test/Unit/Model/Condition/Product/AbstractProductTest.php index 32d0b012c88..41b09160214 100644 --- a/app/code/Magento/Rule/Test/Unit/Model/Condition/Product/AbstractProductTest.php +++ b/app/code/Magento/Rule/Test/Unit/Model/Condition/Product/AbstractProductTest.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Rule\Test\Unit\Model\Condition\Product; use ReflectionMethod; @@ -14,24 +12,30 @@ use ReflectionProperty; class AbstractProductTest extends \PHPUnit_Framework_TestCase { /** - * @var AbstractProduct|\PHPUnit_Framework_MockObject_MockObject + * Tested condition + * + * @var \Magento\Rule\Model\Condition\Product\AbstractProduct|\PHPUnit_Framework_MockObject_MockObject */ protected $_condition; /** + * Framework object + * * @var \Magento\Framework\Object|\PHPUnit_Framework_MockObject_MockObject */ protected $_object; /** + * Reflection for Magento\Rule\Model\Condition\Product\AbstractProduct::$_entityAttributeValues + * * @var \ReflectionProperty - * 'Magento\Rule\Model\Condition\Product\AbstractProduct::_entityAttributeValues' */ protected $_entityAttributeValuesProperty; /** + * Reflection for Magento\Rule\Model\Condition\Product\AbstractProduct::$_config + * * @var \ReflectionProperty - * 'Magento\Rule\Model\Condition\Product\AbstractProduct::_config' */ protected $_configProperty; @@ -306,7 +310,7 @@ class AbstractProductTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); $attrObjectSourceMock - ->expects(is_null($expectedAttrObjSourceAllOptionsParam) ? $this->never() : $this->once()) + ->expects((null === $expectedAttrObjSourceAllOptionsParam) ? $this->never() : $this->once()) ->method('getAllOptions') ->with($expectedAttrObjSourceAllOptionsParam) ->willReturn($attrObjectSourceAllOptionsValue); @@ -317,7 +321,7 @@ class AbstractProductTest extends \PHPUnit_Framework_TestCase ->getMock(); $attributeObjectMock->method('usesSource')->willReturn(true); $attributeObjectMock - ->expects(is_null($attributeObjectFrontendInput) ? $this->never() : $this->once()) + ->expects((null === $attributeObjectFrontendInput) ? $this->never() : $this->once()) ->method('getFrontendInput') ->willReturn($attributeObjectFrontendInput); $attributeObjectMock->method('getSource')->willReturn($attrObjectSourceMock); @@ -345,12 +349,14 @@ class AbstractProductTest extends \PHPUnit_Framework_TestCase $attrSetCollectionValueMock->method('setEntityTypeFilter')->will($this->returnSelf()); $attrSetCollectionValueMock->method('load')->will($this->returnSelf()); $attrSetCollectionValueMock - ->expects(is_null($attrSetCollectionOptionsArray) ? $this->never() : $this->once()) + ->expects((null === $attrSetCollectionOptionsArray) ? $this->never() : $this->once()) ->method('toOptionArray') ->willReturn($attrSetCollectionOptionsArray); - $attrSetCollectionProperty = - new ReflectionProperty('Magento\Rule\Model\Condition\Product\AbstractProduct', '_attrSetCollection'); + $attrSetCollectionProperty = new ReflectionProperty( + 'Magento\Rule\Model\Condition\Product\AbstractProduct', + '_attrSetCollection' + ); $attrSetCollectionProperty->setAccessible(true); $attrSetCollectionProperty->setValue($this->_condition, $attrSetCollectionValueMock); @@ -366,6 +372,8 @@ class AbstractProductTest extends \PHPUnit_Framework_TestCase } /** + * Data provider for prepare value options + * * @return array * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ -- GitLab