Esempio n. 1
0
 /**
  * @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();
 }
Esempio n. 2
0
 /**
  * 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;
     }
 }
Esempio n. 4
0
 /**
  * @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');
 }
Esempio n. 5
0
 /**
  * @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);
 }
Esempio n. 6
0
 /**
  * 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);
 }
Esempio n. 7
0
 /**
  * @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);
 }
Esempio n. 8
0
 /**
  * @param	array	$list
  * @return	array
  */
 public function collectFromRegistry(array $list)
 {
     return KernelRegistry::collectParams($list);
 }