Loading CHANGELOG.md +4 −0 Original line number Diff line number Diff line CHANGELOG ========= 6.1.0 ----- - Introduction des propriétés applicationConfigPath et applicationConfigOverrides dans AbstractControllerTestCase 6.0.0 ----- - Requiert les nouvelles bibliothèques unicaen/authentification et privilege. Loading src/UnicaenTest/Controller/AbstractControllerTestCase.php +31 −19 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace UnicaenTest\Controller; use Doctrine\ORM\EntityManager; use Laminas\ServiceManager\ServiceManager; use Laminas\Stdlib\ArrayUtils; use Prophecy\Argument; use Prophecy\Prophecy\ObjectProphecy; use Prophecy\Prophet; Loading @@ -17,22 +18,33 @@ use RuntimeException; */ abstract class AbstractControllerTestCase extends \Laminas\Test\PHPUnit\Controller\AbstractControllerTestCase { // public function setUp() // { // // The module configuration should still be applicable for tests. // // You can override configuration here with test case specific values, // // such as sample view templates, path stacks, module_listener_options, // // etc. // $configOverrides = []; // // $this->setApplicationConfig(ArrayUtils::merge( // // Grabbing the full application configuration: // include __DIR__ . '/../../../../config/application.config.php', // $configOverrides // )); // // parent::setUp(); // } /** * Chemin vers le fichier de config 'application.config.php'. * * @var string Ex : __DIR__ . '/../../../../config/application.config.php' */ protected string $applicationConfigPath; /** * The module configuration should still be applicable for tests. * You can override configuration here with test case specific values, * such as sample view templates, path stacks, module_listener_options, etc. * * @var array */ protected array $applicationConfigOverrides = []; public function setUp(): void { $this->setApplicationConfig(ArrayUtils::merge( // Grabbing the full application configuration: include $this->applicationConfigPath, $this->applicationConfigOverrides )); parent::setUp(); } /** * @param string $authorizeServiceClass Loading Loading @@ -87,13 +99,13 @@ abstract class AbstractControllerTestCase extends \Laminas\Test\PHPUnit\Controll protected ?EntityManager $em = null; protected function em(): EntityManager protected function em(string $name = 'orm_default'): EntityManager { if (null === $this->em) { try { $this->em = $this->getApplicationServiceLocator()->get("doctrine.entitymanager.orm_default"); $this->em = $this->getApplicationServiceLocator()->get("doctrine.entitymanager.$name"); } catch (ContainerExceptionInterface $e) { throw new RuntimeException("Impossible d'obtenir l'entity manager orm_default !", null, $e); throw new RuntimeException("Impossible d'obtenir l'entity manager $name !", null, $e); } } Loading Loading
CHANGELOG.md +4 −0 Original line number Diff line number Diff line CHANGELOG ========= 6.1.0 ----- - Introduction des propriétés applicationConfigPath et applicationConfigOverrides dans AbstractControllerTestCase 6.0.0 ----- - Requiert les nouvelles bibliothèques unicaen/authentification et privilege. Loading
src/UnicaenTest/Controller/AbstractControllerTestCase.php +31 −19 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace UnicaenTest\Controller; use Doctrine\ORM\EntityManager; use Laminas\ServiceManager\ServiceManager; use Laminas\Stdlib\ArrayUtils; use Prophecy\Argument; use Prophecy\Prophecy\ObjectProphecy; use Prophecy\Prophet; Loading @@ -17,22 +18,33 @@ use RuntimeException; */ abstract class AbstractControllerTestCase extends \Laminas\Test\PHPUnit\Controller\AbstractControllerTestCase { // public function setUp() // { // // The module configuration should still be applicable for tests. // // You can override configuration here with test case specific values, // // such as sample view templates, path stacks, module_listener_options, // // etc. // $configOverrides = []; // // $this->setApplicationConfig(ArrayUtils::merge( // // Grabbing the full application configuration: // include __DIR__ . '/../../../../config/application.config.php', // $configOverrides // )); // // parent::setUp(); // } /** * Chemin vers le fichier de config 'application.config.php'. * * @var string Ex : __DIR__ . '/../../../../config/application.config.php' */ protected string $applicationConfigPath; /** * The module configuration should still be applicable for tests. * You can override configuration here with test case specific values, * such as sample view templates, path stacks, module_listener_options, etc. * * @var array */ protected array $applicationConfigOverrides = []; public function setUp(): void { $this->setApplicationConfig(ArrayUtils::merge( // Grabbing the full application configuration: include $this->applicationConfigPath, $this->applicationConfigOverrides )); parent::setUp(); } /** * @param string $authorizeServiceClass Loading Loading @@ -87,13 +99,13 @@ abstract class AbstractControllerTestCase extends \Laminas\Test\PHPUnit\Controll protected ?EntityManager $em = null; protected function em(): EntityManager protected function em(string $name = 'orm_default'): EntityManager { if (null === $this->em) { try { $this->em = $this->getApplicationServiceLocator()->get("doctrine.entitymanager.orm_default"); $this->em = $this->getApplicationServiceLocator()->get("doctrine.entitymanager.$name"); } catch (ContainerExceptionInterface $e) { throw new RuntimeException("Impossible d'obtenir l'entity manager orm_default !", null, $e); throw new RuntimeException("Impossible d'obtenir l'entity manager $name !", null, $e); } } Loading