本文整理汇总了PHP中PHPUnit_Runner_Version::id方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Runner_Version::id方法的具体用法?PHP PHPUnit_Runner_Version::id怎么用?PHP PHPUnit_Runner_Version::id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Runner_Version
的用法示例。
在下文中一共展示了PHPUnit_Runner_Version::id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPhpUnitVersion
/**
* Get PHPUnit version
* @return string
*/
protected static function getPhpUnitVersion()
{
if (method_exists('\\PHPUnit_Runner_Version', 'id')) {
return \PHPUnit_Runner_Version::id();
}
return \PHPUnit_Runner_Version::VERSION;
}
示例2: checkVersion
public static function checkVersion()
{
try {
// For PHPUnit < 3.7
if (is_file('PHPUnit/Runner/Version.php') && is_readable('PHPUnit/Runner/Version.php')) {
include_once 'PHPUnit/Runner/Version.php';
$actualVersion = PHPUnit_Runner_Version::id();
} elseif (method_exists('PHPUnit_Runner_Version', 'id')) {
$actualVersion = PHPUnit_Runner_Version::id();
} else {
// PHPUnit probably is not installed.
throw new Exception();
}
if (version_compare($actualVersion, self::$phpUnitMinimumVersion) < 0) {
echo "\n Zurmo tests are not working with PHPUnit {$actualVersion} \n";
echo "PHPUnit version must be equal and higher then PHPUnit " . self::$phpUnitMinimumVersion . " and ";
echo "lower then " . self::$phpUnitMaximumVersion . "\n";
echo "Please upgrade your PHPUnit version \n\n";
exit;
}
if (version_compare($actualVersion, self::$phpUnitMaximumVersion) >= 0) {
echo "\n Zurmo tests are not working with PHPUnit {$actualVersion} \n";
echo "PHPUnit version must be equal and higher then PHPUnit " . self::$phpUnitMinimumVersion . " and ";
echo "lower then " . self::$phpUnitMaximumVersion . "\n";
echo "Please downgrade your PHPUnit version \n\n";
exit;
}
return;
} catch (Exception $e) {
echo "You must install PHPUnit, before running tests";
exit;
}
}
示例3: setUp
public function setUp()
{
if (version_compare('3.6.0', PHPUnit_Runner_Version::id()) == 1) {
$this->markTestSkipped('The tested class is not compatible with current version of PHPUnit.');
}
$this->constraint = new Phake_PHPUnit_VerifierResultConstraintV3d6();
}
示例4: get_test_config
public static function get_test_config()
{
$config = array();
if (extension_loaded('sqlite') && version_compare(PHPUnit_Runner_Version::id(), '3.4.15', '>=')) {
$config = array_merge($config, array('dbms' => 'sqlite', 'dbhost' => dirname(__FILE__) . '/../phpbb_unit_tests.sqlite2', 'dbport' => '', 'dbname' => '', 'dbuser' => '', 'dbpasswd' => ''));
}
if (isset($_SERVER['PHPBB_TEST_CONFIG'])) {
// Could be an absolute path
$test_config = $_SERVER['PHPBB_TEST_CONFIG'];
} else {
$test_config = dirname(__FILE__) . '/../test_config.php';
}
if (file_exists($test_config)) {
include $test_config;
$config = array_merge($config, array('dbms' => $dbms, 'dbhost' => $dbhost, 'dbport' => $dbport, 'dbname' => $dbname, 'dbuser' => $dbuser, 'dbpasswd' => $dbpasswd, 'custom_dsn' => isset($custom_dsn) ? $custom_dsn : ''));
if (isset($phpbb_functional_url)) {
$config['phpbb_functional_url'] = $phpbb_functional_url;
}
}
if (isset($_SERVER['PHPBB_TEST_DBMS'])) {
$config = array_merge($config, array('dbms' => isset($_SERVER['PHPBB_TEST_DBMS']) ? $_SERVER['PHPBB_TEST_DBMS'] : '', 'dbhost' => isset($_SERVER['PHPBB_TEST_DBHOST']) ? $_SERVER['PHPBB_TEST_DBHOST'] : '', 'dbport' => isset($_SERVER['PHPBB_TEST_DBPORT']) ? $_SERVER['PHPBB_TEST_DBPORT'] : '', 'dbname' => isset($_SERVER['PHPBB_TEST_DBNAME']) ? $_SERVER['PHPBB_TEST_DBNAME'] : '', 'dbuser' => isset($_SERVER['PHPBB_TEST_DBUSER']) ? $_SERVER['PHPBB_TEST_DBUSER'] : '', 'dbpasswd' => isset($_SERVER['PHPBB_TEST_DBPASSWD']) ? $_SERVER['PHPBB_TEST_DBPASSWD'] : '', 'custom_dsn' => isset($_SERVER['PHPBB_TEST_CUSTOM_DSN']) ? $_SERVER['PHPBB_TEST_CUSTOM_DSN'] : ''));
}
if (isset($_SERVER['PHPBB_FUNCTIONAL_URL'])) {
$config = array_merge($config, array('phpbb_functional_url' => isset($_SERVER['PHPBB_FUNCTIONAL_URL']) ? $_SERVER['PHPBB_FUNCTIONAL_URL'] : ''));
}
return $config;
}
示例5: 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;
}
}
示例6: init
/**
* Initialize Task.
* This method includes any necessary PHPUnit2 libraries and triggers
* appropriate error if they cannot be found. This is not done in header
* because we may want this class to be loaded w/o triggering an error.
*/
function init()
{
if (version_compare(PHP_VERSION, '5.0.3') < 0) {
throw new BuildException("PHPUnit2Task requires PHP version >= 5.0.3.", $this->getLocation());
}
/**
* Determine PHPUnit version number
*/
@(include_once 'PHPUnit/Runner/Version.php');
@(include_once 'PHPUnit2/Runner/Version.php');
if (class_exists('PHPUnit_Runner_Version')) {
$version = PHPUnit_Runner_Version::id();
} elseif (class_exists('PHPUnit2_Runner_Version')) {
$version = PHPUnit2_Runner_Version::id();
} else {
throw new BuildException("PHPUnit task depends on PHPUnit 2 or 3 package being installed.", $this->getLocation());
}
if (version_compare($version, "3.0.0") >= 0) {
PHPUnitUtil::$installedVersion = 3;
if (version_compare($version, "3.2.0") >= 0) {
PHPUnitUtil::$installedMinorVersion = 2;
}
} else {
PHPUnitUtil::$installedVersion = 2;
}
/**
* Other dependencies that should only be loaded when class is actually used.
*/
require_once 'phing/tasks/ext/phpunit/PHPUnitTestRunner.php';
require_once 'phing/tasks/ext/phpunit/BatchTest.php';
require_once 'phing/tasks/ext/phpunit/FormatterElement.php';
/**
* Add some defaults to the PHPUnit filter
*/
if (PHPUnitUtil::$installedVersion == 3) {
require_once 'PHPUnit/Framework.php';
require_once 'PHPUnit/Util/Filter.php';
// point PHPUnit_MAIN_METHOD define to non-existing method
if (!defined('PHPUnit_MAIN_METHOD')) {
define('PHPUnit_MAIN_METHOD', 'PHPUnitTask::undefined');
}
PHPUnit_Util_Filter::addFileToFilter('PHPUnitTask.php', 'PHING');
PHPUnit_Util_Filter::addFileToFilter('PHPUnitTestRunner.php', 'PHING');
PHPUnit_Util_Filter::addFileToFilter('phing/Task.php', 'PHING');
PHPUnit_Util_Filter::addFileToFilter('phing/Target.php', 'PHING');
PHPUnit_Util_Filter::addFileToFilter('phing/Project.php', 'PHING');
PHPUnit_Util_Filter::addFileToFilter('phing/Phing.php', 'PHING');
PHPUnit_Util_Filter::addFileToFilter('phing.php', 'PHING');
} else {
require_once 'PHPUnit2/Framework.php';
require_once 'PHPUnit2/Util/Filter.php';
PHPUnit2_Util_Filter::addFileToFilter('PHPUnitTask.php');
PHPUnit2_Util_Filter::addFileToFilter('PHPUnitTestRunner.php');
PHPUnit2_Util_Filter::addFileToFilter('phing/Task.php');
PHPUnit2_Util_Filter::addFileToFilter('phing/Target.php');
PHPUnit2_Util_Filter::addFileToFilter('phing/Project.php');
PHPUnit2_Util_Filter::addFileToFilter('phing/Phing.php');
PHPUnit2_Util_Filter::addFileToFilter('phing.php');
}
}
示例7: process
/**
* @param PHPUnit_Framework_TestResult $result
*/
public function process(PHPUnit_Framework_TestResult $result, $minLines = 5, $minMatches = 70)
{
$codeCoverage = $result->getCodeCoverageInformation();
$summary = PHPUnit_Util_CodeCoverage::getSummary($codeCoverage);
$files = array_keys($summary);
$metrics = new PHPUnit_Util_Metrics_Project($files, $summary, TRUE, $minLines, $minMatches);
$document = new DOMDocument('1.0', 'UTF-8');
$document->formatOutput = TRUE;
$cpd = $document->createElement('pmd-cpd');
$cpd->setAttribute('version', 'PHPUnit ' . PHPUnit_Runner_Version::id());
$document->appendChild($cpd);
foreach ($metrics->getDuplicates() as $duplicate) {
$xmlDuplication = $cpd->appendChild($document->createElement('duplication'));
$xmlDuplication->setAttribute('lines', $duplicate['numLines']);
$xmlDuplication->setAttribute('tokens', $duplicate['numTokens']);
$xmlFile = $xmlDuplication->appendChild($document->createElement('file'));
$xmlFile->setAttribute('path', $duplicate['fileA']->getPath());
$xmlFile->setAttribute('line', $duplicate['firstLineA']);
$xmlFile = $xmlDuplication->appendChild($document->createElement('file'));
$xmlFile->setAttribute('path', $duplicate['fileB']->getPath());
$xmlFile->setAttribute('line', $duplicate['firstLineB']);
$xmlDuplication->appendChild($document->createElement('codefragment', PHPUnit_Util_XML::prepareString(join('', array_slice($duplicate['fileA']->getLines(), $duplicate['firstLineA'] - 1, $duplicate['numLines'])))));
}
$this->write($document->saveXML());
$this->flush();
}
示例8: init
/**
* Initialize Task.
* This method includes any necessary PHPUnit libraries and triggers
* appropriate error if they cannot be found. This is not done in header
* because we may want this class to be loaded w/o triggering an error.
*/
public function init()
{
/**
* Determine PHPUnit version number
*/
@(include_once 'PHPUnit/Runner/Version.php');
if (!class_exists('PHPUnit_Runner_Version')) {
throw new BuildException("PHPUnitTask requires PHPUnit to be installed", $this->getLocation());
}
$version = PHPUnit_Runner_Version::id();
if (version_compare($version, '3.6.0') < 0) {
throw new BuildException("PHPUnitTask requires PHPUnit version >= 3.6.0", $this->getLocation());
}
/**
* Other dependencies that should only be loaded when class is actually used.
*/
require_once 'phing/tasks/ext/phpunit/PHPUnitTestRunner.php';
require_once 'phing/tasks/ext/phpunit/BatchTest.php';
require_once 'phing/tasks/ext/phpunit/FormatterElement.php';
/**
* point PHPUnit_MAIN_METHOD define to non-existing method
*/
if (!defined('PHPUnit_MAIN_METHOD')) {
define('PHPUnit_MAIN_METHOD', 'PHPUnitTask::undefined');
}
}
示例9: init
/**
* Initialize Task.
* This method includes any necessary PHPUnit2 libraries and triggers
* appropriate error if they cannot be found. This is not done in header
* because we may want this class to be loaded w/o triggering an error.
*/
public function init()
{
if (version_compare(PHP_VERSION, '5.0.3') < 0) {
throw new BuildException("PHPUnitTask requires PHP version >= 5.0.3", $this->getLocation());
}
/**
* Determine PHPUnit version number
*/
@(include_once 'PHPUnit/Runner/Version.php');
$version = PHPUnit_Runner_Version::id();
if (version_compare($version, '3.2.0') < 0) {
throw new BuildException("PHPUnitTask requires PHPUnit version >= 3.2.0", $this->getLocation());
}
/**
* Other dependencies that should only be loaded when class is actually used.
*/
require_once 'phing/tasks/ext/phpunit/PHPUnitTestRunner.php';
require_once 'phing/tasks/ext/phpunit/BatchTest.php';
require_once 'phing/tasks/ext/phpunit/FormatterElement.php';
/**
* Add some defaults to the PHPUnit filter
*/
$pwd = dirname(__FILE__);
require_once 'PHPUnit/Framework.php';
require_once 'PHPUnit/Util/Filter.php';
// point PHPUnit_MAIN_METHOD define to non-existing method
if (!defined('PHPUnit_MAIN_METHOD')) {
define('PHPUnit_MAIN_METHOD', 'PHPUnitTask::undefined');
}
$path = realpath($pwd . '/../../../');
PHPUnit_Util_Filter::addDirectoryToFilter($path);
}
示例10: validateCallable
/**
* @param $funcName
* @throws \BadMethodCallException
*/
protected function validateCallable($funcName)
{
if (!is_callable([self::ASSERT_CLASS, $funcName])) {
$m = $funcName . ' is not found in ' . self::ASSERT_CLASS . '. your phpunit version is ' . \PHPUnit_Runner_Version::id();
throw new \BadMethodCallException($m);
}
}
示例11: evaluate
/**
* Overridden function to cover differences between PHPUnit 3.5 and 3.6.
* Intentionally made final so people have to use match() from now on.
* match() should be abstract really, but isn't, the usual PHPUnit quality...
*
* @param mixed The item to evaluate.
* @param string Additional information about the test (3.6+).
* @param bool Whether to return a result or throw an exception (3.6+).
*
* @author David Zülke <david.zuelke@bitextender.com>
* @since 1.0.7
*/
public function evaluate($other, $description = '', $returnResult = false)
{
if (version_compare(PHPUnit_Runner_Version::id(), '3.6', '<')) {
return $this->matches($other);
} else {
return parent::evaluate($other, $description, $returnResult);
}
}
开发者ID:horros,项目名称:agavi,代码行数:20,代码来源:AgaviBaseConstraintBecausePhpunitSucksAtBackwardsCompatibility.class.php
示例12: prepare
public function prepare()
{
if (version_compare(PHPUnit_Runner_Version::id(), '3.5.0beta1', '>=')) {
require_once 'PHPUnit/Autoload.php';
} else {
require_once 'PHPUnit/Framework.php';
}
}
示例13: getConstraint
private function getConstraint()
{
if (version_compare('3.6.0', PHPUnit_Runner_Version::id()) == 1) {
return new Phake_PHPUnit_VerifierResultConstraint();
} else {
return new Phake_PHPUnit_VerifierResultConstraintV3d6();
}
}
示例14: if_configuration_values_are_invalid_it_matches_when_exception_message_is_right_according_to_regexp
/**
* @test
*/
public function if_configuration_values_are_invalid_it_matches_when_exception_message_is_right_according_to_regexp()
{
$constraint = new ConfigurationValuesAreInvalidConstraint(new ConfigurationWithRequiredValue(), '/required[_]{1}value/', true);
if (version_compare(\PHPUnit_Runner_Version::id(), '4.2.0', '<')) {
$this->setExpectedException('\\InvalidArgumentException', 'does not support matching exception messages by regular expression');
}
$this->assertTrue($constraint->evaluate(array(array()), '', true));
}
示例15: setUp
/**
* Creates a predefined environment using the default environment
*
* Extending classes that have their own setUp() should call
* parent::setUp()
*/
public function setUp()
{
if (self::$_assert_type_compatability === NULL) {
self::$_assert_type_compatability = version_compare(PHPUnit_Runner_Version::id(), '3.5.0', '<=');
}
$this->_helpers = new Kohana_Unittest_Helpers();
$this->setEnvironment($this->environmentDefault);
}