['testPHPVersionOperatorNoSpace', [ 'PHP' => ['version' => '99', 'operator' => '>='] ] ], ['testPHPUnitVersionOperatorLessThan', [ 'PHPUnit' => ['version' => '1.0', 'operator' => '<'] ] ], ['testPHPUnitVersionOperatorLessThanEquals', [ 'PHPUnit' => ['version' => '1.0', 'operator' => '<='] ] ], ['testPHPUnitVersionOperatorGreaterThan', [ 'PHPUnit' => ['version' => '99', 'operator' => '>'] ] ], ['testPHPUnitVersionOperatorGreaterThanEquals', [ 'PHPUnit' => ['version' => '99', 'operator' => '>='] ] ], ['testPHPUnitVersionOperatorEquals', [ 'PHPUnit' => ['version' => '1.0', 'operator' => '='] ] ], ['testPHPUnitVersionOperatorDoubleEquals', [ 'PHPUnit' => ['version' => '1.0', 'operator' => '=='] ] ], ['testPHPUnitVersionOperatorBangEquals', [ 'PHPUnit' => ['version' => '99', 'operator' => '!='] ] ], ['testPHPUnitVersionOperatorNotEquals', [ 'PHPUnit' => ['version' => '99', 'operator' => '<>'] ] ], ['testPHPUnitVersionOperatorNoSpace', [ 'PHPUnit' => ['version' => '99', 'operator' => '>='] ] ], ['testExtensionVersionOperatorLessThanEquals', [ 'extensions' => ['testExtOne'], 'extension_versions' => ['testExtOne' => ['version' => '1.0', 'operator' => '<=']] ] ], ['testExtensionVersionOperatorGreaterThan', [ 'extensions' => ['testExtOne'], 'extension_versions' => ['testExtOne' => ['version' => '99', 'operator' => '>']] ] ], ['testExtensionVersionOperatorGreaterThanEquals', [ 'extensions' => ['testExtOne'], 'extension_versions' => ['testExtOne' => ['version' => '99', 'operator' => '>=']] ] ], ['testExtensionVersionOperatorEquals', [ 'extensions' => ['testExtOne'], 'extension_versions' => ['testExtOne' => ['version' => '1.0', 'operator' => '=']] ] ], ['testExtensionVersionOperatorDoubleEquals', [ 'extensions' => ['testExtOne'], 'extension_versions' => ['testExtOne' => ['version' => '1.0', 'operator' => '==']] ] ], ['testExtensionVersionOperatorBangEquals', [ 'extensions' => ['testExtOne'], 'extension_versions' => ['testExtOne' => ['version' => '99', 'operator' => '!=']] ] ], ['testExtensionVersionOperatorNotEquals', [ 'extensions' => ['testExtOne'], 'extension_versions' => ['testExtOne' => ['version' => '99', 'operator' => '<>']] ] ], ['testExtensionVersionOperatorNoSpace', [ 'extensions' => ['testExtOne'], 'extension_versions' => ['testExtOne' => ['version' => '99', 'operator' => '>=']] ] ], ]; } public function testGetRequirementsMergesClassAndMethodDocBlocks() { $expectedAnnotations = [ 'PHP' => ['version' => '5.4', 'operator' => ''], 'PHPUnit' => ['version' => '3.7', 'operator' => ''], 'OS' => '/WINNT/i', 'functions' => [ 'testFuncClass', 'testFuncMethod', ], 'extensions' => [ 'testExtClass', 'testExtMethod', ] ]; $this->assertEquals( $expectedAnnotations, PHPUnit_Util_Test::getRequirements('RequirementsClassDocBlockTest', 'testMethod') ); } /** * @dataProvider missingRequirementsProvider */ public function testGetMissingRequirements($test, $result) { $this->assertEquals( $result, PHPUnit_Util_Test::getMissingRequirements('RequirementsTest', $test) ); } public function missingRequirementsProvider() { return [ ['testOne', []], ['testNine', ['Function testFunc is required.']], ['testTen', ['Extension testExt is required.']], ['testAlwaysSkip', ['PHPUnit >= 1111111 is required.']], ['testAlwaysSkip2', ['PHP >= 9999999 is required.']], ['testAlwaysSkip3', ['Operating system matching /DOESNOTEXIST/i is required.']], ['testAllPossibleRequirements', [ 'PHP >= 99-dev is required.', 'PHPUnit >= 9-dev is required.', 'Operating system matching /DOESNOTEXIST/i is required.', 'Function testFuncOne is required.', 'Function testFuncTwo is required.', 'Extension testExtOne is required.', 'Extension testExtTwo is required.', 'Extension testExtThree >= 2.0 is required.', ]], ['testPHPVersionOperatorLessThan', ['PHP < 5.4 is required.']], ['testPHPVersionOperatorLessThanEquals', ['PHP <= 5.4 is required.']], ['testPHPVersionOperatorGreaterThan', ['PHP > 99 is required.']], ['testPHPVersionOperatorGreaterThanEquals', ['PHP >= 99 is required.']], ['testPHPVersionOperatorNoSpace', ['PHP >= 99 is required.']], ['testPHPVersionOperatorEquals', ['PHP = 5.4 is required.']], ['testPHPVersionOperatorDoubleEquals', ['PHP == 5.4 is required.']], ['testPHPUnitVersionOperatorLessThan', ['PHPUnit < 1.0 is required.']], ['testPHPUnitVersionOperatorLessThanEquals', ['PHPUnit <= 1.0 is required.']], ['testPHPUnitVersionOperatorGreaterThan', ['PHPUnit > 99 is required.']], ['testPHPUnitVersionOperatorGreaterThanEquals', ['PHPUnit >= 99 is required.']], ['testPHPUnitVersionOperatorEquals', ['PHPUnit = 1.0 is required.']], ['testPHPUnitVersionOperatorDoubleEquals', ['PHPUnit == 1.0 is required.']], ['testPHPUnitVersionOperatorNoSpace', ['PHPUnit >= 99 is required.']], ['testExtensionVersionOperatorLessThan', ['Extension testExtOne < 1.0 is required.']], ['testExtensionVersionOperatorLessThanEquals', ['Extension testExtOne <= 1.0 is required.']], ['testExtensionVersionOperatorGreaterThan', ['Extension testExtOne > 99 is required.']], ['testExtensionVersionOperatorGreaterThanEquals', ['Extension testExtOne >= 99 is required.']], ['testExtensionVersionOperatorEquals', ['Extension testExtOne = 1.0 is required.']], ['testExtensionVersionOperatorDoubleEquals', ['Extension testExtOne == 1.0 is required.']], ['testExtensionVersionOperatorNoSpace', ['Extension testExtOne >= 99 is required.']], ]; } /** * @todo This test does not really test functionality of PHPUnit_Util_Test */ public function testGetProvidedDataRegEx() { $result = preg_match(PHPUnit_Util_Test::REGEX_DATA_PROVIDER, '@dataProvider method', $matches); $this->assertEquals(1, $result); $this->assertEquals('method', $matches[1]); $result = preg_match(PHPUnit_Util_Test::REGEX_DATA_PROVIDER, '@dataPr * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Prettifies class and method names for use in TestDox documentation. */ class PHPUnit_Util_TestDox_NamePrettifier { /** * @var string */ protected $prefix = 'Test'; /** * @var string */ protected $suffix = 'Test'; /** * @var array */ protected $strings = []; /** * Prettifies the name of a test class. * * @param string $name * * @return string */ public function prettifyTestClass($name) { $title = $name; if ($this->suffix !== null && $this->suffix == substr($name, -1 * strlen($this->suffix))) { $title = substr($title, 0, strripos($title, $this->suffix)); } if ($this->prefix !== null && $this->prefix == substr($name, 0, strlen($this->prefix))) { $title = substr($title, strlen($this->prefix)); } if (substr($title, 0, 1) == '\\') { $title = substr($title, 1); } return $title; } /** * Prettifies the name of a test method. * * @param string $name * * @return string */ public function prettifyTestMethod($name) { $buffer = ''; if (!is_string($name) || strlen($name) == 0) { return $buffer; } $string = preg_replace('#\d+$#', '', $name, -1, $count); if (in_array($string, $this->strings)) { $name = $string; } elseif ($count == 0) { $this->strings[] = $string; } if (substr($name, 0, 4) == 'test') { $name = substr($name, 4); } if (strlen($name) == 0) { return $buffer; } $name[0] = strtoupper($name[0]); if (strpos($name, '_') !== false) { return trim(str_replace('_', ' ', $name)); } $max = strlen($name); $wasNumeric = false; for ($i = 0; $i < $max; $i++) { if ($i > 0 && ord($name[$i]) >= 65 && ord($name[$i]) <= 90) { $buffer .= ' ' . strtolower($name[$i]); } else { $isNumeric = is_numeric($name[$i]); if (!$wasNumeric && $isNumeric) { $buffer .= ' '; $wasNumeric = true; } if ($wasNumeric && !$isNumeric) { $wasNumeric = false; } $buffer .= $name[$i]; } } return $buffer; } /** * Sets the prefix of test names. * * @param string $prefix */ public function setPrefix($prefix) { $this->prefix = $prefix; } /** * Sets the suffix of test names. * * @param string $suffix */ public function setSuffix($suffix) { $this->suffix = $suffix; } } e" aria-hidden="true">

23

Journals

  • 26000+

    Authors

  • 10

    Indexing Services

  • 600

    Conference Published

  • 1200+ Eminent

    Faculty