run() публичный Метод

public run ( array $argv, boolean $exit = true ) : integer
$argv array
$exit boolean
Результат integer
Пример #1
0
 /**
  * Call the same functions used by the CLI PHPUnit
  * to engage the tests
  * @param string $modulePath path to the phpunit.xml to use
  * @return int
  * 0: Tests successful
  * 1: Tests failed
  * 2: Failed with exception
  */
 public function run($modulePath, $params = array())
 {
     $runner = new \PHPUnit_TextUI_Command();
     $options = array('--configuration', $modulePath . '/phpunit.xml');
     if (isset($params['filter']) && !empty($params['filter'])) {
         $options[] = '--filter';
         $options[] = $params['filter'];
     }
     if (isset($params['coverage']) && !empty($params['coverage'])) {
         $coverage = $params['coverage'];
         $path = $this->getCoveragePath();
         switch ($coverage) {
             case 'html':
                 $options[] = '--coverage-html';
                 $path .= '/html';
                 $options[] = $path;
                 break;
             default:
                 $options[] = '--coverage-text';
                 break;
         }
         echo "Coverage data will be written to {$path}" . PHP_EOL;
     }
     array_unshift($options, 'phpunit');
     return $runner->run($options, false);
 }
Пример #2
0
 public function runTests()
 {
     $cliOptions = ['phpunit'];
     // first entry is the command
     array_push($cliOptions, '-c', __QCUBED_CORE__ . '/tests/phpunit.xml');
     // the config file is here
     //		array_push($cliOptions, '--bootstrap', __QCUBED_CORE__ . '/../vendor/autoload.php');
     $tester = new PHPUnit_TextUI_Command();
     $tester->run($cliOptions);
 }
Пример #3
0
 public function execute()
 {
     global $IP;
     // NOTE (phuedx, 2014-03-26) wgAutoloadClasses isn't set up
     // by either of the dependencies at the top of the file, so
     // require it here.
     require_once __DIR__ . '/../tests/TestsAutoLoader.php';
     $textUICommand = new PHPUnit_TextUI_Command();
     $argv = array("{$IP}/tests/phpunit/phpunit.php", "{$IP}/tests/phpunit/suites/LessTestSuite.php");
     $textUICommand->run($argv);
 }
Пример #4
0
 /**
  * Read configuration file, and run check.
  *
  * @return void
  * @throws \Exception
  */
 public function run()
 {
     if (is_null($this->config)) {
         exit("Can not find a set of checks to run.\n");
     }
     PHP_Timer::start();
     $command = new \PHPUnit_TextUI_Command();
     $command->run(array('--configuration', $this->config, '--testdox'), false);
     $duration = PHP_Timer::stop();
     $c = new Color();
     echo $c('Time : ' . PHP_Timer::secondsToTimeString($duration))->bold() . PHP_EOL;
 }
Пример #5
0
 /**
  * (non-PHPdoc)
  *
  * @see \SK\ITCBundle\Code\Generator\PHPUnit\AbstractGenerator::execute($input, $output)
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $this->writeHeader($output);
     if (strpos('/usr/bin/php', '@php_bin') === 0) {
         require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'PHPUnit' . DIRECTORY_SEPARATOR . 'Autoload.php';
     } else {
         require '/usr/share/pear' . DIRECTORY_SEPARATOR . 'PHPUnit' . DIRECTORY_SEPARATOR . 'Autoload.php';
     }
     $commandArg = array('-c' => "phpunit.xml");
     $command = new \PHPUnit_TextUI_Command();
     $command->run($commandArg);
 }
 public function run(array $argv, $exit = true)
 {
     wfProfileIn(__METHOD__);
     $ret = parent::run($argv, false);
     wfProfileOut(__METHOD__);
     // Return to real wiki db, so profiling data is preserved
     MediaWikiTestCase::teardownTestDB();
     // Log profiling data, e.g. in the database or UDP
     wfLogProfilingData();
     if ($exit) {
         exit($ret);
     } else {
         return $ret;
     }
 }
Пример #7
0
 /**
  * new method to launch a web server
  * @param array $options
  * @tutorial php bin/console server:run
  *           php bin/console server:run -a 192.168.0.1:8000
  */
 public function phpunit(array $options = array())
 {
     ob_get_clean();
     $files = scandir(__DIR__ . '/../../../../tests');
     foreach ($files as $one) {
         if (is_dir(__DIR__ . '/../../../../tests/' . $one) && $one != '..' && $one != '.') {
             $controllerFiles = scandir(__DIR__ . '/../../../../tests' . '/' . $one . '/app/Controller');
             foreach ($controllerFiles as $oneController) {
                 if (is_file(__DIR__ . '/../../../../tests/' . $one . '/app/Controller/' . $oneController) && $oneController != '..' && $oneController != '.') {
                     $unitTest = new \PHPUnit_TextUI_Command();
                     $unitTest->run([__DIR__ . '/../../../../tests/' . $one . '/app/Controller/' . $oneController]);
                 }
             }
         }
     }
 }
Пример #8
0
 /**
  * Uses an instance of PHPUnit_TextUI_Command to execute the PHPUnit
  * tests and simulates any Mutagenesis supported command line options suitable
  * for PHPUnit. At present, we merely dissect a generic 'options' string
  * equivelant to anything typed into a console after a normal 'phpunit'
  * command. The adapter captures the TextUI output for further processing.
  *
  * To prevent duplication of output from stdout, PHPUnit is hard
  * configured to write to stderrm(stdin is used in proc_open call)
  *
  * @param array $arguments Mutagenesis arguments to pass to PHPUnit
  * @return void
  */
 public static function main(array $arguments, $useStdout = false)
 {
     if (!$useStdout) {
         array_unshift($arguments['clioptions'], '--stderr');
     }
     if (!in_array('--stop-on-failure', $arguments['clioptions'])) {
         array_unshift($arguments['clioptions'], '--stop-on-failure');
     }
     array_unshift($arguments['clioptions'], 'phpunit');
     $originalWorkingDirectory = getcwd();
     if (isset($arguments['tests'])) {
         chdir($arguments['tests']);
     }
     $command = new \PHPUnit_TextUI_Command();
     $command->run($arguments['clioptions'], false);
     chdir($originalWorkingDirectory);
 }
Пример #9
0
 public function execute()
 {
     global $IP;
     // NOTE (phuedx, 2014-03-26) wgAutoloadClasses isn't set up
     // by either of the dependencies at the top of the file, so
     // require it here.
     require_once __DIR__ . '/../tests/TestsAutoLoader.php';
     // If phpunit isn't available by autoloader try pulling it in
     if (!class_exists('PHPUnit_Framework_TestCase')) {
         require_once 'PHPUnit/Autoload.php';
     }
     // RequestContext::resetMain() will print warnings unless this
     // is defined.
     if (!defined('MW_PHPUNIT_TEST')) {
         define('MW_PHPUNIT_TEST', true);
     }
     $textUICommand = new PHPUnit_TextUI_Command();
     $argv = ["{$IP}/tests/phpunit/phpunit.php", "{$IP}/tests/phpunit/suites/LessTestSuite.php"];
     $textUICommand->run($argv);
 }
Пример #10
0
 /**
  * Uses an instance of PHPUnit_TextUI_Command to execute the PHPUnit
  * tests and simulates any Mutateme supported command line options suitable
  * for PHPUnit. At present, we merely dissect a generic 'options' string
  * equivelant to anything typed into a console after a normal 'phpunit'
  * command. The adapter captures the TextUI output for further processing.
  *
  * To prevent duplication of output from stdout, PHPUnit is hard
  * configured to write to stderrm(stdin is used in proc_open call)
  *
  * @param array $arguments Mutateme arguments to pass to PHPUnit
  * @return void
  */
 public static function main(array $arguments, $useStdout = false)
 {
     $optionString = 'phpunit';
     if ($useStdout) {
         $optionString .= '';
     } else {
         $optionString = ' --stderr';
     }
     if (isset($arguments['options'])) {
         $optionString .= ' ' . $arguments['options'];
     }
     $options = explode(' ', $optionString);
     $originalWorkingDirectory = getcwd();
     if (isset($arguments['tests'])) {
         chdir($arguments['tests']);
     }
     $command = new \PHPUnit_TextUI_Command();
     $command->run($options, false);
     chdir($originalWorkingDirectory);
 }
 /**
  * @param array   $argv
  * @param boolean $exit
  */
 public function run(array $argv, $exit = true)
 {
     parent::run($argv, false);
 }
Пример #12
0
 public function run($options)
 {
     $phpunit = new \PHPUnit_TextUI_Command();
     $phpunit->run(['', 'tests/cases', '--bootstrap=tests/bootstrap.php']);
 }
Пример #13
0
 /**
  * Runs PHPUnit with the supplied XML configuration file.
  *
  * @param mixed $xml_config    The path to the PHPUnit XML configuration
  *                             file.
  * @access public
  * @return string
  */
 public function run_with_xml($xml_config, $extraConfiguration)
 {
     $command = new \PHPUnit_TextUI_Command();
     // We need to temporarily turn off html_errors to ensure correct
     // parsing of test debug output
     $html_errors = ini_get('html_errors');
     ini_set('html_errors', 0);
     ob_start();
     if (isset($extraConfiguration['use_group_name'])) {
         $command->run(array('--configuration', $xml_config, '--group', $extraConfiguration['use_group_name']), false);
     } else {
         if (isset($extraConfiguration['run_specific_test'])) {
             $command->run(array('--configuration', $xml_config, '--filter', $extraConfiguration['run_specific_test']), false);
         } else {
             $command->run(array('--configuration', $xml_config), false);
         }
     }
     $results = ob_get_contents();
     ob_end_clean();
     ini_set('html_errors', $html_errors);
     $start = strpos($results, '{');
     $end = strrpos($results, '}');
     return substr($results, $start, $end - $start + 1);
 }
Пример #14
0
 /**
  * Runs PHPUnit with the supplied XML configuration file.
  *
  * @param mixed $xml_config    The path to the PHPUnit XML configuration
  *                             file.
  * @access public
  * @return string
  */
 public function run_with_xml($xml_config)
 {
     $command = new \PHPUnit_TextUI_Command();
     // We need to temporarily turn off html_errors to ensure correct
     // parsing of test debug output
     $html_errors = ini_get('html_errors');
     ini_set('html_errors', 0);
     ob_start();
     $command->run(array('--configuration', $xml_config), false);
     $results = ob_get_contents();
     ob_end_clean();
     ini_set('html_errors', $html_errors);
     $start = strpos($results, '{');
     $end = strrpos($results, '}');
     return substr($results, $start, $end - $start + 1);
 }
Пример #15
0
<?php

$base = dirname(__FILE__);
set_include_path("{$base}:{$base}/tests:" . get_include_path());
require_once 'PHPUnit/Util/Filter.php';
PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
require_once 'PHPUnit/TextUI/Command.php';
$command = new PHPUnit_TextUI_Command();
$command->run($argv);
Пример #16
0
 /**
  * Execute the command
  *
  * @return  void
  *
  * @since   1.0
  */
 public function execute()
 {
     // Use a DirectoryIterator object to loop over each package
     $iterator = new \DirectoryIterator(JPATH_ROOT . '/vendor/joomla');
     /* @type  $directory  \DirectoryIterator */
     foreach ($iterator as $directory) {
         if (!$directory->isDot() && $directory->isDir()) {
             $this->app->out('Processing the ' . $this->helper->getPackageDisplayName($directory->getFilename()) . ' package.');
             // Get the package ID
             $this->getPackageId($directory->getFilename());
             // Check to see if this version of the package already has a report
             if ($this->checkForReport($directory->getFilename())) {
                 $this->app->out(sprintf('A test report already exists for the %s package at version %s.', $this->helper->getPackageDisplayName($directory->getFilename()), $this->packages[$directory->getFilename()]['version']));
                 continue;
             }
             // Check if a test config exists for the package
             if (file_exists(JPATH_TESTS . '/phpunit.' . $directory->getFilename() . '.xml')) {
                 $command = new \PHPUnit_TextUI_Command();
                 $options = ['--configuration=' . JPATH_TESTS . '/phpunit.' . $directory->getFilename() . '.xml'];
                 $command->run($options, false);
                 $this->recordResults($directory->getFilename());
                 $this->sanitizePaths($directory->getFilename());
             } else {
                 $this->app->out('No test config exists for the ' . $this->helper->getPackageDisplayName($directory->getFilename()) . ' package.');
             }
         }
     }
     // Write environment information for the report
     $this->storeEnvironmentData();
 }
Пример #17
0
 /**
  * @param boolean $exit
  */
 public static function main($exit = TRUE)
 {
     $command = new PHPUnit_TextUI_Command();
     $command->run($_SERVER['argv'], $exit);
 }
Пример #18
0
 /**
  * {@inheritdoc}
  *
  * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
  */
 public function run(array $argv, $exit = true)
 {
     $argv = $this->preprocessArgv($argv);
     if (in_array('--sugared-debug', $argv)) {
         $this->logDebug('Arguments', $argv);
     }
     parent::run($argv, $exit);
 }
Пример #19
0
 /**
  * @param array $argv
  * @param boolean $exit
  */
 public function run(array $argv, $exit = true)
 {
     $this->arguments['printer'] = new arbitTextUiResultPrinter();
     return parent::run($argv, $exit);
 }
Пример #20
0
 /**
  * Executes the current command.
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $configuration = Configuration::getInstance();
     $phpunit = new \PHPUnit_TextUI_Command();
     $phpunit->run(array('phpunit', "-c", realpath($configuration->getTargetDirectory()) . "/phpunit.xml"), true);
 }
Пример #21
0
 /**
  * Uses an instance of PHPUnit_TextUI_Command to execute the PHPUnit
  * tests and simulates any Mutagenesis supported command line options suitable
  * for PHPUnit. At present, we merely dissect a generic 'options' string
  * equivelant to anything typed into a console after a normal 'phpunit'
  * command. The adapter captures the TextUI output for further processing.
  *
  * To prevent duplication of output from stdout, PHPUnit is hard
  * configured to write to stderrm(stdin is used in proc_open call)
  *
  * @param array $arguments Mutagenesis arguments to pass to PHPUnit
  * @return void
  */
 public static function main($arguments, $mutation = null, $bootstrap = null)
 {
     $arguments = unserialize($arguments);
     /**
      * Grab the Runkit extension utility and apply the mutation if needed
      */
     if (!is_null($mutation)) {
         $mutation = unserialize($mutation);
         if (!empty($mutation)) {
             if (!is_null($bootstrap)) {
                 require_once $bootstrap;
             }
             if (!in_array('runkit', get_loaded_extensions())) {
                 throw new \Exception('Runkit extension is not loaded. Unfortunately, runkit' . ' is essential for Mutagenesis. Please see the manual or' . ' README which explains how to install an updated runkit' . ' extension suitable for Mutagenesis and PHP 5.3.');
             }
             $runkit = new \Mutagenesis\Utility\Runkit();
             $runkit->applyMutation($mutation);
         }
     }
     /**
      * Switch working directory to tests and execute the test suite
      */
     $originalWorkingDirectory = getcwd();
     if (isset($arguments['tests'])) {
         chdir($arguments['tests']);
     }
     $command = new \PHPUnit_TextUI_Command();
     $command->run($arguments['clioptions'], false);
     chdir($originalWorkingDirectory);
 }
Пример #22
0
 /**
  * @param boolean $exit
  */
 public static function main($exit = TRUE)
 {
     $opt = PHPUnit_TextUI_Command::_get_my_cnf_options();
     $GLOBALS['mysql_host'] = isset($opt['host']) ? $opt['host'] : 'localhost';
     $GLOBALS['mysql_user'] = isset($opt['user']) ? $opt['user'] : (isset($_ENV['USER']) ? $_ENV['USER'] : null);
     $GLOBALS['mysql_pass'] = isset($opt['password']) ? $opt['password'] : null;
     if (!$GLOBALS['mysql_pass']) {
         $GLOBALS['mysql_pass'] = isset($opt['pass']) ? $opt['pass'] : null;
     }
     $GLOBALS['mysql_db'] = null;
     $command = new PHPUnit_TextUI_Command();
     return $command->run($_SERVER['argv'], $exit);
 }
Пример #23
0
 public function run(array $argv, $exit = true)
 {
     $this->longOptions['phpguard-test-files'] = null;
     return parent::run($argv, $exit);
 }
 public function runTests()
 {
     $cliOptions = ['phpunit'];
     // first entry is the command
     array_push($cliOptions, '-c', __QCUBED_CORE__ . '/tests/phpunithtml.xml');
     // the config file is here
     //$cliOptions[] = __QCUBED_CORE__ . '/tests'; // last entry is the directory where the tests are
     $tester = new PHPUnit_TextUI_Command();
     $tester->run($cliOptions);
 }