本文整理汇总了PHP中TestRunner类的典型用法代码示例。如果您正苦于以下问题:PHP TestRunner类的具体用法?PHP TestRunner怎么用?PHP TestRunner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestRunner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public static function run($className)
{
$runner = new TestRunner();
$rc = new ReflectionClass($className);
$methods = $rc->GetMethods(ReflectionMethod::IS_PUBLIC);
foreach ($methods as $m) {
$name = $m->name;
if (!$runner->isValidTest($name)) {
continue;
}
$count = count($className::$errors);
$rt = new $className();
try {
$rt->setUp();
$rt->{$name}();
echo $count === count($className::$errors) ? "." : "F";
} catch (Exception $e) {
if ($e instanceof RedisException) {
$className::$errors[] = "Uncaught exception '" . $e->getMessage() . "' ({$name})\n";
echo 'F';
} else {
echo 'S';
}
}
}
echo "\n";
echo implode('', $className::$warnings);
if (empty($className::$errors)) {
echo "All tests passed.\n";
return 0;
}
echo implode('', $className::$errors);
return 1;
}
示例2: runner
public function runner($reg = NULL)
{
$runner = new TestRunner();
if (!empty($reg)) {
$runner->useRegistry($reg);
}
return $runner;
}
示例3: TestRunner
static function &get($directory = null, $writer = 'TextualWriter')
{
static $instance;
if (!isset($instance)) {
$instance = new TestRunner($directory);
$instance->set_writer(new $writer());
}
return $instance;
}
示例4: testPhpRQ
public function testPhpRQ()
{
if (!self::$redis instanceof Client) {
throw new \Exception('The PhpRQ test suit can be run only with php-rq-run-tests binary or by implementing
the ClientProvider and running the TestRunner in your test suite.');
}
$redisProvider = new ClientProvider();
$redisProvider->registerProvider(function () {
self::$redis->flushdb();
self::$redis->script('flush');
return self::$redis;
});
$test = new TestRunner($redisProvider);
$test->run();
}
示例5: parse_options
function parse_options()
{
$options = getopt("h", array("clients-count:", "log-junit", "verbose", "build"));
if (isset($options['h'])) {
print_info();
die;
}
if (isset($options['build'])) {
$options['verbose'] = true;
$options['log-junit'] = true;
}
if (isset($options['clients-count'])) {
define('SELENIUM_CLIENTS_COUNT', $options['clients-count']);
}
if (isset($options['log-junit'])) {
TestRunner::$log_xml = true;
shell_exec("rm /tmp/TEST*.xml");
}
if (isset($options['verbose'])) {
TestRunner::$verbose = true;
}
if (!defined('SELENIUM_CLIENTS_COUNT')) {
define('SELENIUM_CLIENTS_COUNT', 5);
}
$runner = new testRunner();
$runner->start(SELENIUM_CLIENTS_COUNT);
}
示例6: init
function init()
{
parent::init();
if (!Permission::check('ADMIN')) {
return Security::permissionFailure();
}
TestRunner::use_test_manifest();
}
示例7: process
/**
* Loads kernel file.
*
* @param ContainerBuilder $container
*/
public function process(ContainerBuilder $container)
{
// Connect to database and build manifest
$frameworkPath = $container->getParameter('behat.silverstripe_extension.framework_path');
$_GET['flush'] = 1;
require_once $frameworkPath . '/core/Core.php';
\TestRunner::use_test_manifest();
unset($_GET['flush']);
// Remove the error handler so that PHPUnit can add its own
restore_error_handler();
}
示例8: testIsTestFile
public function testIsTestFile()
{
$this->guy->createTestFolderTree($this->tmpPath1);
$this->assertTrue($this->guy->isTestFolderTree($this->tmpPath1));
// real tests
$this->assertTrue(TestRunner::isTestFile($this->tmpPath1 . DS . 'subFolder1' . DS . 'unit' . DS . 'funTest.php'));
$this->assertTrue(TestRunner::isTestFile($this->tmpPath1 . DS . 'subFolder2' . DS . 'unit' . DS . 'boringTestCest.php'));
$this->assertTrue(TestRunner::isTestFile($this->tmpPath1 . DS . 'subFolder2' . DS . 'unit' . DS . 'interestingTestCept.php'));
// not real tests
$this->assertFalse(TestRunner::isTestFile($this->tmpPath1 . DS . 'README.txt'));
$this->assertFalse(TestRunner::isTestFile($this->tmpPath1 . DS . 'nonExistentFile.txt'));
}
示例9: beforeRunTests
/**
* Overwrites beforeRunTests. Initiates coverage-report generation if
* $coverage has been set to true (@see setCoverageStatus).
*/
protected function beforeRunTests()
{
if ($this->getCoverageStatus()) {
// blacklist selected folders from coverage report
$modules = $this->moduleDirectories();
foreach (TestRunner::config()->coverage_filter_dirs as $dir) {
if ($dir[0] == '*') {
$dir = substr($dir, 1);
foreach ($modules as $module) {
PHPUnit_Util_Filter::addDirectoryToFilter(BASE_PATH . '/' . $dir);
}
} else {
PHPUnit_Util_Filter::addDirectoryToFilter(BASE_PATH . '/' . $dir);
}
}
$this->getFrameworkTestResults()->collectCodeCoverageInformation(true);
}
}
示例10: beforeRunTests
/**
* Overwrites beforeRunTests. Initiates coverage-report generation if
* $coverage has been set to true (@see setCoverageStatus).
*/
protected function beforeRunTests()
{
if ($this->getCoverageStatus()) {
$this->coverage = new PHP_CodeCoverage();
$coverage = $this->coverage;
$filter = $coverage->filter();
$modules = $this->moduleDirectories();
foreach (TestRunner::config()->coverage_filter_dirs as $dir) {
if ($dir[0] == '*') {
$dir = substr($dir, 1);
foreach ($modules as $module) {
$filter->addDirectoryToBlacklist(BASE_PATH . "/{$module}/{$dir}");
}
} else {
$filter->addDirectoryToBlacklist(BASE_PATH . '/' . $dir);
}
}
$filter->addFileToBlacklist(__FILE__, 'PHPUNIT');
$coverage->start(self::get_test_name());
}
}
示例11: files
php RunTests.php [options] [file or directory]
Options:
-p <php> Specify PHP-CGI executable to run.
-c <path> Look for php.ini in directory <path> or use <path> as php.ini.
-d key=val Define INI entry 'key' with value 'val'.
-l <path> Specify path to shared library files (LD_LIBRARY_PATH)
-s Show information about skipped tests
<?php
}
/**
* Execute tests
*/
try {
@unlink(__DIR__ . '/coverage.dat'); // @ - file may not exist
$manager = new TestRunner;
$manager->parseArguments();
$res = $manager->run();
die($res ? 0 : 1);
} catch (Exception $e) {
echo 'Error: ', $e->getMessage(), "\n";
die(2);
}
示例12: tests
function tests($request)
{
return TestRunner::create();
}
示例13: validateArgv
$this->fail($e->getMessage());
}
}
private function validateArgv()
{
try {
$argvLen = count($this->argv);
foreach (range(1, $argvLen - 1) as $argvIndex) {
if (preg_match('/\\.php$/', $this->argv[$argvIndex])) {
$this->testFile = $this->argv[$argvIndex];
}
}
if ($this->testFile == null) {
throw new \Exception('Missing argument: test file');
}
// if($argvLen > 2) {
// throw new \Exception('Too many arguments');
// }
} catch (\Exception $e) {
$this->fail($e->getMessage());
}
}
}
// $stop = getopt('', ['stop-on-fail:']);
// var_dump($stop);
// die();
// var_dump($argv);
// //var_dump($argc);
// die();
$testRunner = new TestRunner($argv);
$testRunner->run();
示例14: testUpgrade
/**
* The master test class that performs the various upgrades of the system,
* and calls private methods to test various sections of the upgrade.
*/
function testUpgrade()
{
$aConf = $GLOBALS['_MAX']['CONF'];
// Run the tests for every set of preferences that have been defined
foreach (array_keys($this->aPrefsOld) as $set) {
if ($set == 1 && $aConf['database']['type'] != 'mysql') {
// OpenX 2.4.4 is only valid for MySQL
continue;
}
// Initialise the database at schema 542
$this->initDatabase(542, array('agency', 'affiliates', 'application_variable', 'audit', 'channel', 'clients', 'preference', 'preference_advertiser', 'preference_publisher', 'acls', 'acls_channel', 'banners', 'campaigns', 'tracker_append', 'trackers', 'userlog', 'variables', 'zones'));
// Set up the database with the standard set of accounts,
// preferences and settings
$this->_setupAccounts();
$this->_setupPreferences($set);
// Perform the required upgrade on the database
$this->upgradeToVersion(543);
$this->upgradeToVersion(544);
$this->upgradeToVersion(546);
// Test the results of the upgrade
$this->_testMigratePrefsToSettings($set);
$this->_testMigratePrefsToAppVars($set);
$this->_testMigratePrefsToPrefs($set);
$this->_testMigrateUsers($set);
// Restore the testing environment
TestRunner::setupEnv(null);
$this->oDbh =& OA_DB::singleton();
}
}
示例15: dirname
<?php
ini_set("display_errors", 1);
ini_set("error_reporting", E_ALL);
require_once dirname(__FILE__).DIRECTORY_SEPARATOR."config.php";
require_once "PHPUnit/Autoload.php";
require_once "class/TestRunner.php";
$includeCoverage = false;
if(isset($_GET["coverage"]))
{
$includeCoverage = true;
}
$runner = new TestRunner(false);
if(isset($testSuite))
{
foreach($testSuite as $onePath)
{
$runner->readFolder($onePath);
}
}
if(isset($codeCoverageIgnoreDirectoryList))
{
foreach($codeCoverageIgnoreDirectoryList as $oneDirectory)
{
$runner->codeCoverageIgnoreDirectory($oneDirectory);
}
}