public function prepare()
 {
     if (defined('STAGEHAND_TESTRUNNER_PREPARER_CAKEPREPARER_PREPARECALLEDMARKER')) {
         return;
     }
     define('STAGEHAND_TESTRUNNER_PREPARER_CAKEPREPARER_PREPARECALLEDMARKER', true);
     if (!defined('DISABLE_AUTO_DISPATCH')) {
         define('DISABLE_AUTO_DISPATCH', true);
     }
     if (is_null($this->getCakePHPAppPath())) {
         $cakephpAppPath = $this->environment->getWorkingDirectoryAtStartup();
     } else {
         $cakephpAppPath = $this->getCakePHPAppPath();
     }
     $rootPath = realpath($cakephpAppPath . '/..');
     $appPath = basename(realpath($cakephpAppPath));
     if (is_null($this->getCakePHPCorePath())) {
         $corePath = $rootPath . DIRECTORY_SEPARATOR . 'cake';
     } else {
         $corePath = realpath($this->getCakePHPCorePath());
     }
     if (!defined('TEST_CAKE_CORE_INCLUDE_PATH')) {
         define('TEST_CAKE_CORE_INCLUDE_PATH', rtrim($corePath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR);
     }
     ob_start();
     require_once $corePath . '/console/cake.php';
     ErrorReporting::invokeWith(error_reporting(), function () use($rootPath, $appPath) {
         new TestRunnerShellDispatcher(array('-root', $rootPath, '-app', $appPath));
     });
     ob_end_clean();
     require_once $corePath . '/tests/lib/test_manager.php';
     new \TestManager();
 }
 protected function configureApplicationContext()
 {
     $environment = new Environment();
     $environment->setWorkingDirectoryAtStartup(function_exists('Stagehand\\TestRunner\\Core\\workingDirectoryAtStartup') ? workingDirectoryAtStartup() : $GLOBALS['STAGEHAND_TESTRUNNER_workingDirectoryAtStartup']);
     $environment->setPreloadScript(function_exists('Stagehand\\TestRunner\\Core\\preloadScript') ? preloadScript() : $GLOBALS['STAGEHAND_TESTRUNNER_preloadScript']);
     $applicationContext = new ApplicationContext();
     $applicationContext->setComponentFactory(new ComponentFactory());
     $applicationContext->setEnvironment($environment);
     ApplicationContext::setInstance($applicationContext);
 }
Example #3
0
 protected function configureApplicationContext()
 {
     $environment = new Environment();
     $environment->setWorkingDirectoryAtStartup(workingDirectoryAtStartup());
     $environment->setPreloadScript(preloadScript());
     $applicationContext = new ApplicationContext();
     $applicationContext->setComponentFactory(new ComponentFactory());
     $applicationContext->setEnvironment($environment);
     ApplicationContext::setInstance($applicationContext);
 }
 public function prepare()
 {
     parent::prepare();
     if (is_null($this->getCIUnitPath())) {
         $ciunitPath = $this->environment->getWorkingDirectoryAtStartup();
     } else {
         $ciunitPath = $this->getCIUnitPath();
     }
     /* Removes some superglobals and environment variables to avoid getting invalid
      * URI string by the CIUnit URI object since some cases PDT sets some
      * environment variables for debugging.
      */
     $this->backupVariables();
     ErrorReporting::invokeWith(error_reporting() & ~E_USER_NOTICE & ~E_WARNING, function () use($ciunitPath) {
         require_once $ciunitPath . '/CIUnit.php';
     });
     $this->restoreVariables();
 }
 /**
  * @param string $command
  *
  * @return array
  */
 protected function buildOptions($command)
 {
     $options = array();
     if (basename(trim($command, '\'"')) != 'testrunner') {
         $configFile = $this->getPHPConfigDir();
         if ($configFile !== false) {
             $options[] = '-c';
             $options[] = escapeshellarg($configFile);
         }
         $options[] = escapeshellarg($_SERVER['argv'][0]);
     }
     if ($this->terminal->shouldColor()) {
         $options[] = '--ansi';
     }
     $options[] = escapeshellarg(strtolower($this->plugin->getPluginID()));
     if (!is_null($this->environment->getPreloadScript())) {
         $options[] = '-p ' . escapeshellarg($this->environment->getPreloadScript());
     }
     $options[] = '-R';
     if ($this->runner->shouldNotify()) {
         $options[] = '-m';
     }
     if ($this->runner->shouldStopOnFailure()) {
         $options[] = '--stop-on-failure';
     }
     if (!$this->testTargetRepository->isDefaultFilePattern()) {
         $options[] = '--test-file-pattern=' . escapeshellarg($this->testTargetRepository->getFilePattern());
     }
     if ($this->runner->hasDetailedProgress()) {
         $options[] = '--detailed-progress';
     }
     if (!is_null($this->commandLineOptionBuilder)) {
         $options = $this->commandLineOptionBuilder->build($options);
     }
     $this->testTargetRepository->walkOnResources(function ($resource, $index, TestTargetRepository $testTargetRepository) use(&$options) {
         $options[] = escapeshellarg($resource);
     });
     return $options;
 }