Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
lib
unicaen
test
Commits
3591a585
Commit
3591a585
authored
Apr 25, 2017
by
Bertrand Gauthier
Browse files
Amélioration.
parent
9ab37f67
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/UnicaenTest/Controller/AbstractControllerTestCase.php
View file @
3591a585
...
...
@@ -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
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment