/** * @return null */ public function setUp() { $this->map = array('user' => "\\TestFuel\\Fake\\Domain\\User\\UserDomain", 'user-email' => "\\TestFuel\\Fake\\Domain\\User\\Email\\EmailDomain", 'role' => "\\TestFuel\\Fake\\Domain\\Role\\RoleDomain"); parent::setUp(); KernelRegistry::setDomainMap($this->map); $this->builder = new DomainBuilder(); }
/** * Since the domain class is decoupled by the its key we must retrieve * the domain class form the domain registry that holds the mapping. Once * we have the class use the root domain namespace * * @param string $key key used to map the domain namespace * @return mixed */ public function createDomainObject($key) { $domainClass = KernelRegistry::getDomainClass($key); if (false === $domainClass) { return false; } try { return new $domainClass(); } catch (Exception $e) { $err = "object not found for ({$key}) at ({$domainClass})"; throw new RunTimeException($err, 0, $e); } }
/** * @return null */ public function tearDown() { KernelRegistry::setRouteMap($this->backup); $this->dispatcher = null; $_GET = $this->bkSuperGlobals['get']; $_POST = $this->bkSuperGlobals['post']; $_FILES = $this->bkSuperGlobals['files']; $_COOKIE = $this->bkSuperGlobals['cookie']; $cli = $this->bkSuperGlobals['argv']; if (null !== $cli) { $_SERVER['argv'] = $cli; } }
/** * @param array $params config params * @return null */ public function execute(array $params = null) { /* regardless of the kernel settings unit tests * should have full error reporting and they should be displayed */ error_reporting(E_ALL | E_STRICT); ini_set('error_diplay', 'on'); $params = KernelRegistry::getParams(); $domains = KernelRegistry::getDomainMap(); $state = new KernelState(); TestRegistry::setKernelState($state); TestRegistry::setKernelParams($params); TestRegistry::setKernelDomainMap($domains); $this->setStatus('appfuel unittest: initialized'); }
/** * @return null */ public function runDbStartupTask() { $task = new DbStartupTask(); $keys = $task->getRegistryKeys(); $params = array(); foreach ($keys as $key => $default) { $params[$key] = KernelRegistry::getParam($key, $default); } $task->execute($params); }
/** * The post filter will replace all spaces with ':' * @depends testInterface * @return null */ public function estRunDispatchConsoleWithPreAndPostFilters() { $uriString = 'my-route/param1/value1'; $output = $this->getMock('Appfuel\\Console\\ConsoleOutputInterface'); $render = function ($data) { echo $data; }; $filters = array('TestFuel\\Fake\\Action\\TestFront\\AddLabelFilter', 'TestFuel\\Fake\\Action\\TestFront\\PrependLabelFilter', 'TestFuel\\Fake\\Action\\TestFront\\ReplaceSpacesFilter'); KernelRegistry::addParam('intercepting-filters', $filters); $output->expects($this->once())->method('render')->will($this->returnCallback($render)); $result = $this->front->runConsoleUri($uriString, $output); $expected = '4:5:6:value:1:2:3:this:action:has:been:executed'; $this->assertEquals(200, $result); $this->expectOutputString($expected); }
/** * @param MvcDispatcherInterface $dispatcher * @param InterceptChainInterface $preChain * @param InterceptChainInterface $postChain * @return MvcFront */ public function createFront(MvcDispatcherInterface $dispatcher = null, InterceptChainInterface $preChain = null, InterceptChainInterface $postChain = null) { $preList = KernelRegistry::getParam('pre-filters', array()); if (null === $preChain) { $preChain = new InterceptChain(); } if (is_array($preList) && !empty($preList)) { $preChain->loadFilters($preList); } $postList = KernelRegistry::getParam('post-filters', array()); if (null === $postChain) { $postChain = new InterceptChain(); } if (is_array($postList) && !empty($postList)) { $postChain->loadFilters($postList); } if (null === $dispatcher) { $dispatcher = new MvcDispatcher(); } return new MvcFront($dispatcher, $preChain, $postChain); }
/** * @param array $list * @return array */ public function collectFromRegistry(array $list) { return KernelRegistry::collectParams($list); }