本文整理汇总了PHP中PHPUnit_TextUI_Command类的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_TextUI_Command类的具体用法?PHP PHPUnit_TextUI_Command怎么用?PHP PHPUnit_TextUI_Command使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PHPUnit_TextUI_Command类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* 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: runTests
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: execute
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: execute
/**
* (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);
}
示例5: run
/**
* 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;
}
示例6: phpunit
/**
* 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]);
}
}
}
}
}
示例7: run
/**
* Runs PHPUnit.
*
* @return void
*/
public function run()
{
require_once 'PHPUnit/Autoload.php';
/** @var string */
define('PHPUnit_MAIN_METHOD', 'PHPUnit_TextUI_Command::main');
PHPUnit_TextUI_Command::main();
}
示例8: runAction
/**
* Should run tests in browser
* @param null $filterClass
*/
public function runAction($filterClass = null)
{
// Make sure PHPUnit is autoloaded
require_once 'PHPUnit/Autoload.php';
set_time_limit(3600);
$version = \PHPUnit_Runner_Version::id();
$kernel_dir = $this->container->getParameter('kernel.root_dir');
chdir($kernel_dir);
// This will force the printer class to be autoloaded by Symfony, before PHPUnit tries to (and does not) find it
$printerClass = 'Goutte\\DoodleBundle\\Tools\\PHPUnit\\HtmlResultPrinter';
if (!class_exists($printerClass)) {
$printerClass = false;
}
$argv = array();
$argv[] = 'phpunit';
if ($filterClass) {
$argv[] = '--filter';
$argv[] = $filterClass;
}
if (version_compare($version, "3.6.0") >= 0) {
if ($printerClass) {
$argv[] = '--printer';
$argv[] = $printerClass;
}
$_SERVER['argv'] = $argv;
\PHPUnit_TextUI_Command::main(true);
} else {
ob_end_clean();
echo '<pre>';
$_SERVER['argv'] = $argv;
\PHPUnit_TextUI_Command::main(false);
echo '</pre>';
exit;
}
}
示例9: main
/**
* 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);
}
示例10: execute
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);
}
示例11: main
/**
* 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);
}
示例12: run
/**
* Runs PHPUnit.
*
* @return void
*/
public function run()
{
// Store current TYPO3 configuration and set the default one
// This is needed as the configuration might include closures which cannot be backed up
$globalBackup = $this->removeClosures($GLOBALS['TYPO3_CONF_VARS']);
// Run unit tests
/** @var string */
define('PHPUnit_MAIN_METHOD', 'PHPUnit_TextUI_Command::main');
PHPUnit_TextUI_Command::main();
// Restore configuration
$GLOBALS['TYPO3_CONF_VARS'] = array_merge($GLOBALS['TYPO3_CONF_VARS'], $globalBackup);
}
示例13: showHelp
protected function showHelp()
{
parent::showHelp();
print <<<EOT
--rerun Runs tests that failed on last execution.
EOT;
}
示例14: showHelp
public function showHelp()
{
parent::showHelp();
print <<<EOT
--order <rand[:seed]> Randomize the order of the tests. Optionally you can pass a seed to run a specific order.
EOT;
}
示例15: handleArguments
/**
* {@inheritdoc}
*/
protected function handleArguments(array $argv)
{
parent::handleArguments($argv);
if (array_key_exists('testSuffixes', $this->arguments)) {
$fileSystem = new FileSystem();
$filePatterns = array();
foreach ($this->arguments['testSuffixes'] as $testSuffix) {
$filePatterns[] = preg_quote($testSuffix) . '$';
}
$this->testTargetRepository->setResources(array(empty($this->arguments['testFile']) ? $this->arguments['test'] : $this->arguments['testFile']));
$this->testTargetRepository->setFilePattern(implode('|', $filePatterns));
}
}