Ejemplo n.º 1
0
 public static function dispatch($arguments = array())
 {
     $GLOBALS['__PHPUNIT_BOOTSTRAP'] = dirname(__FILE__) . '/templates/AgaviBootstrap.tpl.php';
     $suites = (include AgaviConfigCache::checkConfig(AgaviConfig::get('core.testing_dir') . '/config/suites.xml'));
     $master_suite = new AgaviTestSuite('Master');
     if (!empty($arguments['include-suite'])) {
         $names = explode(',', $arguments['include-suite']);
         unset($arguments['include-suite']);
         foreach ($names as $name) {
             if (empty($suites[$name])) {
                 throw new InvalidArgumentException(sprintf('Invalid suite name %1$s.', $name));
             }
             $master_suite->addTest(self::createSuite($name, $suites[$name]));
         }
     } else {
         $excludes = array();
         if (!empty($arguments['exclude-suite'])) {
             $excludes = explode(',', $arguments['exclude-suite']);
             unset($arguments['exclude-suite']);
         }
         foreach ($suites as $name => $suite) {
             if (!in_array($name, $excludes)) {
                 $master_suite->addTest(self::createSuite($name, $suite));
             }
         }
     }
     $runner = new PHPUnit_TextUI_TestRunner();
     $runner->doRun($master_suite, $arguments);
 }
Ejemplo n.º 2
0
 /**
  * Dispatch the test run.
  *
  * @param      array An array of arguments configuring PHPUnit behavior.
  * @param      bool  Whether exit() should be called with an appropriate shell
  *                   exit status to indicate success or failures/errors.
  *
  * @return     PHPUnit_Framework_TestResult The PHPUnit result object.
  *
  * @author     Felix Gilcher <*****@*****.**>
  * @author     David Zülke <*****@*****.**>
  * @since      1.0.0
  * @deprecated 1.1.0 Use AgaviPhpUnitCli
  */
 public static function dispatch($arguments = array(), $exit = true)
 {
     $suites = (include AgaviConfigCache::checkConfig(AgaviConfig::get('core.testing_dir') . '/config/suites.xml'));
     $master_suite = new AgaviTestSuite('Master');
     if (!empty($arguments['include-suite'])) {
         $names = explode(',', $arguments['include-suite']);
         unset($arguments['include-suite']);
         foreach ($names as $name) {
             if (empty($suites[$name])) {
                 throw new InvalidArgumentException(sprintf('Invalid suite name %1$s.', $name));
             }
             $master_suite->addTest(self::createSuite($name, $suites[$name]));
         }
     } else {
         $excludes = array();
         if (!empty($arguments['exclude-suite'])) {
             $excludes = explode(',', $arguments['exclude-suite']);
             unset($arguments['exclude-suite']);
         }
         foreach ($suites as $name => $suite) {
             if (!in_array($name, $excludes)) {
                 $master_suite->addTest(self::createSuite($name, $suite));
             }
         }
     }
     if (version_compare(PHPUnit_Runner_Version::id(), '3.6', '<')) {
         // PHP_CodeCoverage_Filter is a singleton
         $runner = new PHPUnit_TextUI_TestRunner();
     } else {
         // PHP_CodeCoverage_Filter instance must be passed to the test runner
         $runner = new PHPUnit_TextUI_TestRunner(null, self::$codeCoverageFilter);
     }
     $result = $runner->doRun($master_suite, $arguments);
     if ($exit) {
         // bai
         exit(self::getExitStatus($result));
     } else {
         // return result so calling code can use it
         return $result;
     }
 }
Ejemplo n.º 3
0
 /**
  * Custom callback for test suite discovery.
  * This is called by PHPUnit in the setup process, right after all command line 
  * arguments have been parsed.
  *
  * @author     Dominik del Bondio <*****@*****.**>
  * @since      1.1.0
  */
 protected function handleCustomTestSuite()
 {
     // ensure the bootstrap script doesn't run and bootstraps agavi another time
     define('AGAVI_TESTING_BOOTSTRAPPED', true);
     AgaviToolkit::clearCache();
     $this->bootstrap($this->arguments['agaviEnvironment']);
     // use the default configuration only if another configuration was not given as command line argument
     $defaultConfigPath = AgaviConfig::get('core.testing_dir') . '/config/phpunit.xml';
     if (empty($this->arguments['configuration']) && is_file($defaultConfigPath)) {
         $this->arguments['configuration'] = $defaultConfigPath;
     }
     $this->arguments['configuration'] = $this->expandConfiguration($this->arguments['configuration']);
     if (count($this->options[1]) > 0) {
         // positional args were given, so the user specified a test or folder on the command line
         return;
     }
     $suites = (require AgaviConfigCache::checkConfig(AgaviConfig::get('core.testing_dir') . '/config/suites.xml'));
     $masterSuite = new AgaviTestSuite('Master');
     if ($this->arguments['agaviIncludeSuites']) {
         foreach ($this->arguments['agaviIncludeSuites'] as $name) {
             if (empty($suites[$name])) {
                 throw new InvalidArgumentException(sprintf('Invalid suite name %1$s.', $name));
             }
             $masterSuite->addTest(self::createSuite($name, $suites[$name]));
         }
     } else {
         foreach ($suites as $name => $suite) {
             if (!in_array($name, $this->arguments['agaviExcludeSuites'])) {
                 $masterSuite->addTest(self::createSuite($name, $suite));
             }
         }
     }
     $this->arguments['test'] = $masterSuite;
 }