Skip to content
Snippets Groups Projects
Select Git revision
  • f85e6c0113b4f5f0617d24d459ebf18c46f338eb
  • master default protected
  • b24
  • ll-workflow
  • alc-scindage-donnees-pj
  • FJ_LL_Tbl_Contrat
  • alc-docker-node
  • ll-apiplatform
  • php84
  • ll-rgpd
  • b23
  • alc-filtre-type-intervenant
  • ll-sans-mdb5
  • formules-ancienne-infra
  • ll-formules
  • alc-intervenant-dmep
  • ll-suppr-v_vol-s
  • b20
  • ll-postgresql
  • b23.0.1
  • b22
  • 24.8
  • 24.7
  • 24.6
  • 24.5
  • 24.4
  • 24.3
  • 24.2
  • 24.1
  • 24.0
  • 23.15
  • 24.0-beta19
  • 24.0-beta18
  • 24.0-beta17
  • 24.0-beta16
  • 24.0-beta15
  • 24.0-beta14
  • 24.0-beta13
  • 23.14
  • 24.0-beta12
  • 24.0-beta11
41 results

install.php

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    AbstractControllerTestCase.php 3.05 KiB
    <?php
    
    namespace UnicaenTest\Controller;
    
    use Doctrine\ORM\EntityManager;
    use Prophecy\Argument;
    use Prophecy\Prophecy\ObjectProphecy;
    use Prophecy\Prophet;
    use Zend\ServiceManager\ServiceManager;
    use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;
    
    /**
     * Class AbstractControllerTest
     *
     * @package ApplicationTest\Controller
     */
    abstract class AbstractControllerTestCase extends AbstractHttpControllerTestCase
    {
    //    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();
    //    }
    
        /**
         * @param string $authorizeServiceClass
         * @return ObjectProphecy|UnicaenAuth\Service\AuthorizeService
         */
        protected function mockAuthorizeService($authorizeServiceClass)
        {
            $prophet = new Prophet();
    
            /** @var ObjectProphecy|UnicaenAuth\Service\AuthorizeService $prophecy */
            $prophecy = $prophet->prophesize();
            $prophecy->willExtend($authorizeServiceClass);
    
            $service = $prophecy->reveal();
    
            /* @var $services ServiceManager */
            $services = $this->getApplication()->getServiceManager();
            $services->setAllowOverride(true);
            $services->setFactory('BjyAuthorize\Service\Authorize', function() use ($service) {
                return $service;
            });
    
            return $prophecy;
        }
    
        /**
         * @param string $userContextServiceClass
         * @return ObjectProphecy|UnicaenAuth\Service\UserContext
         */
        protected function mockUserContextService($userContextServiceClass)
        {
            $prophet = new Prophet();
    
            /** @var ObjectProphecy|UnicaenAuth\Service\UserContext $prophecy */
            $prophecy = $prophet->prophesize();
            $prophecy->willExtend($userContextServiceClass);
    
            $prophecy->getEventManager()->willReturn($this->getApplication()->getEventManager());
            $prophecy->setServiceLocator(Argument::any())->willReturn();
    
            $service = $prophecy->reveal();
    
            /* @var $services ServiceManager */
            $services = $this->getApplication()->getServiceManager();
            $services->setAllowOverride(true);
            $services->setFactory('UnicaenAuth\Service\UserContext', function() use ($service) {
                return $service;
            });
    
            return $prophecy;
        }
    
        /**
         * @var EntityManager
         */
        private $em;
    
        /**
         * @param string $name
         * @return EntityManager
         */
        protected function em($name = 'orm_default')
        {
            if (null === $this->em) {
                $this->em = $this->getApplicationServiceLocator()->get("doctrine.entitymanager.$name");
            }
    
            return $this->em;
        }
    }