Skip to content

Commit

Permalink
Fix to make sure the module will work with Magento 2.1 and 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
shochdoerfer committed Dec 26, 2017
1 parent 00db470 commit 52a1419
Show file tree
Hide file tree
Showing 4 changed files with 528 additions and 449 deletions.
36 changes: 8 additions & 28 deletions Controller/LoginRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@

use BitExpert\ForceCustomerLogin\Api\Controller\LoginCheckInterface;
use Magento\Framework\App\ActionFactory;
use Magento\Framework\App\Router\Base;
use Magento\Framework\App\RouterInterface;

/**
* Class LoginRouter
*
* @package BitExpert\ForceCustomerLogin\Controller
*/
class LoginRouter extends Base
class LoginRouter implements RouterInterface
{
/**
* @var ActionFactory
*/
private $actionFactory;
/**
* @var LoginCheck
*/
Expand All @@ -30,39 +34,15 @@ class LoginRouter extends Base
/**
* LoginRouter constructor.
*
* @param \Magento\Framework\App\Router\ActionList $actionList
* @param ActionFactory $actionFactory
* @param \Magento\Framework\App\DefaultPathInterface $defaultPath
* @param \Magento\Framework\App\ResponseFactory $responseFactory
* @param \Magento\Framework\App\Route\ConfigInterface $routeConfig
* @param \Magento\Framework\UrlInterface $url
* @param \Magento\Framework\Code\NameBuilder $nameBuilder
* @param \Magento\Framework\App\Router\PathConfigInterface $pathConfig
* @param LoginCheckInterface $loginCheck
* @throws \InvalidArgumentException
*/
public function __construct(
\Magento\Framework\App\Router\ActionList $actionList,
\Magento\Framework\App\ActionFactory $actionFactory,
\Magento\Framework\App\DefaultPathInterface $defaultPath,
\Magento\Framework\App\ResponseFactory $responseFactory,
\Magento\Framework\App\Route\ConfigInterface $routeConfig,
\Magento\Framework\UrlInterface $url,
\Magento\Framework\Code\NameBuilder $nameBuilder,
\Magento\Framework\App\Router\PathConfigInterface $pathConfig,
ActionFactory $actionFactory,
LoginCheckInterface $loginCheck
) {
parent::__construct(
$actionList,
$actionFactory,
$defaultPath,
$responseFactory,
$routeConfig,
$url,
$nameBuilder,
$pathConfig
);

$this->actionFactory = $actionFactory;
$this->loginCheck = $loginCheck;
}

Expand Down
76 changes: 0 additions & 76 deletions Test/Unit/Controller/LoginRouterUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,7 @@ public function runRedirectRoutingOnlyIfLoginCheckHasExecutedSuccessfully()
->willReturn(true);

$loginRouter = new \BitExpert\ForceCustomerLogin\Controller\LoginRouter(
$this->getActionList(),
$actionFactory,
$this->getDefaultPath(),
$this->getResponseFactory(),
$this->getConfig(),
$this->getUrl(),
$this->getNameBuilder(),
$this->getPathConfig(),
$loginCheck
);

Expand Down Expand Up @@ -95,68 +88,6 @@ protected function getLoginCheck()
return $this->createMock('\BitExpert\ForceCustomerLogin\Api\Controller\LoginCheckInterface');
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\Router\ActionList
*/
protected function getActionList()
{
return $this->getMockBuilder('\Magento\Framework\App\Router\ActionList')
->disableOriginalConstructor()
->getMock();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\DefaultPathInterface
*/
protected function getDefaultPath()
{
return $this->createMock('\Magento\Framework\App\DefaultPathInterface');
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\ResponseFactory
*/
protected function getResponseFactory()
{
return $this->getMockBuilder('\Magento\Framework\App\ResponseFactory')
->disableOriginalConstructor()
->getMock();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\Route\ConfigInterface
*/
protected function getConfig()
{
return $this->createMock('\Magento\Framework\App\Route\ConfigInterface');
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\UrlInterface
*/
protected function getUrl()
{
return $this->createMock('\Magento\Framework\UrlInterface');
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Code\NameBuilder
*/
protected function getNameBuilder()
{
return $this->getMockBuilder('\Magento\Framework\Code\NameBuilder')
->disableOriginalConstructor()
->getMock();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\Router\PathConfigInterface
*/
protected function getPathConfig()
{
return $this->createMock('\Magento\Framework\App\Router\PathConfigInterface');
}

/**
* @test
* @depends testClassExists
Expand All @@ -175,14 +106,7 @@ public function skipRedirectRoutingIfLoginCheckHasNotBeenExecuted()
->willReturn(false);

$loginRouter = new \BitExpert\ForceCustomerLogin\Controller\LoginRouter(
$this->getActionList(),
$actionFactory,
$this->getDefaultPath(),
$this->getResponseFactory(),
$this->getConfig(),
$this->getUrl(),
$this->getNameBuilder(),
$this->getPathConfig(),
$loginCheck
);

Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "bitexpert/magento2-force-customer-login",
"description": "The Force Login module for Magento2 redirects a storefront visitor to the Magento2 Frontend login page, if the visitor is not logged in. It is possible to configure the whitelisted urls to add custom definitions.",
"type": "magento2-module",
"version": "3.0.0",
"minimum-stability": "stable",
"license": "Apache-2.0",
"authors": [
Expand All @@ -17,7 +18,8 @@
}
],
"require": {
"magento/module-customer": "~101.0"
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6|~7.1.0",
"magento/module-customer": "~100.1|~101.0"
},
"require-dev": {
"squizlabs/php_codesniffer": "~2.0",
Expand Down
Loading

0 comments on commit 52a1419

Please sign in to comment.