Commit 3591a585 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Amélioration.

parent 9ab37f67
......@@ -4,7 +4,11 @@ namespace UnicaenTest\Controller;
use Doctrine\ORM\EntityManager;
use Prophecy\Argument;
use Prophecy\Prophecy\ObjectProphecy;
use Prophecy\Prophet;
use UnicaenAuth\Service\AuthorizeService;
use UnicaenAuth\Service\UserContext as UserContextService;
use Zend\ServiceManager\ServiceManager;
use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;
/**
......@@ -33,17 +37,19 @@ abstract class AbstractControllerTestCase extends AbstractHttpControllerTestCase
/**
* @param string $authorizeServiceClass
* @return \Prophecy\Prophecy\ObjectProphecy
* @return ObjectProphecy|AuthorizeService
*/
protected function mockAuthorizeService($authorizeServiceClass)
{
$prophet = new Prophet();
/** @var ObjectProphecy|AuthorizeService $prophecy */
$prophecy = $prophet->prophesize();
$prophecy->willExtend($authorizeServiceClass);
$service = $prophecy->reveal();
/* @var $services \Zend\ServiceManager\ServiceManager */
/* @var $services ServiceManager */
$services = $this->getApplication()->getServiceManager();
$services->setAllowOverride(true);
$services->setFactory('BjyAuthorize\Service\Authorize', function() use ($service) {
......@@ -55,11 +61,13 @@ abstract class AbstractControllerTestCase extends AbstractHttpControllerTestCase
/**
* @param string $userContextServiceClass
* @return \Prophecy\Prophecy\ObjectProphecy
* @return ObjectProphecy|UserContextService
*/
protected function mockUserContextService($userContextServiceClass)
{
$prophet = new Prophet();
/** @var ObjectProphecy|UserContextService $prophecy */
$prophecy = $prophet->prophesize();
$prophecy->willExtend($userContextServiceClass);
......@@ -68,7 +76,7 @@ abstract class AbstractControllerTestCase extends AbstractHttpControllerTestCase
$service = $prophecy->reveal();
/* @var $services \Zend\ServiceManager\ServiceManager */
/* @var $services ServiceManager */
$services = $this->getApplication()->getServiceManager();
$services->setAllowOverride(true);
$services->setFactory('UnicaenAuth\Service\UserContext', function() use ($service) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment