Loading src/UnicaenTest/Controller/AbstractControllerTestCase.php +17 −19 Original line number Diff line number Diff line Loading @@ -3,18 +3,19 @@ namespace UnicaenTest\Controller; use Doctrine\ORM\EntityManager; use Laminas\ServiceManager\ServiceManager; use Prophecy\Argument; use Prophecy\Prophecy\ObjectProphecy; use Prophecy\Prophet; use Laminas\ServiceManager\ServiceManager; use Laminas\Test\PHPUnit\Controller\AbstractHttpControllerTestCase; use Psr\Container\ContainerExceptionInterface; use RuntimeException; /** * Class AbstractControllerTest * * @package ApplicationTest\Controller */ abstract class AbstractControllerTestCase extends AbstractHttpControllerTestCase abstract class AbstractControllerTestCase extends \Laminas\Test\PHPUnit\Controller\AbstractControllerTestCase { // public function setUp() // { Loading @@ -35,13 +36,13 @@ abstract class AbstractControllerTestCase extends AbstractHttpControllerTestCase /** * @param string $authorizeServiceClass * @return ObjectProphecy|UnicaenAuth\Service\AuthorizeService * @return ObjectProphecy|\UnicaenAuth\Service\AuthorizeService */ protected function mockAuthorizeService($authorizeServiceClass) protected function mockAuthorizeService(string $authorizeServiceClass) { $prophet = new Prophet(); /** @var ObjectProphecy|UnicaenAuth\Service\AuthorizeService $prophecy */ /** @var ObjectProphecy|\UnicaenAuth\Service\AuthorizeService $prophecy */ $prophecy = $prophet->prophesize(); $prophecy->willExtend($authorizeServiceClass); Loading @@ -59,13 +60,13 @@ abstract class AbstractControllerTestCase extends AbstractHttpControllerTestCase /** * @param string $userContextServiceClass * @return ObjectProphecy|UnicaenAuth\Service\UserContext * @return ObjectProphecy|\UnicaenAuth\Service\UserContext */ protected function mockUserContextService($userContextServiceClass) protected function mockUserContextService(string $userContextServiceClass) { $prophet = new Prophet(); /** @var ObjectProphecy|UnicaenAuth\Service\UserContext $prophecy */ /** @var ObjectProphecy|\UnicaenAuth\Service\UserContext $prophecy */ $prophecy = $prophet->prophesize(); $prophecy->willExtend($userContextServiceClass); Loading @@ -84,19 +85,16 @@ abstract class AbstractControllerTestCase extends AbstractHttpControllerTestCase return $prophecy; } /** * @var EntityManager */ private $em; protected ?EntityManager $em = null; /** * @param string $name * @return EntityManager */ protected function em($name = 'orm_default') protected function em(): EntityManager { if (null === $this->em) { $this->em = $this->getApplicationServiceLocator()->get("doctrine.entitymanager.$name"); try { $this->em = $this->getApplicationServiceLocator()->get("doctrine.entitymanager.orm_default"); } catch (ContainerExceptionInterface $e) { throw new RuntimeException("Impossible d'obtenir l'entity manager orm_default !", null, $e); } } return $this->em; Loading Loading
src/UnicaenTest/Controller/AbstractControllerTestCase.php +17 −19 Original line number Diff line number Diff line Loading @@ -3,18 +3,19 @@ namespace UnicaenTest\Controller; use Doctrine\ORM\EntityManager; use Laminas\ServiceManager\ServiceManager; use Prophecy\Argument; use Prophecy\Prophecy\ObjectProphecy; use Prophecy\Prophet; use Laminas\ServiceManager\ServiceManager; use Laminas\Test\PHPUnit\Controller\AbstractHttpControllerTestCase; use Psr\Container\ContainerExceptionInterface; use RuntimeException; /** * Class AbstractControllerTest * * @package ApplicationTest\Controller */ abstract class AbstractControllerTestCase extends AbstractHttpControllerTestCase abstract class AbstractControllerTestCase extends \Laminas\Test\PHPUnit\Controller\AbstractControllerTestCase { // public function setUp() // { Loading @@ -35,13 +36,13 @@ abstract class AbstractControllerTestCase extends AbstractHttpControllerTestCase /** * @param string $authorizeServiceClass * @return ObjectProphecy|UnicaenAuth\Service\AuthorizeService * @return ObjectProphecy|\UnicaenAuth\Service\AuthorizeService */ protected function mockAuthorizeService($authorizeServiceClass) protected function mockAuthorizeService(string $authorizeServiceClass) { $prophet = new Prophet(); /** @var ObjectProphecy|UnicaenAuth\Service\AuthorizeService $prophecy */ /** @var ObjectProphecy|\UnicaenAuth\Service\AuthorizeService $prophecy */ $prophecy = $prophet->prophesize(); $prophecy->willExtend($authorizeServiceClass); Loading @@ -59,13 +60,13 @@ abstract class AbstractControllerTestCase extends AbstractHttpControllerTestCase /** * @param string $userContextServiceClass * @return ObjectProphecy|UnicaenAuth\Service\UserContext * @return ObjectProphecy|\UnicaenAuth\Service\UserContext */ protected function mockUserContextService($userContextServiceClass) protected function mockUserContextService(string $userContextServiceClass) { $prophet = new Prophet(); /** @var ObjectProphecy|UnicaenAuth\Service\UserContext $prophecy */ /** @var ObjectProphecy|\UnicaenAuth\Service\UserContext $prophecy */ $prophecy = $prophet->prophesize(); $prophecy->willExtend($userContextServiceClass); Loading @@ -84,19 +85,16 @@ abstract class AbstractControllerTestCase extends AbstractHttpControllerTestCase return $prophecy; } /** * @var EntityManager */ private $em; protected ?EntityManager $em = null; /** * @param string $name * @return EntityManager */ protected function em($name = 'orm_default') protected function em(): EntityManager { if (null === $this->em) { $this->em = $this->getApplicationServiceLocator()->get("doctrine.entitymanager.$name"); try { $this->em = $this->getApplicationServiceLocator()->get("doctrine.entitymanager.orm_default"); } catch (ContainerExceptionInterface $e) { throw new RuntimeException("Impossible d'obtenir l'entity manager orm_default !", null, $e); } } return $this->em; Loading