id() public static method

Returns the current version of PHPUnit.
public static id ( ) : string
return string
Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 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;
     }
 }
 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();
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 /**
  * 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;
     }
 }
Ejemplo n.º 6
0
 /**
  * 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');
     }
 }
Ejemplo n.º 7
0
 /**
  * @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();
 }
Ejemplo n.º 8
0
 /**
  * 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');
     }
 }
Ejemplo n.º 9
0
 /**
  * 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);
 }
Ejemplo n.º 10
0
 /**
  * @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);
     }
 }
 /**
  * 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 <*****@*****.**>
  * @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);
     }
 }
 public function prepare()
 {
     if (version_compare(PHPUnit_Runner_Version::id(), '3.5.0beta1', '>=')) {
         require_once 'PHPUnit/Autoload.php';
     } else {
         require_once 'PHPUnit/Framework.php';
     }
 }
Ejemplo n.º 13
0
 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();
     }
 }
 /**
  * @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));
 }
Ejemplo n.º 15
0
 /**
  * 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);
 }
 /**
  * InvalidIfRefererDoesNotMatchHost
  *
  * @return void
  */
 public function testInvalidIfRefererDoesNotMatchHost()
 {
     $GLOBALS['_SERVER']['HTTP_USER_AGENT'] = 'PHPUnit/' . \PHPUnit_Runner_Version::id();
     $GLOBALS['_SERVER']['HTTP_REFERER'] = 'http://example.org';
     $GLOBALS['_SERVER']['HTTP_HOST'] = 'http://foo.bar';
     $validationResult = $this->sut->validate($this->contactMock);
     $this->assertEquals(1400451586, $validationResult->getFirstError()->getCode());
 }
Ejemplo n.º 17
0
 public function setUp()
 {
     error_reporting(E_ALL | E_STRICT);
     $_SERVER['REQUEST_URI'] = '';
     $this->router = new Zend_Controller_RewriteRouter();
     $this->router->setRewriteBase('/');
     $this->dispatcher = new Zend_Controller_Dispacher_Mock();
     $this->version = version_compare(PHPUnit_Runner_Version::id(), '3.0.0alpha11') >= 0 ? 3 : 2;
 }
Ejemplo n.º 18
0
 public static function assertType($x, $y)
 {
     #global $phpunit_version;
     if (version_compare(PHPUnit_Runner_Version::id(), '3.5') < 0) {
         return PHPUnit_Framework_TestCase::assertType($x, $y);
     } else {
         return PHPUnit_Framework_TestCase::assertInternalType($x, $y);
     }
 }
Ejemplo n.º 19
0
 public function testThrow2()
 {
     if (!method_exists('PHPUnit_Runner_Version', 'id') || version_compare(\PHPUnit_Runner_Version::id(), '5.2.0', '<')) {
         $this->setExpectedException('\\Exception', 'error');
     } else {
         $this->expectException('\\Exception', 'error');
     }
     $t = new \Test\TryTest();
     $t->testThrow2();
 }
Ejemplo n.º 20
0
 protected function getProductManager($qbCallback)
 {
     if (version_compare(\PHPUnit_Runner_Version::id(), '5.0.0', '>=')) {
         $this->markTestSkipped('Not compatible with PHPUnit 5.');
     }
     $em = EntityManagerMockFactory::create($this, $qbCallback, array('sku', 'slug', 'name'));
     $registry = $this->getMock('Doctrine\\Common\\Persistence\\ManagerRegistry');
     $registry->expects($this->any())->method('getManagerForClass')->will($this->returnValue($em));
     return new ProductManager('Sonata\\PageBundle\\Entity\\BaseProduct', $registry);
 }
 public function get_phpunit_version($as_string = false)
 {
     $ver = PHPUnit_Runner_Version::id();
     if (!$as_string) {
         $ver_array = explode('.', $ver);
         $ver_array[0] .= '.';
         $ver = (double) implode('', $ver_array);
     }
     return $ver;
 }
 public function testgetPostalXWindow()
 {
     if (headers_sent() || version_compare(PHPUnit_Runner_Version::id(), '3.3.0', '<')) {
         $this->markTestSkipped('phpunit version < 3.3.0 cant cope with headers');
     }
     ob_start();
     $this->_uit->getPostalXWindow();
     $html = ob_get_clean();
     $this->assertGreaterThan(100, strlen($html));
 }
Ejemplo n.º 23
0
 public function basicProvider()
 {
     if (!extension_loaded('intl')) {
         if (version_compare(\PHPUnit_Runner_Version::id(), '3.8.0-dev') === 1) {
             $this->markTestSkipped('ext/intl not enabled');
         } else {
             return array(array());
         }
     }
     return array(array('May 30, 2013', true, array('locale' => 'en', 'dateType' => \IntlDateFormatter::MEDIUM, 'timeType' => \IntlDateFormatter::NONE)), array('30.Mai.2013', true, array('locale' => 'de', 'dateType' => \IntlDateFormatter::MEDIUM, 'timeType' => \IntlDateFormatter::NONE)), array('30 Mei 2013', true, array('locale' => 'nl', 'dateType' => \IntlDateFormatter::MEDIUM, 'timeType' => \IntlDateFormatter::NONE)), array('May 38, 2013', false, array('locale' => 'en', 'dateType' => \IntlDateFormatter::FULL, 'timeType' => \IntlDateFormatter::NONE)), array('Dienstag, 28. Mai 2013', true, array('locale' => 'de', 'dateType' => \IntlDateFormatter::FULL, 'timeType' => \IntlDateFormatter::NONE)), array('Maandag 28 Mei 2013', true, array('locale' => 'nl', 'dateType' => \IntlDateFormatter::FULL, 'timeType' => \IntlDateFormatter::NONE)), array('0:00', true, array('locale' => 'nl', 'dateType' => \IntlDateFormatter::NONE, 'timeType' => \IntlDateFormatter::SHORT)), array('01:01', true, array('locale' => 'nl', 'dateType' => \IntlDateFormatter::NONE, 'timeType' => \IntlDateFormatter::SHORT)), array('01:01:01', true, array('locale' => 'nl', 'dateType' => \IntlDateFormatter::NONE, 'timeType' => \IntlDateFormatter::MEDIUM)), array('01:01:01 +2', true, array('locale' => 'nl', 'dateType' => \IntlDateFormatter::NONE, 'timeType' => \IntlDateFormatter::LONG)), array('03:30:42 am +2', true, array('locale' => 'en', 'dateType' => \IntlDateFormatter::NONE, 'timeType' => \IntlDateFormatter::LONG)));
 }
Ejemplo n.º 24
0
 public function currencyTestsDataProvider()
 {
     if (!extension_loaded('intl')) {
         if (version_compare(\PHPUnit_Runner_Version::id(), '3.8.0-dev') === 1) {
             $this->markTestSkipped('ext/intl not enabled');
         } else {
             return array(array());
         }
     }
     return array(array('de_DE', NumberFormatter::DECIMAL, NumberFormatter::TYPE_DOUBLE, null, 1234567.8912345679, '1.234.567,891'), array('de_DE', NumberFormatter::DECIMAL, NumberFormatter::TYPE_DOUBLE, 6, 1234567.8912345679, '1.234.567,891235'), array('de_DE', NumberFormatter::PERCENT, NumberFormatter::TYPE_DOUBLE, null, 1234567.8912345679, '123.456.789 %'), array('de_DE', NumberFormatter::PERCENT, NumberFormatter::TYPE_DOUBLE, 1, 1234567.8912345679, '123.456.789,1 %'), array('de_DE', NumberFormatter::SCIENTIFIC, NumberFormatter::TYPE_DOUBLE, null, 1234567.8912345679, '1,23456789123457E6'), array('ru_RU', NumberFormatter::DECIMAL, NumberFormatter::TYPE_DOUBLE, null, 1234567.8912345679, '1 234 567,891'), array('ru_RU', NumberFormatter::PERCENT, NumberFormatter::TYPE_DOUBLE, null, 1234567.8912345679, '123 456 789 %'), array('ru_RU', NumberFormatter::SCIENTIFIC, NumberFormatter::TYPE_DOUBLE, null, 1234567.8912345679, '1,23456789123457E6'), array('en_US', NumberFormatter::DECIMAL, NumberFormatter::TYPE_DOUBLE, null, 1234567.8912345679, '1,234,567.891'), array('en_US', NumberFormatter::PERCENT, NumberFormatter::TYPE_DOUBLE, null, 1234567.8912345679, '123,456,789%'), array('en_US', NumberFormatter::SCIENTIFIC, NumberFormatter::TYPE_DOUBLE, null, 1234567.8912345679, '1.23456789123457E6'));
 }
Ejemplo n.º 25
0
 public function formattedToNumberProvider()
 {
     if (!extension_loaded('intl')) {
         if (version_compare(\PHPUnit_Runner_Version::id(), '3.8.0-dev') === 1) {
             $this->markTestSkipped('ext/intl not enabled');
         } else {
             return array(array());
         }
     }
     return array(array('en_US', NumberFormatter::DEFAULT_STYLE, NumberFormatter::TYPE_DOUBLE, '1,234,567.891', 1234567.891), array('de_DE', NumberFormatter::DEFAULT_STYLE, NumberFormatter::TYPE_DOUBLE, '1.234.567,891', 1234567.891), array('ru_RU', NumberFormatter::DEFAULT_STYLE, NumberFormatter::TYPE_DOUBLE, '1 234 567,891', 1234567.891));
 }
Ejemplo n.º 26
0
 /**
  * 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) {
         if (!class_exists('PHPUnit_Runner_Version')) {
             require_once 'PHPUnit/Runner/Version.php';
         }
         self::$_assert_type_compatability = version_compare(PHPUnit_Runner_Version::id(), '3.5.0', '<=');
     }
     $this->_helpers = new Unittest_Helpers();
     $this->setEnvironment($this->environmentDefault);
 }
Ejemplo n.º 27
0
 public function testResource()
 {
     $t = new MethodArgs();
     $t->setResourceStrict(STDIN);
     $this->assertSame(STDIN, $t->a);
     if (!method_exists('PHPUnit_Runner_Version', 'id') || version_compare(\PHPUnit_Runner_Version::id(), '5.2.0', '<')) {
         $this->setExpectedException('\\Exception');
     } else {
         $this->expectException('\\Exception');
     }
     $t->setResourceStrict(true);
 }
Ejemplo n.º 28
0
 public static function handleError($level, $message, $file, $line)
 {
     $isFiltered = false;
     if (version_compare(PHPUnit_Runner_Version::id(), '3.5.0') >= 0) {
         $isFiltered = PHP_CodeCoverage::getInstance()->filter()->isFiltered($file, array(), true);
     } else {
         $isFiltered = PHPUnit_Util_Filter::isFiltered($file, true, true);
     }
     if (!$isFiltered) {
         return PHPUnit_Util_ErrorHandler::handleError($level, $message, $file, $line);
     }
 }
 private function createPhpUnitConstraint()
 {
     // Matching by regular expression was added in PHPUnit 4.2.0
     if ($this->useRegExp && version_compare(\PHPUnit_Runner_Version::id(), '4.2.0', '<')) {
         throw new \InvalidArgumentException('Currently installed PHPUnit version does not support matching exception messages by regular expression.');
     }
     // Matching by regular expression was moved to a separate constraint in PHPUnit 4.3.0
     if ($this->useRegExp && class_exists('PHPUnit_Framework_Constraint_ExceptionMessageRegExp')) {
         return new \PHPUnit_Framework_Constraint_ExceptionMessageRegExp($this->expectedMessage);
     }
     return new \PHPUnit_Framework_Constraint_ExceptionMessage($this->expectedMessage);
 }
Ejemplo n.º 30
0
 function __construct()
 {
     $this->longOptions['all-modules'] = null;
     $this->longOptions['module'] = null;
     $this->longOptions['entrypoint='] = null;
     $this->longOptions['testtype='] = null;
     $this->version36 = version_compare(PHPUnit_Runner_Version::id(), '3.6') > -1;
     if (!$this->version36) {
         require_once 'PHPUnit/Runner/TestCollector.php';
         require_once 'PHPUnit/Runner/IncludePathTestCollector.php';
     }
 }