Skip to content

Commit

Permalink
MAGETWO-67711: Fixed coding standard violations in the Framework\App …
Browse files Browse the repository at this point in the history
…namespace #9350
  • Loading branch information
Oleksii Korshenko authored Apr 22, 2017
2 parents 20f64b4 + f096ee6 commit cb52dee
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 66 deletions.
27 changes: 27 additions & 0 deletions lib/internal/Magento/Framework/App/Test/Unit/Action/ActionFake.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Framework\App\Test\Unit\Action;

use \Magento\Framework\App\Action\Action;

class ActionFake extends Action
{
/**
* Fake action to check a method call from a parent
*/
public function execute()
{
$this->_forward(
ActionTest::ACTION_NAME,
ActionTest::CONTROLLER_NAME,
ActionTest::MODULE_NAME,
ActionTest::$actionParams
);
$this->_redirect(ActionTest::FULL_ACTION_NAME, ActionTest::$actionParams);
return;
}
}
19 changes: 0 additions & 19 deletions lib/internal/Magento/Framework/App/Test/Unit/Action/ActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

namespace Magento\Framework\App\Test\Unit\Action;

use \Magento\Framework\App\Action\Action;
Expand Down Expand Up @@ -185,20 +183,3 @@ public function testDispatchPostDispatch()
$this->assertEquals($this->_responseMock, $this->action->dispatch($this->_requestMock));
}
}

class ActionFake extends Action
{
/**
* Fake action to check a method call from a parent
*/
public function execute()
{
$this->_forward(
ActionTest::ACTION_NAME,
ActionTest::CONTROLLER_NAME,
ActionTest::MODULE_NAME,
ActionTest::$actionParams);
$this->_redirect(ActionTest::FULL_ACTION_NAME, ActionTest::$actionParams);
return;
}
}
29 changes: 18 additions & 11 deletions lib/internal/Magento/Framework/App/Test/Unit/AreaListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

namespace Magento\Framework\App\Test\Unit;

use \Magento\Framework\App\AreaList;
Expand Down Expand Up @@ -48,12 +46,12 @@ public function testGetCodeByFrontNameWhenAreaDoesNotContainFrontName()
$this->_resolverFactory->expects(
$this->any()
)->method(
'create'
)->with(
'testValue'
)->will(
$this->returnValue($resolverMock)
);
'create'
)->with(
'testValue'
)->will(
$this->returnValue($resolverMock)
);

$actual = $this->_model->getCodeByFrontName('testFrontName');
$this->assertEquals($expected, $actual);
Expand Down Expand Up @@ -106,7 +104,10 @@ public function testGetCodes()
{
$areas = ['area1' => 'value1', 'area2' => 'value2'];
$this->_model = new \Magento\Framework\App\AreaList(
$this->objectManagerMock, $this->_resolverFactory, $areas, ''
$this->objectManagerMock,
$this->_resolverFactory,
$areas,
''
);

$expected = array_keys($areas);
Expand All @@ -118,7 +119,10 @@ public function testGetDefaultRouter()
{
$areas = ['area1' => ['router' => 'value1'], 'area2' => 'value2'];
$this->_model = new \Magento\Framework\App\AreaList(
$this->objectManagerMock, $this->_resolverFactory, $areas, ''
$this->objectManagerMock,
$this->_resolverFactory,
$areas,
''
);

$this->assertEquals($this->_model->getDefaultRouter('area1'), $areas['area1']['router']);
Expand All @@ -131,7 +135,10 @@ public function testGetArea()
$objectManagerMock = $this->getObjectManagerMockGetArea();
$areas = ['area1' => ['router' => 'value1'], 'area2' => 'value2'];
$this->_model = new AreaList(
$objectManagerMock, $this->_resolverFactory, $areas, ''
$objectManagerMock,
$this->_resolverFactory,
$areas,
''
);

$this->assertEquals($this->_model->getArea('testArea'), 'ok');
Expand Down
32 changes: 24 additions & 8 deletions lib/internal/Magento/Framework/App/Test/Unit/BootstrapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

namespace Magento\Framework\App\Test\Unit;

use Magento\Framework\App\Bootstrap;
Expand Down Expand Up @@ -85,9 +83,27 @@ protected function setUp()
'',
false
);
$this->maintenanceMode = $this->getMock(\Magento\Framework\App\MaintenanceMode::class, ['isOn'], [], '', false);
$this->remoteAddress = $this->getMock('Magento\Framework\HTTP\PhpEnvironment\RemoteAddress', [], [], '', false);
$filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false);
$this->maintenanceMode = $this->getMock(
\Magento\Framework\App\MaintenanceMode::class,
['isOn'],
[],
'',
false
);
$this->remoteAddress = $this->getMock(
\Magento\Framework\HTTP\PhpEnvironment\RemoteAddress::class,
[],
[],
'',
false
);
$filesystem = $this->getMock(
\Magento\Framework\Filesystem::class,
[],
[],
'',
false
);

$this->logger = $this->getMock(\Psr\Log\LoggerInterface::class);

Expand All @@ -99,7 +115,7 @@ protected function setUp()
[\Magento\Framework\HTTP\PhpEnvironment\RemoteAddress::class, $this->remoteAddress],
[\Magento\Framework\Filesystem::class, $filesystem],
[\Magento\Framework\App\DeploymentConfig::class, $this->deploymentConfig],
['Psr\Log\LoggerInterface', $this->logger],
[\Psr\Log\LoggerInterface::class, $this->logger],
];

$this->objectManager->expects($this->any())->method('get')
Expand Down Expand Up @@ -211,7 +227,7 @@ public function testIsDeveloperModeDataProvider()
[State::MODE_DEVELOPER, State::MODE_PRODUCTION, true],
[State::MODE_PRODUCTION, State::MODE_DEVELOPER, false],
[null, State::MODE_DEVELOPER, true],
[null, State::MODE_PRODUCTION, false],
[null, State::MODE_PRODUCTION, false]
];
}

Expand Down Expand Up @@ -280,7 +296,7 @@ public function assertMaintenanceDataProvider()
{
return [
[true, false],
[false, true],
[false, true]
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

namespace Magento\Framework\App\Test\Unit\ObjectManager;

use Magento\Framework\Serialize\SerializerInterface;
Expand Down Expand Up @@ -55,15 +53,18 @@ protected function setUp()
false
);

$this->readerFactoryMock->expects(
$this->any()
)->method(
'create'
)->will(
$this->returnValue($this->readerMock)
$this->readerFactoryMock->expects($this->any())
->method('create')
->will($this->returnValue($this->readerMock));

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

$this->cacheMock = $this->getMock(\Magento\Framework\App\Cache\Type\Config::class, [], [], '', false);
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);

$this->object = $objectManagerHelper->getObject(
Expand Down Expand Up @@ -98,7 +99,10 @@ public function testLoadNotCached($area)
$this->cacheMock->expects($this->once())
->method('save')
->with($serializedData);
$this->readerMock->expects($this->once())->method('read')->with($area)->will($this->returnValue($configData));
$this->readerMock->expects($this->once())
->method('read')
->with($area)
->will($this->returnValue($configData));

$this->serializerMock->expects($this->once())
->method('serialize')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

namespace Magento\Framework\App\Test\Unit\Request;

use Magento\Framework\App\Config\ScopeConfigInterface;
Expand Down Expand Up @@ -345,8 +343,10 @@ public function testIsSecure($isSecure, $serverHttps, $headerOffloadKey, $header
->getMock();
$configMock->expects($this->exactly($configCall))
->method('getValue')
->with(\Magento\Framework\App\Request\Http::XML_PATH_OFFLOADER_HEADER, ScopeConfigInterface::SCOPE_TYPE_DEFAULT)
->willReturn($configOffloadHeader);
->with(
\Magento\Framework\App\Request\Http::XML_PATH_OFFLOADER_HEADER,
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
)->willReturn($configOffloadHeader);

$this->objectManager->setBackwardCompatibleProperty($this->_model, 'appConfig', $configMock);
$this->objectManager->setBackwardCompatibleProperty($this->_model, 'sslOffloadHeader', null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

namespace Magento\Framework\App\Test\Unit\Response;

use \Magento\Framework\App\Response\Http;
Expand Down Expand Up @@ -53,7 +51,8 @@ protected function setUp()
)->disableOriginalConstructor()->getMock();
$this->cookieManagerMock = $this->getMock(\Magento\Framework\Stdlib\CookieManagerInterface::class);
$this->contextMock = $this->getMockBuilder(
\Magento\Framework\App\Http\Context::class)->disableOriginalConstructor()
\Magento\Framework\App\Http\Context::class
)->disableOriginalConstructor()
->getMock();

$this->dateTimeMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime::class)
Expand Down Expand Up @@ -87,7 +86,8 @@ public function testSendVary()
$expectedCookieName = Http::COOKIE_VARY_STRING;
$expectedCookieValue = 'SHA1 Serialized String';
$sensitiveCookieMetadataMock = $this->getMockBuilder(
\Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata::class)
\Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata::class
)
->disableOriginalConstructor()
->getMock();
$sensitiveCookieMetadataMock->expects($this->once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

namespace Magento\Framework\App\Test\Unit\Router;

class NoRouteHandlerListTest extends \PHPUnit_Framework_TestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

namespace Magento\Framework\App\Test\Unit\Router;

class NoRouteHandlerTest extends \Magento\Framework\TestFramework\Unit\BaseTestCase
Expand Down
2 changes: 0 additions & 2 deletions lib/internal/Magento/Framework/App/Test/Unit/StateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

namespace Magento\Framework\App\Test\Unit;

use \Magento\Framework\App\Area;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

namespace Magento\Framework\App\Test\Unit;

use Magento\Framework\App\Bootstrap;
Expand Down Expand Up @@ -77,7 +75,11 @@ protected function setUp()
$this->objectManager = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class);
$this->logger = $this->getMockForAbstractClass(\Psr\Log\LoggerInterface::class);
$this->configLoader = $this->getMock(
\Magento\Framework\App\ObjectManager\ConfigLoader::class, [], [], '', false
\Magento\Framework\App\ObjectManager\ConfigLoader::class,
[],
[],
'',
false
);
$this->object = new \Magento\Framework\App\StaticResource(
$this->state,
Expand Down Expand Up @@ -204,7 +206,7 @@ public function testCatchExceptionDeveloperMode()
{
$this->objectManager->expects($this->once())
->method('get')
->with('Psr\Log\LoggerInterface')
->with(\Psr\Log\LoggerInterface::class)
->willReturn($this->logger);
$this->logger->expects($this->once())
->method('critical');
Expand Down

0 comments on commit cb52dee

Please sign in to comment.