コード例 #1
0
ファイル: Phalcon1.php プロジェクト: nsgomez/Codeception
 /**
  * Provides access the Phalcon application object.
  *
  * @see \Codeception\Lib\Connector\Phalcon::getApplication
  * @return \Phalcon\Mvc\Application|\Phalcon\Mvc\Micro|\Phalcon\Cli\Console
  */
 public function getApplication()
 {
     return $this->client->getApplication();
 }
コード例 #2
0
ファイル: Phalcon1.php プロジェクト: jymboche/Codeception
 /**
  * HOOK: before scenario
  *
  * @param TestCase $test
  * @throws ModuleException
  */
 public function _before(TestCase $test)
 {
     $application = (require $this->bootstrapFile);
     if (!$application instanceof Injectable) {
         throw new ModuleException(__CLASS__, 'Bootstrap must return \\Phalcon\\Di\\Injectable object');
     }
     $this->di = $application->getDI();
     if (!$this->di instanceof DiInterface) {
         throw new ModuleException(__CLASS__, 'Dependency injector container must implement DiInterface');
     }
     Di::reset();
     Di::setDefault($this->di);
     if ($this->di->has('session')) {
         $this->di['session'] = new PhalconMemorySession();
     }
     if ($this->di->has('cookies')) {
         $this->di['cookies']->useEncryption(false);
     }
     if ($this->config['cleanup'] && $this->di->has('db')) {
         if ($this->config['savepoints']) {
             $this->di['db']->setNestedTransactionsWithSavepoints(true);
         }
         $this->di['db']->begin();
     }
     // localize
     $bootstrap = $this->bootstrapFile;
     $this->client->setApplication(function () use($bootstrap) {
         $currentDi = Di::getDefault();
         $application = (require $bootstrap);
         $di = $application->getDI();
         if ($currentDi->has('db')) {
             $di['db'] = $currentDi['db'];
         }
         if ($currentDi->has('session')) {
             $di['session'] = $currentDi['session'];
         }
         if ($di->has('cookies')) {
             $di['cookies']->useEncryption(false);
         }
         return $application;
     });
 }