diff --git a/.travis.yml b/.travis.yml index ce3c047dd..4c6210529 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,23 @@ language: php php: - - 5.4 + - 5.4 before_script: - - mkdir -p vendor/SebastianBergmann - - git clone --branch=master --depth=100 --quiet git://github.com/sebastianbergmann/phpunit.git vendor/phpunit - - git clone --branch=master --depth=100 --quiet git://github.com/sebastianbergmann/phpunit-mock-objects.git vendor/phpunit-mock-objects - - git clone --branch=master --depth=100 --quiet git://github.com/sebastianbergmann/php-text-template.git vendor/php-text-template - - git clone --branch=master --depth=100 --quiet git://github.com/sebastianbergmann/php-token-stream.git vendor/php-token-stream - - git clone --branch=master --depth=100 --quiet git://github.com/sebastianbergmann/php-file-iterator.git vendor/php-file-iterator - - git clone --branch=master --depth=100 --quiet git://github.com/sebastianbergmann/php-timer.git vendor/php-timer - - git clone --branch=master --depth=100 --quiet git://github.com/sebastianbergmann/version.git vendor/version - - ln -s ~/builds/sebastianbergmann/php-code-coverage/vendor/version/src ~/builds/sebastianbergmann/php-code-coverage/vendor/SebastianBergmann/Version - - git clone --branch=master --depth=100 --quiet git://github.com/pear/pear-core.git vendor/pear-core - - git clone --branch=trunk --depth=100 --quiet git://github.com/pear/Console_Getopt.git vendor/console-getopt + - mkdir -p vendor/SebastianBergmann + - git clone --branch=master --depth=100 --quiet git://github.com/sebastianbergmann/phpunit.git vendor/phpunit + - git clone --branch=master --depth=100 --quiet git://github.com/sebastianbergmann/phpunit-mock-objects.git vendor/phpunit-mock-objects + - git clone --branch=master --depth=100 --quiet git://github.com/sebastianbergmann/php-text-template.git vendor/php-text-template + - git clone --branch=master --depth=100 --quiet git://github.com/sebastianbergmann/php-token-stream.git vendor/php-token-stream + - git clone --branch=master --depth=100 --quiet git://github.com/sebastianbergmann/php-file-iterator.git vendor/php-file-iterator + - git clone --branch=master --depth=100 --quiet git://github.com/sebastianbergmann/php-timer.git vendor/php-timer + - git clone --branch=master --depth=100 --quiet git://github.com/sebastianbergmann/version.git vendor/version + - ln -s ~/builds/sebastianbergmann/php-code-coverage/vendor/version/src ~/builds/sebastianbergmann/php-code-coverage/vendor/SebastianBergmann/Version + - git clone --branch=master --depth=100 --quiet git://github.com/pear/pear-core.git vendor/pear-core + - git clone --branch=trunk --depth=100 --quiet git://github.com/pear/Console_Getopt.git vendor/console-getopt script: php -d include_path=vendor/php-text-template:vendor/php-token-stream:vendor/php-file-iterator:vendor/phpunit:vendor/phpunit-mock-objects:vendor/php-timer:vendor/php-invoker:vendor/pear-core:vendor/console-getopt:vendor:. ./vendor/phpunit/phpunit.php --configuration ./build/travis-ci.xml notifications: - email: false - irc: "irc.freenode.org#phpunit" + email: false + irc: "irc.freenode.org#phpunit" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b29053982..6f6ef3445 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -Pull Requests for bug fixes should be made against the current release branch (1.2). +Pull Requests for bug fixes should be made against the current release branch (1.2). Pull Requests for new features should be made against master. diff --git a/LICENSE b/LICENSE index 95d18222f..47478963e 100644 --- a/LICENSE +++ b/LICENSE @@ -8,16 +8,16 @@ modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. * Neither the name of Sebastian Bergmann nor the names of his - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT diff --git a/PHP/CodeCoverage.php b/PHP/CodeCoverage.php index cb599612f..fa8146a09 100644 --- a/PHP/CodeCoverage.php +++ b/PHP/CodeCoverage.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,992 +34,992 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.0.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.0.0 */ /** * Provides collection functionality for PHP code coverage information. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.0.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.0.0 */ class PHP_CodeCoverage { - /** - * @var PHP_CodeCoverage_Driver - */ - protected $driver; - - /** - * @var PHP_CodeCoverage_Filter - */ - protected $filter; - - /** - * @var boolean - */ - protected $cacheTokens = FALSE; - - /** - * @var boolean - */ - protected $checkForUnintentionallyCoveredCode = FALSE; - - /** - * @var boolean - */ - protected $forceCoversAnnotation = FALSE; - - /** - * @var boolean - */ - protected $mapTestClassNameToCoveredClassName = FALSE; - - /** - * @var boolean - */ - protected $addUncoveredFilesFromWhitelist = TRUE; - - /** - * @var boolean - */ - protected $processUncoveredFilesFromWhitelist = FALSE; - - /** - * @var mixed - */ - protected $currentId; - - /** - * Code coverage data. - * - * @var array - */ - protected $data = array(); - - /** - * @var array - */ - protected $ignoredLines = array(); - - /** - * Test data. - * - * @var array - */ - protected $tests = array(); - - /** - * Constructor. - * - * @param PHP_CodeCoverage_Driver $driver - * @param PHP_CodeCoverage_Filter $filter - */ - public function __construct(PHP_CodeCoverage_Driver $driver = NULL, PHP_CodeCoverage_Filter $filter = NULL) - { - if ($driver === NULL) { - $driver = new PHP_CodeCoverage_Driver_Xdebug; - } - - if ($filter === NULL) { - $filter = new PHP_CodeCoverage_Filter; - } - - $this->driver = $driver; - $this->filter = $filter; - } - - /** - * Returns the PHP_CodeCoverage_Report_Node_* object graph - * for this PHP_CodeCoverage object. - * - * @return PHP_CodeCoverage_Report_Node_Directory - * @since Method available since Release 1.1.0 - */ - public function getReport() - { - $factory = new PHP_CodeCoverage_Report_Factory; - - return $factory->create($this); - } - - /** - * Clears collected code coverage data. - */ - public function clear() - { - $this->currentId = NULL; - $this->data = array(); - $this->tests = array(); - } - - /** - * Returns the PHP_CodeCoverage_Filter used. - * - * @return PHP_CodeCoverage_Filter - */ - public function filter() - { - return $this->filter; - } - - /** - * Returns the collected code coverage data. - * - * @return array - * @since Method available since Release 1.1.0 - */ - public function getData() - { - if ($this->addUncoveredFilesFromWhitelist) { - $this->addUncoveredFilesFromWhitelist(); - } - - // We need to apply the blacklist filter a second time - // when no whitelist is used. - if (!$this->filter->hasWhitelist()) { - $this->applyListsFilter($this->data); - } - - return $this->data; - } - - /** - * Returns the test data. - * - * @return array - * @since Method available since Release 1.1.0 - */ - public function getTests() - { - return $this->tests; - } - - /** - * Start collection of code coverage information. - * - * @param mixed $id - * @param boolean $clear - * @throws PHP_CodeCoverage_Exception - */ - public function start($id, $clear = FALSE) - { - if (!is_bool($clear)) { - throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory( - 1, 'boolean' - ); - } - - if ($clear) { - $this->clear(); - } - - $this->currentId = $id; - - $this->driver->start(); - } - - /** - * Stop collection of code coverage information. - * - * @param boolean $append - * @return array - * @throws PHP_CodeCoverage_Exception - */ - public function stop($append = TRUE) - { - if (!is_bool($append)) { - throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory( - 1, 'boolean' - ); - } - - $data = $this->driver->stop(); - $this->append($data, NULL, $append); - - $this->currentId = NULL; - - return $data; - } - - /** - * Appends code coverage data. - * - * @param array $data - * @param mixed $id - * @param boolean $append - */ - public function append(array $data, $id = NULL, $append = TRUE) - { - if ($id === NULL) { - $id = $this->currentId; - } - - if ($id === NULL) { - throw new PHP_CodeCoverage_Exception; - } - - $this->applyListsFilter($data); - $this->applyIgnoredLinesFilter($data); - $this->initializeFilesThatAreSeenTheFirstTime($data); - - if (!$append) { - return; - } - - if ($id != 'UNCOVERED_FILES_FROM_WHITELIST') { - $this->applyCoversAnnotationFilter($data, $id); - } - - if (empty($data)) { - return; - } - - $status = NULL; - - if ($id instanceof PHPUnit_Framework_TestCase) { - $status = $id->getStatus(); - $id = get_class($id) . '::' . $id->getName(); - } - - else if ($id instanceof PHPUnit_Extensions_PhptTestCase) { - $id = $id->getName(); - } - - $this->tests[$id] = $status; - - foreach ($data as $file => $lines) { - if (!$this->filter->isFile($file)) { - continue; - } - - foreach ($lines as $k => $v) { - if ($v == 1) { - $this->data[$file][$k][] = $id; - } - } - } - } - - /** - * Merges the data from another instance of PHP_CodeCoverage. - * - * @param PHP_CodeCoverage $that - */ - public function merge(PHP_CodeCoverage $that) - { - foreach ($that->data as $file => $lines) { - if (!isset($this->data[$file])) { - if (!$this->filter->isFiltered($file)) { - $this->data[$file] = $lines; - } - - continue; - } - - foreach ($lines as $line => $data) { - if ($data !== NULL) { - if (!isset($this->data[$file][$line])) { - $this->data[$file][$line] = $data; - } else { - $this->data[$file][$line] = array_unique( - array_merge($this->data[$file][$line], $data) - ); - } - } - } - } - - $this->tests = array_merge($this->tests, $that->getTests()); - } - - /** - * @param boolean $flag - * @throws PHP_CodeCoverage_Exception - * @since Method available since Release 1.1.0 - */ - public function setCacheTokens($flag) - { - if (!is_bool($flag)) { - throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory( - 1, 'boolean' - ); - } - - $this->cacheTokens = $flag; - } - - /** - * @param boolean $flag - * @since Method available since Release 1.1.0 - */ - public function getCacheTokens() - { - return $this->cacheTokens; - } - - /** - * @param boolean $flag - * @throws PHP_CodeCoverage_Exception - * @since Method available since Release 1.3.0 - */ - public function setCheckForUnintentionallyCoveredCode($flag) - { - if (!is_bool($flag)) { - throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory( - 1, 'boolean' - ); - } - - $this->checkForUnintentionallyCoveredCode = $flag; - } - - /** - * @param boolean $flag - * @throws PHP_CodeCoverage_Exception - */ - public function setForceCoversAnnotation($flag) - { - if (!is_bool($flag)) { - throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory( - 1, 'boolean' - ); - } - - $this->forceCoversAnnotation = $flag; - } - - /** - * @param boolean $flag - * @throws PHP_CodeCoverage_Exception - */ - public function setMapTestClassNameToCoveredClassName($flag) - { - if (!is_bool($flag)) { - throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory( - 1, 'boolean' - ); - } - - $this->mapTestClassNameToCoveredClassName = $flag; - } - - /** - * @param boolean $flag - * @throws PHP_CodeCoverage_Exception - */ - public function setAddUncoveredFilesFromWhitelist($flag) - { - if (!is_bool($flag)) { - throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory( - 1, 'boolean' - ); - } - - $this->addUncoveredFilesFromWhitelist = $flag; - } - - /** - * @param boolean $flag - * @throws PHP_CodeCoverage_Exception - */ - public function setProcessUncoveredFilesFromWhitelist($flag) - { - if (!is_bool($flag)) { - throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory( - 1, 'boolean' - ); - } - - $this->processUncoveredFilesFromWhitelist = $flag; - } - - /** - * Applies the @covers annotation filtering. - * - * @param array $data - * @param mixed $id - * @throws PHP_CodeCoverage_Exception_UnintentionallyCoveredCode - */ - protected function applyCoversAnnotationFilter(&$data, $id) - { - $unintentionallyCoveredCode = FALSE; - - if ($id instanceof PHPUnit_Framework_TestCase) { - $testClassName = get_class($id); - $linesToBeCovered = $this->getLinesToBeCovered( - $testClassName, $id->getName() - ); - - if ($linesToBeCovered === FALSE) { - $data = array(); - return; - } - - if ($this->mapTestClassNameToCoveredClassName && - empty($linesToBeCovered)) { - $testedClass = substr($testClassName, 0, -4); - - if (class_exists($testedClass)) { - $class = new ReflectionClass($testedClass); - - $linesToBeCovered = array( - $class->getFileName() => range( - $class->getStartLine(), $class->getEndLine() - ) - ); - } - } - } else { - $linesToBeCovered = array(); - } - - if (!empty($linesToBeCovered)) { - $count = count($data); - $data = array_intersect_key($data, $linesToBeCovered); - - if ($this->checkForUnintentionallyCoveredCode && - $count != count($data)) { - throw new PHP_CodeCoverage_Exception_UnintentionallyCoveredCode; - } - - foreach (array_keys($data) as $filename) { - $_linesToBeCovered = array_flip($linesToBeCovered[$filename]); - - if ($this->checkForUnintentionallyCoveredCode) { - foreach ($data[$filename] as $k => $v) { - if ($v == 1 && !isset($_linesToBeCovered[$k])) { - throw new PHP_CodeCoverage_Exception_UnintentionallyCoveredCode; - } - } - } - - $data[$filename] = array_intersect_key( - $data[$filename], $_linesToBeCovered - ); - } - } - - else if ($this->forceCoversAnnotation) { - $data = array(); - } - } - - /** - * Applies the blacklist/whitelist filtering. - * - * @param array $data - */ - protected function applyListsFilter(&$data) - { - foreach (array_keys($data) as $filename) { - if ($this->filter->isFiltered($filename)) { - unset($data[$filename]); - } - } - } - - /** - * Applies the "ignored lines" filtering. - * - * @param array $data - */ - protected function applyIgnoredLinesFilter(&$data) - { - foreach (array_keys($data) as $filename) { - foreach ($this->getLinesToBeIgnored($filename) as $line) { - unset($data[$filename][$line]); - } - - if (empty($data[$filename])) { - unset($data[$filename]); - } - } - } - - /** - * @since Method available since Release 1.1.0 - */ - protected function initializeFilesThatAreSeenTheFirstTime($data) - { - foreach ($data as $file => $lines) { - if ($this->filter->isFile($file) && !isset($this->data[$file])) { - $this->data[$file] = array(); - - foreach ($lines as $k => $v) { - $this->data[$file][$k] = $v == -2 ? NULL : array(); - } - } - } - } - - /** - * Processes whitelisted files that are not covered. - */ - protected function addUncoveredFilesFromWhitelist() - { - $data = array(); - $uncoveredFiles = array_diff( - $this->filter->getWhitelist(), array_keys($this->data) - ); - - foreach ($uncoveredFiles as $uncoveredFile) { - if (!file_exists($uncoveredFile)) { - continue; - } - - if ($this->processUncoveredFilesFromWhitelist) { - $this->processUncoveredFileFromWhitelist( - $uncoveredFile, $data, $uncoveredFiles - ); - } else { - $data[$uncoveredFile] = array(); - - $lines = count(file($uncoveredFile)); - - for ($i = 1; $i <= $lines; $i++) { - $data[$uncoveredFile][$i] = -1; - } - } - } - - $this->append($data, 'UNCOVERED_FILES_FROM_WHITELIST'); - } - - /** - * @param string $uncoveredFile - * @param array $data - * @param array $uncoveredFiles - */ - protected function processUncoveredFileFromWhitelist($uncoveredFile, array &$data, array $uncoveredFiles) - { - $this->driver->start(); - include_once $uncoveredFile; - $coverage = $this->driver->stop(); - - foreach ($coverage as $file => $fileCoverage) { - if (!isset($data[$file]) && - in_array($file, $uncoveredFiles)) { - foreach (array_keys($fileCoverage) as $key) { - if ($fileCoverage[$key] == 1) { - $fileCoverage[$key] = -1; - } - } - - $data[$file] = $fileCoverage; - } - } - } - - /** - * Returns the files and lines a test method wants to cover. - * - * @param string $className - * @param string $methodName - * @return array - * @since Method available since Release 1.2.0 - */ - protected function getLinesToBeCovered($className, $methodName) - { - $codeToCoverList = array(); - $result = array(); - - // @codeCoverageIgnoreStart - if (($pos = strpos($methodName, ' ')) !== FALSE) { - $methodName = substr($methodName, 0, $pos); - } - // @codeCoverageIgnoreEnd - - $class = new ReflectionClass($className); - - try { - $method = new ReflectionMethod($className, $methodName); - } - - catch (ReflectionException $e) { - return array(); - } - - $docComment = substr($class->getDocComment(), 3, -2) . PHP_EOL . substr($method->getDocComment(), 3, -2); - - $templateMethods = array( - 'setUp', 'assertPreConditions', 'assertPostConditions', 'tearDown' - ); - - foreach ($templateMethods as $templateMethod) { - if ($class->hasMethod($templateMethod)) { - $reflector = $class->getMethod($templateMethod); - $docComment .= PHP_EOL . substr($reflector->getDocComment(), 3, -2); - unset($reflector); - } - } - - if (strpos($docComment, '@coversNothing') !== FALSE) { - return FALSE; - } - - $classShortcut = preg_match_all( - '(@coversDefaultClass\s+(?P.*?)\s*$)m', - $class->getDocComment(), - $matches - ); - - if ($classShortcut) { - if ($classShortcut > 1) { - throw new PHP_CodeCoverage_Exception( - sprintf( - 'More than one @coversClass annotation in class or interface "%s".', - $className - ) - ); - } - - $classShortcut = $matches['coveredClass'][0]; - } - - $match = preg_match_all( - '(@covers\s+(?P.*?)\s*(\(\s*\))?\s*$)m', - $docComment, - $matches - ); - - if ($match) { - foreach ($matches['coveredElement'] as $coveredElement) { - if ($classShortcut && strncmp($coveredElement, '::', 2) === 0) { - $coveredElement = $classShortcut . $coveredElement; - } - - $codeToCoverList = array_merge( - $codeToCoverList, - $this->resolveCoversToReflectionObjects($coveredElement) - ); - } - - foreach ($codeToCoverList as $codeToCover) { - $fileName = $codeToCover->getFileName(); - - if (!isset($result[$fileName])) { - $result[$fileName] = array(); - } - - $result[$fileName] = array_unique( - array_merge( - $result[$fileName], - range( - $codeToCover->getStartLine(), $codeToCover->getEndLine() - ) - ) - ); - } - } - - return $result; - } - - /** - * @param string $coveredElement - * @return array - * @since Method available since Release 1.2.0 - */ - protected function resolveCoversToReflectionObjects($coveredElement) - { - $codeToCoverList = array(); - - if (strpos($coveredElement, '::') !== FALSE) { - list($className, $methodName) = explode('::', $coveredElement); - - if (isset($methodName[0]) && $methodName[0] == '<') { - $classes = array($className); - - foreach ($classes as $className) { - if (!class_exists($className) && - !interface_exists($className)) { - throw new PHP_CodeCoverage_Exception_InvalidCoversTarget( - sprintf( - 'Trying to @cover not existing class or ' . - 'interface "%s".', - $className - ) - ); - } - - $class = new ReflectionClass($className); - $methods = $class->getMethods(); - $inverse = isset($methodName[1]) && $methodName[1] == '!'; - - if (strpos($methodName, 'protected')) { - $visibility = 'isProtected'; - } - - else if (strpos($methodName, 'private')) { - $visibility = 'isPrivate'; - } - - else if (strpos($methodName, 'public')) { - $visibility = 'isPublic'; - } - - foreach ($methods as $method) { - if ($inverse && !$method->$visibility()) { - $codeToCoverList[] = $method; - } - - else if (!$inverse && $method->$visibility()) { - $codeToCoverList[] = $method; - } - } - } - } else { - $classes = array($className); - - foreach ($classes as $className) { - if ($className == '' && function_exists($methodName)) { - $codeToCoverList[] = new ReflectionFunction( - $methodName - ); - } else { - if (!((class_exists($className) || - interface_exists($className) || - trait_exists($className)) && - method_exists($className, $methodName))) { - throw new PHP_CodeCoverage_Exception_InvalidCoversTarget( - sprintf( - 'Trying to @cover not existing method "%s::%s".', - $className, - $methodName - ) - ); - } - - $codeToCoverList[] = new ReflectionMethod( - $className, $methodName - ); - } - } - } - } else { - $extended = FALSE; - - if (strpos($coveredElement, '') !== FALSE) { - $coveredElement = str_replace( - '', '', $coveredElement - ); - - $extended = TRUE; - } - - $classes = array($coveredElement); - - if ($extended) { - $classes = array_merge( - $classes, - class_implements($coveredElement), - class_parents($coveredElement) - ); - } - - foreach ($classes as $className) { - if (!class_exists($className) && - !interface_exists($className) && - !trait_exists($className)) { - throw new PHP_CodeCoverage_Exception_InvalidCoversTarget( - sprintf( - 'Trying to @cover not existing class or ' . - 'interface "%s".', - $className - ) - ); - } - - $codeToCoverList[] = new ReflectionClass($className); - } - } - - return $codeToCoverList; - } - - /** - * Returns the lines of a source file that should be ignored. - * - * @param string $filename - * @return array - * @throws PHP_CodeCoverage_Exception - * @since Method available since Release 1.3.0 - */ - protected function getLinesToBeIgnored($filename) - { - if (!is_string($filename)) { - throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory( - 1, 'string' - ); - } - - if (!isset($this->ignoredLines[$filename])) { - $this->ignoredLines[$filename] = array(); - $ignore = FALSE; - $stop = FALSE; - $lines = file($filename); - $numLines = count($lines); - - foreach ($lines as $index => $line) { - if (!trim($line)) { - $this->ignoredLines[$filename][] = $index + 1; - } - } - - if ($this->cacheTokens) { - $tokens = PHP_Token_Stream_CachingFactory::get($filename); - } else { - $tokens = new PHP_Token_Stream($filename); - } - - $classes = array_merge($tokens->getClasses(), $tokens->getTraits()); - $tokens = $tokens->tokens(); - - foreach ($tokens as $token) { - switch (get_class($token)) { - case 'PHP_Token_COMMENT': - case 'PHP_Token_DOC_COMMENT': { - $count = substr_count($token, "\n"); - $line = $token->getLine(); - - for ($i = $line; $i < $line + $count; $i++) { - $this->ignoredLines[$filename][] = $i; - } - - if ($token instanceof PHP_Token_DOC_COMMENT) { - // Workaround for the fact the DOC_COMMENT token - // does not include the final \n character in its - // text. - if (substr(trim($lines[$i-1]), -2) == '*/') { - $this->ignoredLines[$filename][] = $i; - } - - break; - } - - $_token = trim($token); - - if ($_token == '// @codeCoverageIgnore' || - $_token == '//@codeCoverageIgnore') { - $ignore = TRUE; - $stop = TRUE; - } - - else if ($_token == '// @codeCoverageIgnoreStart' || - $_token == '//@codeCoverageIgnoreStart') { - $ignore = TRUE; - } - - else if ($_token == '// @codeCoverageIgnoreEnd' || - $_token == '//@codeCoverageIgnoreEnd') { - $stop = TRUE; - } - } - break; - - case 'PHP_Token_INTERFACE': - case 'PHP_Token_TRAIT': - case 'PHP_Token_CLASS': - case 'PHP_Token_FUNCTION': { - $docblock = $token->getDocblock(); - - if (strpos($docblock, '@codeCoverageIgnore')) { - $endLine = $token->getEndLine(); - - for ($i = $token->getLine(); $i <= $endLine; $i++) { - $this->ignoredLines[$filename][] = $i; - } - } - - else if ($token instanceof PHP_Token_INTERFACE || - $token instanceof PHP_Token_TRAIT || - $token instanceof PHP_Token_CLASS) { - if (empty($classes[$token->getName()]['methods'])) { - for ($i = $token->getLine(); - $i <= $token->getEndLine(); - $i++) { - $this->ignoredLines[$filename][] = $i; - } - } else { - $firstMethod = array_shift( - $classes[$token->getName()]['methods'] - ); - - $lastMethod = array_pop( - $classes[$token->getName()]['methods'] - ); - - if ($lastMethod === NULL) { - $lastMethod = $firstMethod; - } - - for ($i = $token->getLine(); - $i < $firstMethod['startLine']; - $i++) { - $this->ignoredLines[$filename][] = $i; - } - - for ($i = $token->getEndLine(); - $i > $lastMethod['endLine']; - $i--) { - $this->ignoredLines[$filename][] = $i; - } - } - } - } - break; - - case 'PHP_Token_INTERFACE': { - $endLine = $token->getEndLine(); - - for ($i = $token->getLine(); $i <= $endLine; $i++) { - $this->ignoredLines[$filename][] = $i; - } - } - break; - - case 'PHP_Token_NAMESPACE': { - $this->ignoredLines[$filename][] = $token->getEndLine(); - } // Intentional fallthrough - case 'PHP_Token_OPEN_TAG': - case 'PHP_Token_CLOSE_TAG': - case 'PHP_Token_USE': { - $this->ignoredLines[$filename][] = $token->getLine(); - } - break; - } - - if ($ignore) { - $this->ignoredLines[$filename][] = $token->getLine(); - - if ($stop) { - $ignore = FALSE; - $stop = FALSE; - } - } - } - - $this->ignoredLines[$filename][] = $numLines + 1; - - $this->ignoredLines[$filename] = array_unique( - $this->ignoredLines[$filename] - ); - - sort($this->ignoredLines[$filename]); - } - - return $this->ignoredLines[$filename]; - } + /** + * @var PHP_CodeCoverage_Driver + */ + protected $driver; + + /** + * @var PHP_CodeCoverage_Filter + */ + protected $filter; + + /** + * @var boolean + */ + protected $cacheTokens = FALSE; + + /** + * @var boolean + */ + protected $checkForUnintentionallyCoveredCode = FALSE; + + /** + * @var boolean + */ + protected $forceCoversAnnotation = FALSE; + + /** + * @var boolean + */ + protected $mapTestClassNameToCoveredClassName = FALSE; + + /** + * @var boolean + */ + protected $addUncoveredFilesFromWhitelist = TRUE; + + /** + * @var boolean + */ + protected $processUncoveredFilesFromWhitelist = FALSE; + + /** + * @var mixed + */ + protected $currentId; + + /** + * Code coverage data. + * + * @var array + */ + protected $data = array(); + + /** + * @var array + */ + protected $ignoredLines = array(); + + /** + * Test data. + * + * @var array + */ + protected $tests = array(); + + /** + * Constructor. + * + * @param PHP_CodeCoverage_Driver $driver + * @param PHP_CodeCoverage_Filter $filter + */ + public function __construct(PHP_CodeCoverage_Driver $driver = NULL, PHP_CodeCoverage_Filter $filter = NULL) + { + if ($driver === NULL) { + $driver = new PHP_CodeCoverage_Driver_Xdebug; + } + + if ($filter === NULL) { + $filter = new PHP_CodeCoverage_Filter; + } + + $this->driver = $driver; + $this->filter = $filter; + } + + /** + * Returns the PHP_CodeCoverage_Report_Node_* object graph + * for this PHP_CodeCoverage object. + * + * @return PHP_CodeCoverage_Report_Node_Directory + * @since Method available since Release 1.1.0 + */ + public function getReport() + { + $factory = new PHP_CodeCoverage_Report_Factory; + + return $factory->create($this); + } + + /** + * Clears collected code coverage data. + */ + public function clear() + { + $this->currentId = NULL; + $this->data = array(); + $this->tests = array(); + } + + /** + * Returns the PHP_CodeCoverage_Filter used. + * + * @return PHP_CodeCoverage_Filter + */ + public function filter() + { + return $this->filter; + } + + /** + * Returns the collected code coverage data. + * + * @return array + * @since Method available since Release 1.1.0 + */ + public function getData() + { + if ($this->addUncoveredFilesFromWhitelist) { + $this->addUncoveredFilesFromWhitelist(); + } + + // We need to apply the blacklist filter a second time + // when no whitelist is used. + if (!$this->filter->hasWhitelist()) { + $this->applyListsFilter($this->data); + } + + return $this->data; + } + + /** + * Returns the test data. + * + * @return array + * @since Method available since Release 1.1.0 + */ + public function getTests() + { + return $this->tests; + } + + /** + * Start collection of code coverage information. + * + * @param mixed $id + * @param boolean $clear + * @throws PHP_CodeCoverage_Exception + */ + public function start($id, $clear = FALSE) + { + if (!is_bool($clear)) { + throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory( + 1, 'boolean' + ); + } + + if ($clear) { + $this->clear(); + } + + $this->currentId = $id; + + $this->driver->start(); + } + + /** + * Stop collection of code coverage information. + * + * @param boolean $append + * @return array + * @throws PHP_CodeCoverage_Exception + */ + public function stop($append = TRUE) + { + if (!is_bool($append)) { + throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory( + 1, 'boolean' + ); + } + + $data = $this->driver->stop(); + $this->append($data, NULL, $append); + + $this->currentId = NULL; + + return $data; + } + + /** + * Appends code coverage data. + * + * @param array $data + * @param mixed $id + * @param boolean $append + */ + public function append(array $data, $id = NULL, $append = TRUE) + { + if ($id === NULL) { + $id = $this->currentId; + } + + if ($id === NULL) { + throw new PHP_CodeCoverage_Exception; + } + + $this->applyListsFilter($data); + $this->applyIgnoredLinesFilter($data); + $this->initializeFilesThatAreSeenTheFirstTime($data); + + if (!$append) { + return; + } + + if ($id != 'UNCOVERED_FILES_FROM_WHITELIST') { + $this->applyCoversAnnotationFilter($data, $id); + } + + if (empty($data)) { + return; + } + + $status = NULL; + + if ($id instanceof PHPUnit_Framework_TestCase) { + $status = $id->getStatus(); + $id = get_class($id) . '::' . $id->getName(); + } + + else if ($id instanceof PHPUnit_Extensions_PhptTestCase) { + $id = $id->getName(); + } + + $this->tests[$id] = $status; + + foreach ($data as $file => $lines) { + if (!$this->filter->isFile($file)) { + continue; + } + + foreach ($lines as $k => $v) { + if ($v == 1) { + $this->data[$file][$k][] = $id; + } + } + } + } + + /** + * Merges the data from another instance of PHP_CodeCoverage. + * + * @param PHP_CodeCoverage $that + */ + public function merge(PHP_CodeCoverage $that) + { + foreach ($that->data as $file => $lines) { + if (!isset($this->data[$file])) { + if (!$this->filter->isFiltered($file)) { + $this->data[$file] = $lines; + } + + continue; + } + + foreach ($lines as $line => $data) { + if ($data !== NULL) { + if (!isset($this->data[$file][$line])) { + $this->data[$file][$line] = $data; + } else { + $this->data[$file][$line] = array_unique( + array_merge($this->data[$file][$line], $data) + ); + } + } + } + } + + $this->tests = array_merge($this->tests, $that->getTests()); + } + + /** + * @param boolean $flag + * @throws PHP_CodeCoverage_Exception + * @since Method available since Release 1.1.0 + */ + public function setCacheTokens($flag) + { + if (!is_bool($flag)) { + throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory( + 1, 'boolean' + ); + } + + $this->cacheTokens = $flag; + } + + /** + * @param boolean $flag + * @since Method available since Release 1.1.0 + */ + public function getCacheTokens() + { + return $this->cacheTokens; + } + + /** + * @param boolean $flag + * @throws PHP_CodeCoverage_Exception + * @since Method available since Release 1.3.0 + */ + public function setCheckForUnintentionallyCoveredCode($flag) + { + if (!is_bool($flag)) { + throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory( + 1, 'boolean' + ); + } + + $this->checkForUnintentionallyCoveredCode = $flag; + } + + /** + * @param boolean $flag + * @throws PHP_CodeCoverage_Exception + */ + public function setForceCoversAnnotation($flag) + { + if (!is_bool($flag)) { + throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory( + 1, 'boolean' + ); + } + + $this->forceCoversAnnotation = $flag; + } + + /** + * @param boolean $flag + * @throws PHP_CodeCoverage_Exception + */ + public function setMapTestClassNameToCoveredClassName($flag) + { + if (!is_bool($flag)) { + throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory( + 1, 'boolean' + ); + } + + $this->mapTestClassNameToCoveredClassName = $flag; + } + + /** + * @param boolean $flag + * @throws PHP_CodeCoverage_Exception + */ + public function setAddUncoveredFilesFromWhitelist($flag) + { + if (!is_bool($flag)) { + throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory( + 1, 'boolean' + ); + } + + $this->addUncoveredFilesFromWhitelist = $flag; + } + + /** + * @param boolean $flag + * @throws PHP_CodeCoverage_Exception + */ + public function setProcessUncoveredFilesFromWhitelist($flag) + { + if (!is_bool($flag)) { + throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory( + 1, 'boolean' + ); + } + + $this->processUncoveredFilesFromWhitelist = $flag; + } + + /** + * Applies the @covers annotation filtering. + * + * @param array $data + * @param mixed $id + * @throws PHP_CodeCoverage_Exception_UnintentionallyCoveredCode + */ + protected function applyCoversAnnotationFilter(&$data, $id) + { + $unintentionallyCoveredCode = FALSE; + + if ($id instanceof PHPUnit_Framework_TestCase) { + $testClassName = get_class($id); + $linesToBeCovered = $this->getLinesToBeCovered( + $testClassName, $id->getName() + ); + + if ($linesToBeCovered === FALSE) { + $data = array(); + return; + } + + if ($this->mapTestClassNameToCoveredClassName && + empty($linesToBeCovered)) { + $testedClass = substr($testClassName, 0, -4); + + if (class_exists($testedClass)) { + $class = new ReflectionClass($testedClass); + + $linesToBeCovered = array( + $class->getFileName() => range( + $class->getStartLine(), $class->getEndLine() + ) + ); + } + } + } else { + $linesToBeCovered = array(); + } + + if (!empty($linesToBeCovered)) { + $count = count($data); + $data = array_intersect_key($data, $linesToBeCovered); + + if ($this->checkForUnintentionallyCoveredCode && + $count != count($data)) { + throw new PHP_CodeCoverage_Exception_UnintentionallyCoveredCode; + } + + foreach (array_keys($data) as $filename) { + $_linesToBeCovered = array_flip($linesToBeCovered[$filename]); + + if ($this->checkForUnintentionallyCoveredCode) { + foreach ($data[$filename] as $k => $v) { + if ($v == 1 && !isset($_linesToBeCovered[$k])) { + throw new PHP_CodeCoverage_Exception_UnintentionallyCoveredCode; + } + } + } + + $data[$filename] = array_intersect_key( + $data[$filename], $_linesToBeCovered + ); + } + } + + else if ($this->forceCoversAnnotation) { + $data = array(); + } + } + + /** + * Applies the blacklist/whitelist filtering. + * + * @param array $data + */ + protected function applyListsFilter(&$data) + { + foreach (array_keys($data) as $filename) { + if ($this->filter->isFiltered($filename)) { + unset($data[$filename]); + } + } + } + + /** + * Applies the "ignored lines" filtering. + * + * @param array $data + */ + protected function applyIgnoredLinesFilter(&$data) + { + foreach (array_keys($data) as $filename) { + foreach ($this->getLinesToBeIgnored($filename) as $line) { + unset($data[$filename][$line]); + } + + if (empty($data[$filename])) { + unset($data[$filename]); + } + } + } + + /** + * @since Method available since Release 1.1.0 + */ + protected function initializeFilesThatAreSeenTheFirstTime($data) + { + foreach ($data as $file => $lines) { + if ($this->filter->isFile($file) && !isset($this->data[$file])) { + $this->data[$file] = array(); + + foreach ($lines as $k => $v) { + $this->data[$file][$k] = $v == -2 ? NULL : array(); + } + } + } + } + + /** + * Processes whitelisted files that are not covered. + */ + protected function addUncoveredFilesFromWhitelist() + { + $data = array(); + $uncoveredFiles = array_diff( + $this->filter->getWhitelist(), array_keys($this->data) + ); + + foreach ($uncoveredFiles as $uncoveredFile) { + if (!file_exists($uncoveredFile)) { + continue; + } + + if ($this->processUncoveredFilesFromWhitelist) { + $this->processUncoveredFileFromWhitelist( + $uncoveredFile, $data, $uncoveredFiles + ); + } else { + $data[$uncoveredFile] = array(); + + $lines = count(file($uncoveredFile)); + + for ($i = 1; $i <= $lines; $i++) { + $data[$uncoveredFile][$i] = -1; + } + } + } + + $this->append($data, 'UNCOVERED_FILES_FROM_WHITELIST'); + } + + /** + * @param string $uncoveredFile + * @param array $data + * @param array $uncoveredFiles + */ + protected function processUncoveredFileFromWhitelist($uncoveredFile, array &$data, array $uncoveredFiles) + { + $this->driver->start(); + include_once $uncoveredFile; + $coverage = $this->driver->stop(); + + foreach ($coverage as $file => $fileCoverage) { + if (!isset($data[$file]) && + in_array($file, $uncoveredFiles)) { + foreach (array_keys($fileCoverage) as $key) { + if ($fileCoverage[$key] == 1) { + $fileCoverage[$key] = -1; + } + } + + $data[$file] = $fileCoverage; + } + } + } + + /** + * Returns the files and lines a test method wants to cover. + * + * @param string $className + * @param string $methodName + * @return array + * @since Method available since Release 1.2.0 + */ + protected function getLinesToBeCovered($className, $methodName) + { + $codeToCoverList = array(); + $result = array(); + + // @codeCoverageIgnoreStart + if (($pos = strpos($methodName, ' ')) !== FALSE) { + $methodName = substr($methodName, 0, $pos); + } + // @codeCoverageIgnoreEnd + + $class = new ReflectionClass($className); + + try { + $method = new ReflectionMethod($className, $methodName); + } + + catch (ReflectionException $e) { + return array(); + } + + $docComment = substr($class->getDocComment(), 3, -2) . PHP_EOL . substr($method->getDocComment(), 3, -2); + + $templateMethods = array( + 'setUp', 'assertPreConditions', 'assertPostConditions', 'tearDown' + ); + + foreach ($templateMethods as $templateMethod) { + if ($class->hasMethod($templateMethod)) { + $reflector = $class->getMethod($templateMethod); + $docComment .= PHP_EOL . substr($reflector->getDocComment(), 3, -2); + unset($reflector); + } + } + + if (strpos($docComment, '@coversNothing') !== FALSE) { + return FALSE; + } + + $classShortcut = preg_match_all( + '(@coversDefaultClass\s+(?P.*?)\s*$)m', + $class->getDocComment(), + $matches + ); + + if ($classShortcut) { + if ($classShortcut > 1) { + throw new PHP_CodeCoverage_Exception( + sprintf( + 'More than one @coversClass annotation in class or interface "%s".', + $className + ) + ); + } + + $classShortcut = $matches['coveredClass'][0]; + } + + $match = preg_match_all( + '(@covers\s+(?P.*?)\s*(\(\s*\))?\s*$)m', + $docComment, + $matches + ); + + if ($match) { + foreach ($matches['coveredElement'] as $coveredElement) { + if ($classShortcut && strncmp($coveredElement, '::', 2) === 0) { + $coveredElement = $classShortcut . $coveredElement; + } + + $codeToCoverList = array_merge( + $codeToCoverList, + $this->resolveCoversToReflectionObjects($coveredElement) + ); + } + + foreach ($codeToCoverList as $codeToCover) { + $fileName = $codeToCover->getFileName(); + + if (!isset($result[$fileName])) { + $result[$fileName] = array(); + } + + $result[$fileName] = array_unique( + array_merge( + $result[$fileName], + range( + $codeToCover->getStartLine(), $codeToCover->getEndLine() + ) + ) + ); + } + } + + return $result; + } + + /** + * @param string $coveredElement + * @return array + * @since Method available since Release 1.2.0 + */ + protected function resolveCoversToReflectionObjects($coveredElement) + { + $codeToCoverList = array(); + + if (strpos($coveredElement, '::') !== FALSE) { + list($className, $methodName) = explode('::', $coveredElement); + + if (isset($methodName[0]) && $methodName[0] == '<') { + $classes = array($className); + + foreach ($classes as $className) { + if (!class_exists($className) && + !interface_exists($className)) { + throw new PHP_CodeCoverage_Exception_InvalidCoversTarget( + sprintf( + 'Trying to @cover not existing class or ' . + 'interface "%s".', + $className + ) + ); + } + + $class = new ReflectionClass($className); + $methods = $class->getMethods(); + $inverse = isset($methodName[1]) && $methodName[1] == '!'; + + if (strpos($methodName, 'protected')) { + $visibility = 'isProtected'; + } + + else if (strpos($methodName, 'private')) { + $visibility = 'isPrivate'; + } + + else if (strpos($methodName, 'public')) { + $visibility = 'isPublic'; + } + + foreach ($methods as $method) { + if ($inverse && !$method->$visibility()) { + $codeToCoverList[] = $method; + } + + else if (!$inverse && $method->$visibility()) { + $codeToCoverList[] = $method; + } + } + } + } else { + $classes = array($className); + + foreach ($classes as $className) { + if ($className == '' && function_exists($methodName)) { + $codeToCoverList[] = new ReflectionFunction( + $methodName + ); + } else { + if (!((class_exists($className) || + interface_exists($className) || + trait_exists($className)) && + method_exists($className, $methodName))) { + throw new PHP_CodeCoverage_Exception_InvalidCoversTarget( + sprintf( + 'Trying to @cover not existing method "%s::%s".', + $className, + $methodName + ) + ); + } + + $codeToCoverList[] = new ReflectionMethod( + $className, $methodName + ); + } + } + } + } else { + $extended = FALSE; + + if (strpos($coveredElement, '') !== FALSE) { + $coveredElement = str_replace( + '', '', $coveredElement + ); + + $extended = TRUE; + } + + $classes = array($coveredElement); + + if ($extended) { + $classes = array_merge( + $classes, + class_implements($coveredElement), + class_parents($coveredElement) + ); + } + + foreach ($classes as $className) { + if (!class_exists($className) && + !interface_exists($className) && + !trait_exists($className)) { + throw new PHP_CodeCoverage_Exception_InvalidCoversTarget( + sprintf( + 'Trying to @cover not existing class or ' . + 'interface "%s".', + $className + ) + ); + } + + $codeToCoverList[] = new ReflectionClass($className); + } + } + + return $codeToCoverList; + } + + /** + * Returns the lines of a source file that should be ignored. + * + * @param string $filename + * @return array + * @throws PHP_CodeCoverage_Exception + * @since Method available since Release 1.3.0 + */ + protected function getLinesToBeIgnored($filename) + { + if (!is_string($filename)) { + throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory( + 1, 'string' + ); + } + + if (!isset($this->ignoredLines[$filename])) { + $this->ignoredLines[$filename] = array(); + $ignore = FALSE; + $stop = FALSE; + $lines = file($filename); + $numLines = count($lines); + + foreach ($lines as $index => $line) { + if (!trim($line)) { + $this->ignoredLines[$filename][] = $index + 1; + } + } + + if ($this->cacheTokens) { + $tokens = PHP_Token_Stream_CachingFactory::get($filename); + } else { + $tokens = new PHP_Token_Stream($filename); + } + + $classes = array_merge($tokens->getClasses(), $tokens->getTraits()); + $tokens = $tokens->tokens(); + + foreach ($tokens as $token) { + switch (get_class($token)) { + case 'PHP_Token_COMMENT': + case 'PHP_Token_DOC_COMMENT': { + $count = substr_count($token, "\n"); + $line = $token->getLine(); + + for ($i = $line; $i < $line + $count; $i++) { + $this->ignoredLines[$filename][] = $i; + } + + if ($token instanceof PHP_Token_DOC_COMMENT) { + // Workaround for the fact the DOC_COMMENT token + // does not include the final \n character in its + // text. + if (substr(trim($lines[$i-1]), -2) == '*/') { + $this->ignoredLines[$filename][] = $i; + } + + break; + } + + $_token = trim($token); + + if ($_token == '// @codeCoverageIgnore' || + $_token == '//@codeCoverageIgnore') { + $ignore = TRUE; + $stop = TRUE; + } + + else if ($_token == '// @codeCoverageIgnoreStart' || + $_token == '//@codeCoverageIgnoreStart') { + $ignore = TRUE; + } + + else if ($_token == '// @codeCoverageIgnoreEnd' || + $_token == '//@codeCoverageIgnoreEnd') { + $stop = TRUE; + } + } + break; + + case 'PHP_Token_INTERFACE': + case 'PHP_Token_TRAIT': + case 'PHP_Token_CLASS': + case 'PHP_Token_FUNCTION': { + $docblock = $token->getDocblock(); + + if (strpos($docblock, '@codeCoverageIgnore')) { + $endLine = $token->getEndLine(); + + for ($i = $token->getLine(); $i <= $endLine; $i++) { + $this->ignoredLines[$filename][] = $i; + } + } + + else if ($token instanceof PHP_Token_INTERFACE || + $token instanceof PHP_Token_TRAIT || + $token instanceof PHP_Token_CLASS) { + if (empty($classes[$token->getName()]['methods'])) { + for ($i = $token->getLine(); + $i <= $token->getEndLine(); + $i++) { + $this->ignoredLines[$filename][] = $i; + } + } else { + $firstMethod = array_shift( + $classes[$token->getName()]['methods'] + ); + + $lastMethod = array_pop( + $classes[$token->getName()]['methods'] + ); + + if ($lastMethod === NULL) { + $lastMethod = $firstMethod; + } + + for ($i = $token->getLine(); + $i < $firstMethod['startLine']; + $i++) { + $this->ignoredLines[$filename][] = $i; + } + + for ($i = $token->getEndLine(); + $i > $lastMethod['endLine']; + $i--) { + $this->ignoredLines[$filename][] = $i; + } + } + } + } + break; + + case 'PHP_Token_INTERFACE': { + $endLine = $token->getEndLine(); + + for ($i = $token->getLine(); $i <= $endLine; $i++) { + $this->ignoredLines[$filename][] = $i; + } + } + break; + + case 'PHP_Token_NAMESPACE': { + $this->ignoredLines[$filename][] = $token->getEndLine(); + } // Intentional fallthrough + case 'PHP_Token_OPEN_TAG': + case 'PHP_Token_CLOSE_TAG': + case 'PHP_Token_USE': { + $this->ignoredLines[$filename][] = $token->getLine(); + } + break; + } + + if ($ignore) { + $this->ignoredLines[$filename][] = $token->getLine(); + + if ($stop) { + $ignore = FALSE; + $stop = FALSE; + } + } + } + + $this->ignoredLines[$filename][] = $numLines + 1; + + $this->ignoredLines[$filename] = array_unique( + $this->ignoredLines[$filename] + ); + + sort($this->ignoredLines[$filename]); + } + + return $this->ignoredLines[$filename]; + } } diff --git a/PHP/CodeCoverage/Autoload.php b/PHP/CodeCoverage/Autoload.php index 6312e8023..8a3672eb1 100644 --- a/PHP/CodeCoverage/Autoload.php +++ b/PHP/CodeCoverage/Autoload.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,13 +34,13 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2010 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.1.0 */ require_once 'File/Iterator/Autoload.php'; @@ -49,44 +49,44 @@ require_once 'SebastianBergmann/Version/autoload.php'; spl_autoload_register( - function ($class) - { - static $classes = NULL; - static $path = NULL; + function ($class) + { + static $classes = NULL; + static $path = NULL; - if ($classes === NULL) { - $classes = array( - 'php_codecoverage' => '/CodeCoverage.php', - 'php_codecoverage_driver' => '/CodeCoverage/Driver.php', - 'php_codecoverage_driver_xdebug' => '/CodeCoverage/Driver/Xdebug.php', - 'php_codecoverage_exception' => '/CodeCoverage/Exception.php', - 'php_codecoverage_exception_invalidcoverstarget' => '/CodeCoverage/Exception/InvalidCoversTarget.php', - 'php_codecoverage_exception_unintentionallycoveredcode' => '/CodeCoverage/Exception/UnintentionallyCoveredCode.php', - 'php_codecoverage_filter' => '/CodeCoverage/Filter.php', - 'php_codecoverage_report_clover' => '/CodeCoverage/Report/Clover.php', - 'php_codecoverage_report_factory' => '/CodeCoverage/Report/Factory.php', - 'php_codecoverage_report_html' => '/CodeCoverage/Report/HTML.php', - 'php_codecoverage_report_html_renderer' => '/CodeCoverage/Report/HTML/Renderer.php', - 'php_codecoverage_report_html_renderer_dashboard' => '/CodeCoverage/Report/HTML/Renderer/Dashboard.php', - 'php_codecoverage_report_html_renderer_directory' => '/CodeCoverage/Report/HTML/Renderer/Directory.php', - 'php_codecoverage_report_html_renderer_file' => '/CodeCoverage/Report/HTML/Renderer/File.php', - 'php_codecoverage_report_node' => '/CodeCoverage/Report/Node.php', - 'php_codecoverage_report_node_directory' => '/CodeCoverage/Report/Node/Directory.php', - 'php_codecoverage_report_node_file' => '/CodeCoverage/Report/Node/File.php', - 'php_codecoverage_report_node_iterator' => '/CodeCoverage/Report/Node/Iterator.php', - 'php_codecoverage_report_php' => '/CodeCoverage/Report/PHP.php', - 'php_codecoverage_report_text' => '/CodeCoverage/Report/Text.php', - 'php_codecoverage_util' => '/CodeCoverage/Util.php', - 'php_codecoverage_util_invalidargumenthelper' => '/CodeCoverage/Util/InvalidArgumentHelper.php' - ); + if ($classes === NULL) { + $classes = array( + 'php_codecoverage' => '/CodeCoverage.php', + 'php_codecoverage_driver' => '/CodeCoverage/Driver.php', + 'php_codecoverage_driver_xdebug' => '/CodeCoverage/Driver/Xdebug.php', + 'php_codecoverage_exception' => '/CodeCoverage/Exception.php', + 'php_codecoverage_exception_invalidcoverstarget' => '/CodeCoverage/Exception/InvalidCoversTarget.php', + 'php_codecoverage_exception_unintentionallycoveredcode' => '/CodeCoverage/Exception/UnintentionallyCoveredCode.php', + 'php_codecoverage_filter' => '/CodeCoverage/Filter.php', + 'php_codecoverage_report_clover' => '/CodeCoverage/Report/Clover.php', + 'php_codecoverage_report_factory' => '/CodeCoverage/Report/Factory.php', + 'php_codecoverage_report_html' => '/CodeCoverage/Report/HTML.php', + 'php_codecoverage_report_html_renderer' => '/CodeCoverage/Report/HTML/Renderer.php', + 'php_codecoverage_report_html_renderer_dashboard' => '/CodeCoverage/Report/HTML/Renderer/Dashboard.php', + 'php_codecoverage_report_html_renderer_directory' => '/CodeCoverage/Report/HTML/Renderer/Directory.php', + 'php_codecoverage_report_html_renderer_file' => '/CodeCoverage/Report/HTML/Renderer/File.php', + 'php_codecoverage_report_node' => '/CodeCoverage/Report/Node.php', + 'php_codecoverage_report_node_directory' => '/CodeCoverage/Report/Node/Directory.php', + 'php_codecoverage_report_node_file' => '/CodeCoverage/Report/Node/File.php', + 'php_codecoverage_report_node_iterator' => '/CodeCoverage/Report/Node/Iterator.php', + 'php_codecoverage_report_php' => '/CodeCoverage/Report/PHP.php', + 'php_codecoverage_report_text' => '/CodeCoverage/Report/Text.php', + 'php_codecoverage_util' => '/CodeCoverage/Util.php', + 'php_codecoverage_util_invalidargumenthelper' => '/CodeCoverage/Util/InvalidArgumentHelper.php' + ); - $path = dirname(dirname(__FILE__)); - } + $path = dirname(dirname(__FILE__)); + } - $cn = strtolower($class); + $cn = strtolower($class); - if (isset($classes[$cn])) { - require $path . $classes[$cn]; - } - } + if (isset($classes[$cn])) { + require $path . $classes[$cn]; + } + } ); diff --git a/PHP/CodeCoverage/Autoload.php.in b/PHP/CodeCoverage/Autoload.php.in index a363a4c27..d95667c39 100644 --- a/PHP/CodeCoverage/Autoload.php.in +++ b/PHP/CodeCoverage/Autoload.php.in @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,13 +34,13 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2010 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2010 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.1.0 */ require_once 'File/Iterator/Autoload.php'; @@ -49,23 +49,23 @@ require_once 'Text/Template/Autoload.php'; require_once 'SebastianBergmann/Version/autoload.php'; spl_autoload_register( - function ($class) - { - static $classes = NULL; - static $path = NULL; + function ($class) + { + static $classes = NULL; + static $path = NULL; - if ($classes === NULL) { - $classes = array( - ___CLASSLIST___ - ); + if ($classes === NULL) { + $classes = array( + ___CLASSLIST___ + ); - $path = dirname(dirname(__FILE__)); - } + $path = dirname(dirname(__FILE__)); + } - $cn = strtolower($class); + $cn = strtolower($class); - if (isset($classes[$cn])) { - require $path . $classes[$cn]; - } - } + if (isset($classes[$cn])) { + require $path . $classes[$cn]; + } + } ); diff --git a/PHP/CodeCoverage/Driver.php b/PHP/CodeCoverage/Driver.php index 5cd79127f..125a3a06e 100644 --- a/PHP/CodeCoverage/Driver.php +++ b/PHP/CodeCoverage/Driver.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,37 +34,37 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.0.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.0.0 */ /** * Interface for code coverage drivers. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.0.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.0.0 */ interface PHP_CodeCoverage_Driver { - /** - * Start collection of code coverage information. - */ - public function start(); + /** + * Start collection of code coverage information. + */ + public function start(); - /** - * Stop collection of code coverage information. - * - * @return array - */ - public function stop(); + /** + * Stop collection of code coverage information. + * + * @return array + */ + public function stop(); } diff --git a/PHP/CodeCoverage/Driver/Xdebug.php b/PHP/CodeCoverage/Driver/Xdebug.php index 59bbf00ca..4fe4e8b71 100644 --- a/PHP/CodeCoverage/Driver/Xdebug.php +++ b/PHP/CodeCoverage/Driver/Xdebug.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,63 +34,63 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.0.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.0.0 */ /** * Driver for Xdebug's code coverage functionality. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.0.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.0.0 * @codeCoverageIgnore */ class PHP_CodeCoverage_Driver_Xdebug implements PHP_CodeCoverage_Driver { - /** - * Constructor. - */ - public function __construct() - { - if (!extension_loaded('xdebug')) { - throw new PHP_CodeCoverage_Exception('Xdebug is not loaded.'); - } + /** + * Constructor. + */ + public function __construct() + { + if (!extension_loaded('xdebug')) { + throw new PHP_CodeCoverage_Exception('Xdebug is not loaded.'); + } - if (!ini_get('xdebug.coverage_enable')) { - throw new PHP_CodeCoverage_Exception( - 'You need to set xdebug.coverage_enable=On in your php.ini.' - ); - } - } + if (!ini_get('xdebug.coverage_enable')) { + throw new PHP_CodeCoverage_Exception( + 'You need to set xdebug.coverage_enable=On in your php.ini.' + ); + } + } - /** - * Start collection of code coverage information. - */ - public function start() - { - xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); - } + /** + * Start collection of code coverage information. + */ + public function start() + { + xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); + } - /** - * Stop collection of code coverage information. - * - * @return array - */ - public function stop() - { - $codeCoverage = xdebug_get_code_coverage(); - xdebug_stop_code_coverage(); + /** + * Stop collection of code coverage information. + * + * @return array + */ + public function stop() + { + $codeCoverage = xdebug_get_code_coverage(); + xdebug_stop_code_coverage(); - return $codeCoverage; - } + return $codeCoverage; + } } diff --git a/PHP/CodeCoverage/Exception.php b/PHP/CodeCoverage/Exception.php index 412a4e12d..25f6f72fa 100644 --- a/PHP/CodeCoverage/Exception.php +++ b/PHP/CodeCoverage/Exception.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,25 +34,25 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.1.0 */ /** * Exception class for PHP_CodeCoverage component. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.1.0 */ class PHP_CodeCoverage_Exception extends RuntimeException { diff --git a/PHP/CodeCoverage/Exception/InvalidCoversTarget.php b/PHP/CodeCoverage/Exception/InvalidCoversTarget.php index 185a953d4..c0918d1f9 100644 --- a/PHP/CodeCoverage/Exception/InvalidCoversTarget.php +++ b/PHP/CodeCoverage/Exception/InvalidCoversTarget.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,25 +34,25 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.3.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.3.0 */ /** * Exception that is raised when code is unintentionally covered. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.3.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.3.0 */ class PHP_CodeCoverage_Exception_InvalidCoversTarget extends PHP_CodeCoverage_Exception { diff --git a/PHP/CodeCoverage/Exception/UnintentionallyCoveredCode.php b/PHP/CodeCoverage/Exception/UnintentionallyCoveredCode.php index 7f9260f10..80fbb83fb 100644 --- a/PHP/CodeCoverage/Exception/UnintentionallyCoveredCode.php +++ b/PHP/CodeCoverage/Exception/UnintentionallyCoveredCode.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,25 +34,25 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.3.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.3.0 */ /** * Exception that is raised when code is unintentionally covered. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.3.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.3.0 */ class PHP_CodeCoverage_Exception_UnintentionallyCoveredCode extends PHP_CodeCoverage_Exception { diff --git a/PHP/CodeCoverage/Filter.php b/PHP/CodeCoverage/Filter.php index 966a0b9ea..59d9f4801 100644 --- a/PHP/CodeCoverage/Filter.php +++ b/PHP/CodeCoverage/Filter.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,310 +34,310 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.0.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.0.0 */ /** * Filter for blacklisting and whitelisting of code coverage information. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.0.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.0.0 */ class PHP_CodeCoverage_Filter { - /** - * Source files that are blacklisted. - * - * @var array - */ - protected $blacklistedFiles = array(); - - /** - * Source files that are whitelisted. - * - * @var array - */ - protected $whitelistedFiles = array(); - - /** - * @var boolean - */ - protected $blacklistPrefilled = FALSE; - - /** - * Adds a directory to the blacklist (recursively). - * - * @param string $directory - * @param string $suffix - * @param string $prefix - */ - public function addDirectoryToBlacklist($directory, $suffix = '.php', $prefix = '') - { - $facade = new File_Iterator_Facade; - $files = $facade->getFilesAsArray( - $directory, $suffix, $prefix - ); - - foreach ($files as $file) { - $this->addFileToBlacklist($file); - } - } - - /** - * Adds a file to the blacklist. - * - * @param string $filename - */ - public function addFileToBlacklist($filename) - { - $this->blacklistedFiles[realpath($filename)] = TRUE; - } - - /** - * Adds files to the blacklist. - * - * @param array $files - */ - public function addFilesToBlacklist(array $files) - { - foreach ($files as $file) { - $this->addFileToBlacklist($file); - } - } - - /** - * Removes a directory from the blacklist (recursively). - * - * @param string $directory - * @param string $suffix - * @param string $prefix - */ - public function removeDirectoryFromBlacklist($directory, $suffix = '.php', $prefix = '') - { - $facade = new File_Iterator_Facade; - $files = $facade->getFilesAsArray( - $directory, $suffix, $prefix - ); - - foreach ($files as $file) { - $this->removeFileFromBlacklist($file); - } - } - - /** - * Removes a file from the blacklist. - * - * @param string $filename - */ - public function removeFileFromBlacklist($filename) - { - $filename = realpath($filename); - - if (isset($this->blacklistedFiles[$filename])) { - unset($this->blacklistedFiles[$filename]); - } - } - - /** - * Adds a directory to the whitelist (recursively). - * - * @param string $directory - * @param string $suffix - * @param string $prefix - */ - public function addDirectoryToWhitelist($directory, $suffix = '.php', $prefix = '') - { - $facade = new File_Iterator_Facade; - $files = $facade->getFilesAsArray( - $directory, $suffix, $prefix - ); - - foreach ($files as $file) { - $this->addFileToWhitelist($file); - } - } - - /** - * Adds a file to the whitelist. - * - * @param string $filename - */ - public function addFileToWhitelist($filename) - { - $this->whitelistedFiles[realpath($filename)] = TRUE; - } - - /** - * Adds files to the whitelist. - * - * @param array $files - */ - public function addFilesToWhitelist(array $files) - { - foreach ($files as $file) { - $this->addFileToWhitelist($file); - } - } - - /** - * Removes a directory from the whitelist (recursively). - * - * @param string $directory - * @param string $suffix - * @param string $prefix - */ - public function removeDirectoryFromWhitelist($directory, $suffix = '.php', $prefix = '') - { - $facade = new File_Iterator_Facade; - $files = $facade->getFilesAsArray( - $directory, $suffix, $prefix - ); - - foreach ($files as $file) { - $this->removeFileFromWhitelist($file); - } - } - - /** - * Removes a file from the whitelist. - * - * @param string $filename - */ - public function removeFileFromWhitelist($filename) - { - $filename = realpath($filename); - - if (isset($this->whitelistedFiles[$filename])) { - unset($this->whitelistedFiles[$filename]); - } - } - - /** - * Checks whether a filename is a real filename. - * - * @param string $filename - */ - public function isFile($filename) - { - if ($filename == '-' || - strpos($filename, 'eval()\'d code') !== FALSE || - strpos($filename, 'runtime-created function') !== FALSE || - strpos($filename, 'runkit created function') !== FALSE || - strpos($filename, 'assert code') !== FALSE || - strpos($filename, 'regexp code') !== FALSE) { - return FALSE; - } - - return TRUE; - } - - /** - * Checks whether or not a file is filtered. - * - * When the whitelist is empty (default), blacklisting is used. - * When the whitelist is not empty, whitelisting is used. - * - * @param string $filename - * @param boolean $ignoreWhitelist - * @return boolean - * @throws PHP_CodeCoverage_Exception - */ - public function isFiltered($filename) - { - $filename = realpath($filename); - - if (!empty($this->whitelistedFiles)) { - return !isset($this->whitelistedFiles[$filename]); - } - - if (!$this->blacklistPrefilled) { - $this->prefillBlacklist(); - } - - return isset($this->blacklistedFiles[$filename]); - } - - /** - * Returns the list of blacklisted files. - * - * @return array - */ - public function getBlacklist() - { - return array_keys($this->blacklistedFiles); - } - - /** - * Returns the list of whitelisted files. - * - * @return array - */ - public function getWhitelist() - { - return array_keys($this->whitelistedFiles); - } - - /** - * Returns whether this filter has a whitelist. - * - * @return boolean - * @since Method available since Release 1.1.0 - */ - public function hasWhitelist() - { - return !empty($this->whitelistedFiles); - } - - /** - * @since Method available since Release 1.2.3 - */ - protected function prefillBlacklist() - { - $this->addDirectoryContainingClassToBlacklist('File_Iterator'); - $this->addDirectoryContainingClassToBlacklist('PHP_CodeCoverage'); - $this->addDirectoryContainingClassToBlacklist('PHP_Invoker'); - $this->addDirectoryContainingClassToBlacklist('PHP_Timer'); - $this->addDirectoryContainingClassToBlacklist('PHP_Token'); - $this->addDirectoryContainingClassToBlacklist('PHPUnit_Framework_TestCase', 2); - $this->addDirectoryContainingClassToBlacklist('PHPUnit_Extensions_Database_TestCase', 2); - $this->addDirectoryContainingClassToBlacklist('PHPUnit_Framework_MockObject_Generator', 2); - $this->addDirectoryContainingClassToBlacklist('PHPUnit_Extensions_SeleniumTestCase', 2); - $this->addDirectoryContainingClassToBlacklist('PHPUnit_Extensions_Story_TestCase', 2); - $this->addDirectoryContainingClassToBlacklist('Text_Template'); - $this->addDirectoryContainingClassToBlacklist('Symfony\Component\Yaml\Yaml'); - - $this->blacklistPrefilled = TRUE; - } - - /** - * @param string $className - * @param integer $parent - * @since Method available since Release 1.2.3 - */ - protected function addDirectoryContainingClassToBlacklist($className, $parent = 1) - { - if (!class_exists($className)) { - return; - } - - $reflector = new ReflectionClass($className); - $directory = $reflector->getFileName(); - - for ($i = 0; $i < $parent; $i++) { - $directory = dirname($directory); - } - - $this->addDirectoryToBlacklist($directory); - } + /** + * Source files that are blacklisted. + * + * @var array + */ + protected $blacklistedFiles = array(); + + /** + * Source files that are whitelisted. + * + * @var array + */ + protected $whitelistedFiles = array(); + + /** + * @var boolean + */ + protected $blacklistPrefilled = FALSE; + + /** + * Adds a directory to the blacklist (recursively). + * + * @param string $directory + * @param string $suffix + * @param string $prefix + */ + public function addDirectoryToBlacklist($directory, $suffix = '.php', $prefix = '') + { + $facade = new File_Iterator_Facade; + $files = $facade->getFilesAsArray( + $directory, $suffix, $prefix + ); + + foreach ($files as $file) { + $this->addFileToBlacklist($file); + } + } + + /** + * Adds a file to the blacklist. + * + * @param string $filename + */ + public function addFileToBlacklist($filename) + { + $this->blacklistedFiles[realpath($filename)] = TRUE; + } + + /** + * Adds files to the blacklist. + * + * @param array $files + */ + public function addFilesToBlacklist(array $files) + { + foreach ($files as $file) { + $this->addFileToBlacklist($file); + } + } + + /** + * Removes a directory from the blacklist (recursively). + * + * @param string $directory + * @param string $suffix + * @param string $prefix + */ + public function removeDirectoryFromBlacklist($directory, $suffix = '.php', $prefix = '') + { + $facade = new File_Iterator_Facade; + $files = $facade->getFilesAsArray( + $directory, $suffix, $prefix + ); + + foreach ($files as $file) { + $this->removeFileFromBlacklist($file); + } + } + + /** + * Removes a file from the blacklist. + * + * @param string $filename + */ + public function removeFileFromBlacklist($filename) + { + $filename = realpath($filename); + + if (isset($this->blacklistedFiles[$filename])) { + unset($this->blacklistedFiles[$filename]); + } + } + + /** + * Adds a directory to the whitelist (recursively). + * + * @param string $directory + * @param string $suffix + * @param string $prefix + */ + public function addDirectoryToWhitelist($directory, $suffix = '.php', $prefix = '') + { + $facade = new File_Iterator_Facade; + $files = $facade->getFilesAsArray( + $directory, $suffix, $prefix + ); + + foreach ($files as $file) { + $this->addFileToWhitelist($file); + } + } + + /** + * Adds a file to the whitelist. + * + * @param string $filename + */ + public function addFileToWhitelist($filename) + { + $this->whitelistedFiles[realpath($filename)] = TRUE; + } + + /** + * Adds files to the whitelist. + * + * @param array $files + */ + public function addFilesToWhitelist(array $files) + { + foreach ($files as $file) { + $this->addFileToWhitelist($file); + } + } + + /** + * Removes a directory from the whitelist (recursively). + * + * @param string $directory + * @param string $suffix + * @param string $prefix + */ + public function removeDirectoryFromWhitelist($directory, $suffix = '.php', $prefix = '') + { + $facade = new File_Iterator_Facade; + $files = $facade->getFilesAsArray( + $directory, $suffix, $prefix + ); + + foreach ($files as $file) { + $this->removeFileFromWhitelist($file); + } + } + + /** + * Removes a file from the whitelist. + * + * @param string $filename + */ + public function removeFileFromWhitelist($filename) + { + $filename = realpath($filename); + + if (isset($this->whitelistedFiles[$filename])) { + unset($this->whitelistedFiles[$filename]); + } + } + + /** + * Checks whether a filename is a real filename. + * + * @param string $filename + */ + public function isFile($filename) + { + if ($filename == '-' || + strpos($filename, 'eval()\'d code') !== FALSE || + strpos($filename, 'runtime-created function') !== FALSE || + strpos($filename, 'runkit created function') !== FALSE || + strpos($filename, 'assert code') !== FALSE || + strpos($filename, 'regexp code') !== FALSE) { + return FALSE; + } + + return TRUE; + } + + /** + * Checks whether or not a file is filtered. + * + * When the whitelist is empty (default), blacklisting is used. + * When the whitelist is not empty, whitelisting is used. + * + * @param string $filename + * @param boolean $ignoreWhitelist + * @return boolean + * @throws PHP_CodeCoverage_Exception + */ + public function isFiltered($filename) + { + $filename = realpath($filename); + + if (!empty($this->whitelistedFiles)) { + return !isset($this->whitelistedFiles[$filename]); + } + + if (!$this->blacklistPrefilled) { + $this->prefillBlacklist(); + } + + return isset($this->blacklistedFiles[$filename]); + } + + /** + * Returns the list of blacklisted files. + * + * @return array + */ + public function getBlacklist() + { + return array_keys($this->blacklistedFiles); + } + + /** + * Returns the list of whitelisted files. + * + * @return array + */ + public function getWhitelist() + { + return array_keys($this->whitelistedFiles); + } + + /** + * Returns whether this filter has a whitelist. + * + * @return boolean + * @since Method available since Release 1.1.0 + */ + public function hasWhitelist() + { + return !empty($this->whitelistedFiles); + } + + /** + * @since Method available since Release 1.2.3 + */ + protected function prefillBlacklist() + { + $this->addDirectoryContainingClassToBlacklist('File_Iterator'); + $this->addDirectoryContainingClassToBlacklist('PHP_CodeCoverage'); + $this->addDirectoryContainingClassToBlacklist('PHP_Invoker'); + $this->addDirectoryContainingClassToBlacklist('PHP_Timer'); + $this->addDirectoryContainingClassToBlacklist('PHP_Token'); + $this->addDirectoryContainingClassToBlacklist('PHPUnit_Framework_TestCase', 2); + $this->addDirectoryContainingClassToBlacklist('PHPUnit_Extensions_Database_TestCase', 2); + $this->addDirectoryContainingClassToBlacklist('PHPUnit_Framework_MockObject_Generator', 2); + $this->addDirectoryContainingClassToBlacklist('PHPUnit_Extensions_SeleniumTestCase', 2); + $this->addDirectoryContainingClassToBlacklist('PHPUnit_Extensions_Story_TestCase', 2); + $this->addDirectoryContainingClassToBlacklist('Text_Template'); + $this->addDirectoryContainingClassToBlacklist('Symfony\Component\Yaml\Yaml'); + + $this->blacklistPrefilled = TRUE; + } + + /** + * @param string $className + * @param integer $parent + * @since Method available since Release 1.2.3 + */ + protected function addDirectoryContainingClassToBlacklist($className, $parent = 1) + { + if (!class_exists($className)) { + return; + } + + $reflector = new ReflectionClass($className); + $directory = $reflector->getFileName(); + + for ($i = 0; $i < $parent; $i++) { + $directory = dirname($directory); + } + + $this->addDirectoryToBlacklist($directory); + } } diff --git a/PHP/CodeCoverage/Report/Clover.php b/PHP/CodeCoverage/Report/Clover.php index 05f9eee43..87a45f9ba 100644 --- a/PHP/CodeCoverage/Report/Clover.php +++ b/PHP/CodeCoverage/Report/Clover.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,302 +34,302 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.0.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.0.0 */ /** * Generates a Clover XML logfile from an PHP_CodeCoverage object. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.0.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.0.0 */ class PHP_CodeCoverage_Report_Clover { - /** - * @param PHP_CodeCoverage $coverage - * @param string $target - * @param string $name - * @return string - */ - public function process(PHP_CodeCoverage $coverage, $target = NULL, $name = NULL) - { - $xmlDocument = new DOMDocument('1.0', 'UTF-8'); - $xmlDocument->formatOutput = TRUE; - - $xmlCoverage = $xmlDocument->createElement('coverage'); - $xmlCoverage->setAttribute('generated', (int)$_SERVER['REQUEST_TIME']); - $xmlDocument->appendChild($xmlCoverage); - - $xmlProject = $xmlDocument->createElement('project'); - $xmlProject->setAttribute('timestamp', (int)$_SERVER['REQUEST_TIME']); - - if (is_string($name)) { - $xmlProject->setAttribute('name', $name); - } - - $xmlCoverage->appendChild($xmlProject); - - $packages = array(); - $report = $coverage->getReport(); - unset($coverage); - - foreach ($report as $item) { - $namespace = 'global'; - - if (!$item instanceof PHP_CodeCoverage_Report_Node_File) { - continue; - } - - $xmlFile = $xmlDocument->createElement('file'); - $xmlFile->setAttribute('name', $item->getPath()); - - $classes = $item->getClassesAndTraits(); - $coverage = $item->getCoverageData(); - $lines = array(); - - foreach ($classes as $className => $class) { - $classStatements = 0; - $coveredClassStatements = 0; - $coveredMethods = 0; - - foreach ($class['methods'] as $methodName => $method) { - $methodCount = 0; - $methodLines = 0; - $methodLinesCovered = 0; - - for ($i = $method['startLine']; - $i <= $method['endLine']; - $i++) { - $add = TRUE; - $count = 0; - - if (isset($coverage[$i])) { - if ($coverage[$i] !== NULL) { - $classStatements++; - $methodLines++; - } else { - $add = FALSE; - } - - $count = count($coverage[$i]); - - if ($count > 0) { - $coveredClassStatements++; - $methodLinesCovered++; - } - } else { - $add = FALSE; - } - - $methodCount = max($methodCount, $count); - - if ($add) { - $lines[$i] = array( - 'count' => $count, 'type' => 'stmt' - ); - } - } - - if ($methodCount > 0) { - $coveredMethods++; - } - - $lines[$method['startLine']] = array( - 'count' => $methodCount, - 'crap' => $method['crap'], - 'type' => 'method', - 'name' => $methodName - ); - } - - if (!empty($class['package']['namespace'])) { - $namespace = $class['package']['namespace']; - } - - $xmlClass = $xmlDocument->createElement('class'); - $xmlClass->setAttribute('name', $className); - $xmlClass->setAttribute('namespace', $namespace); - - if (!empty($class['package']['fullPackage'])) { - $xmlClass->setAttribute( - 'fullPackage', $class['package']['fullPackage'] - ); - } - - if (!empty($class['package']['category'])) { - $xmlClass->setAttribute( - 'category', $class['package']['category'] - ); - } - - if (!empty($class['package']['package'])) { - $xmlClass->setAttribute( - 'package', $class['package']['package'] - ); - } - - if (!empty($class['package']['subpackage'])) { - $xmlClass->setAttribute( - 'subpackage', $class['package']['subpackage'] - ); - } - - $xmlFile->appendChild($xmlClass); - - $xmlMetrics = $xmlDocument->createElement('metrics'); - $xmlMetrics->setAttribute('methods', count($class['methods'])); - $xmlMetrics->setAttribute('coveredmethods', $coveredMethods); - $xmlMetrics->setAttribute('conditionals', 0); - $xmlMetrics->setAttribute('coveredconditionals', 0); - $xmlMetrics->setAttribute('statements', $classStatements); - $xmlMetrics->setAttribute( - 'coveredstatements', $coveredClassStatements - ); - $xmlMetrics->setAttribute( - 'elements', - count($class['methods']) + - $classStatements - /* + conditionals */); - $xmlMetrics->setAttribute( - 'coveredelements', - $coveredMethods + - $coveredClassStatements - /* + coveredconditionals */ - ); - $xmlClass->appendChild($xmlMetrics); - } - - foreach ($coverage as $line => $data) { - if ($data === NULL || isset($lines[$line])) { - continue; - } - - $lines[$line] = array( - 'count' => count($data), 'type' => 'stmt' - ); - } - - ksort($lines); - - foreach ($lines as $line => $data) { - $xmlLine = $xmlDocument->createElement('line'); - $xmlLine->setAttribute('num', $line); - $xmlLine->setAttribute('type', $data['type']); - - if (isset($data['name'])) { - $xmlLine->setAttribute('name', $data['name']); - } - - if (isset($data['crap'])) { - $xmlLine->setAttribute('crap', $data['crap']); - } - - $xmlLine->setAttribute('count', $data['count']); - $xmlFile->appendChild($xmlLine); - } - - $linesOfCode = $item->getLinesOfCode(); - - $xmlMetrics = $xmlDocument->createElement('metrics'); - $xmlMetrics->setAttribute('loc', $linesOfCode['loc']); - $xmlMetrics->setAttribute('ncloc', $linesOfCode['ncloc']); - $xmlMetrics->setAttribute('classes', $item->getNumClassesAndTraits()); - $xmlMetrics->setAttribute('methods', $item->getNumMethods()); - $xmlMetrics->setAttribute( - 'coveredmethods', $item->getNumTestedMethods() - ); - $xmlMetrics->setAttribute('conditionals', 0); - $xmlMetrics->setAttribute('coveredconditionals', 0); - $xmlMetrics->setAttribute( - 'statements', $item->getNumExecutableLines() - ); - $xmlMetrics->setAttribute( - 'coveredstatements', $item->getNumExecutedLines() - ); - $xmlMetrics->setAttribute( - 'elements', - $item->getNumMethods() + - $item->getNumExecutableLines() - /* + conditionals */ - ); - $xmlMetrics->setAttribute( - 'coveredelements', - $item->getNumTestedMethods() + - $item->getNumExecutedLines() - /* + coveredconditionals */ - ); - $xmlFile->appendChild($xmlMetrics); - - if ($namespace == 'global') { - $xmlProject->appendChild($xmlFile); - } else { - if (!isset($packages[$namespace])) { - $packages[$namespace] = $xmlDocument->createElement( - 'package' - ); - - $packages[$namespace]->setAttribute('name', $namespace); - $xmlProject->appendChild($packages[$namespace]); - } - - $packages[$namespace]->appendChild($xmlFile); - } - } - - $linesOfCode = $report->getLinesOfCode(); - - $xmlMetrics = $xmlDocument->createElement('metrics'); - $xmlMetrics->setAttribute('files', count($report)); - $xmlMetrics->setAttribute('loc', $linesOfCode['loc']); - $xmlMetrics->setAttribute('ncloc', $linesOfCode['ncloc']); - $xmlMetrics->setAttribute( - 'classes', $report->getNumClassesAndTraits() - ); - $xmlMetrics->setAttribute('methods', $report->getNumMethods()); - $xmlMetrics->setAttribute( - 'coveredmethods', $report->getNumTestedMethods() - ); - $xmlMetrics->setAttribute('conditionals', 0); - $xmlMetrics->setAttribute('coveredconditionals', 0); - $xmlMetrics->setAttribute( - 'statements', $report->getNumExecutableLines() - ); - $xmlMetrics->setAttribute( - 'coveredstatements', $report->getNumExecutedLines() - ); - $xmlMetrics->setAttribute( - 'elements', - $report->getNumMethods() + - $report->getNumExecutableLines() - /* + conditionals */ - ); - $xmlMetrics->setAttribute( - 'coveredelements', - $report->getNumTestedMethods() + - $report->getNumExecutedLines() - /* + coveredconditionals */ - ); - $xmlProject->appendChild($xmlMetrics); - - if ($target !== NULL) { - if (!is_dir(dirname($target))) { - mkdir(dirname($target), 0777, TRUE); - } - - return $xmlDocument->save($target); - } else { - return $xmlDocument->saveXML(); - } - } + /** + * @param PHP_CodeCoverage $coverage + * @param string $target + * @param string $name + * @return string + */ + public function process(PHP_CodeCoverage $coverage, $target = NULL, $name = NULL) + { + $xmlDocument = new DOMDocument('1.0', 'UTF-8'); + $xmlDocument->formatOutput = TRUE; + + $xmlCoverage = $xmlDocument->createElement('coverage'); + $xmlCoverage->setAttribute('generated', (int)$_SERVER['REQUEST_TIME']); + $xmlDocument->appendChild($xmlCoverage); + + $xmlProject = $xmlDocument->createElement('project'); + $xmlProject->setAttribute('timestamp', (int)$_SERVER['REQUEST_TIME']); + + if (is_string($name)) { + $xmlProject->setAttribute('name', $name); + } + + $xmlCoverage->appendChild($xmlProject); + + $packages = array(); + $report = $coverage->getReport(); + unset($coverage); + + foreach ($report as $item) { + $namespace = 'global'; + + if (!$item instanceof PHP_CodeCoverage_Report_Node_File) { + continue; + } + + $xmlFile = $xmlDocument->createElement('file'); + $xmlFile->setAttribute('name', $item->getPath()); + + $classes = $item->getClassesAndTraits(); + $coverage = $item->getCoverageData(); + $lines = array(); + + foreach ($classes as $className => $class) { + $classStatements = 0; + $coveredClassStatements = 0; + $coveredMethods = 0; + + foreach ($class['methods'] as $methodName => $method) { + $methodCount = 0; + $methodLines = 0; + $methodLinesCovered = 0; + + for ($i = $method['startLine']; + $i <= $method['endLine']; + $i++) { + $add = TRUE; + $count = 0; + + if (isset($coverage[$i])) { + if ($coverage[$i] !== NULL) { + $classStatements++; + $methodLines++; + } else { + $add = FALSE; + } + + $count = count($coverage[$i]); + + if ($count > 0) { + $coveredClassStatements++; + $methodLinesCovered++; + } + } else { + $add = FALSE; + } + + $methodCount = max($methodCount, $count); + + if ($add) { + $lines[$i] = array( + 'count' => $count, 'type' => 'stmt' + ); + } + } + + if ($methodCount > 0) { + $coveredMethods++; + } + + $lines[$method['startLine']] = array( + 'count' => $methodCount, + 'crap' => $method['crap'], + 'type' => 'method', + 'name' => $methodName + ); + } + + if (!empty($class['package']['namespace'])) { + $namespace = $class['package']['namespace']; + } + + $xmlClass = $xmlDocument->createElement('class'); + $xmlClass->setAttribute('name', $className); + $xmlClass->setAttribute('namespace', $namespace); + + if (!empty($class['package']['fullPackage'])) { + $xmlClass->setAttribute( + 'fullPackage', $class['package']['fullPackage'] + ); + } + + if (!empty($class['package']['category'])) { + $xmlClass->setAttribute( + 'category', $class['package']['category'] + ); + } + + if (!empty($class['package']['package'])) { + $xmlClass->setAttribute( + 'package', $class['package']['package'] + ); + } + + if (!empty($class['package']['subpackage'])) { + $xmlClass->setAttribute( + 'subpackage', $class['package']['subpackage'] + ); + } + + $xmlFile->appendChild($xmlClass); + + $xmlMetrics = $xmlDocument->createElement('metrics'); + $xmlMetrics->setAttribute('methods', count($class['methods'])); + $xmlMetrics->setAttribute('coveredmethods', $coveredMethods); + $xmlMetrics->setAttribute('conditionals', 0); + $xmlMetrics->setAttribute('coveredconditionals', 0); + $xmlMetrics->setAttribute('statements', $classStatements); + $xmlMetrics->setAttribute( + 'coveredstatements', $coveredClassStatements + ); + $xmlMetrics->setAttribute( + 'elements', + count($class['methods']) + + $classStatements + /* + conditionals */); + $xmlMetrics->setAttribute( + 'coveredelements', + $coveredMethods + + $coveredClassStatements + /* + coveredconditionals */ + ); + $xmlClass->appendChild($xmlMetrics); + } + + foreach ($coverage as $line => $data) { + if ($data === NULL || isset($lines[$line])) { + continue; + } + + $lines[$line] = array( + 'count' => count($data), 'type' => 'stmt' + ); + } + + ksort($lines); + + foreach ($lines as $line => $data) { + $xmlLine = $xmlDocument->createElement('line'); + $xmlLine->setAttribute('num', $line); + $xmlLine->setAttribute('type', $data['type']); + + if (isset($data['name'])) { + $xmlLine->setAttribute('name', $data['name']); + } + + if (isset($data['crap'])) { + $xmlLine->setAttribute('crap', $data['crap']); + } + + $xmlLine->setAttribute('count', $data['count']); + $xmlFile->appendChild($xmlLine); + } + + $linesOfCode = $item->getLinesOfCode(); + + $xmlMetrics = $xmlDocument->createElement('metrics'); + $xmlMetrics->setAttribute('loc', $linesOfCode['loc']); + $xmlMetrics->setAttribute('ncloc', $linesOfCode['ncloc']); + $xmlMetrics->setAttribute('classes', $item->getNumClassesAndTraits()); + $xmlMetrics->setAttribute('methods', $item->getNumMethods()); + $xmlMetrics->setAttribute( + 'coveredmethods', $item->getNumTestedMethods() + ); + $xmlMetrics->setAttribute('conditionals', 0); + $xmlMetrics->setAttribute('coveredconditionals', 0); + $xmlMetrics->setAttribute( + 'statements', $item->getNumExecutableLines() + ); + $xmlMetrics->setAttribute( + 'coveredstatements', $item->getNumExecutedLines() + ); + $xmlMetrics->setAttribute( + 'elements', + $item->getNumMethods() + + $item->getNumExecutableLines() + /* + conditionals */ + ); + $xmlMetrics->setAttribute( + 'coveredelements', + $item->getNumTestedMethods() + + $item->getNumExecutedLines() + /* + coveredconditionals */ + ); + $xmlFile->appendChild($xmlMetrics); + + if ($namespace == 'global') { + $xmlProject->appendChild($xmlFile); + } else { + if (!isset($packages[$namespace])) { + $packages[$namespace] = $xmlDocument->createElement( + 'package' + ); + + $packages[$namespace]->setAttribute('name', $namespace); + $xmlProject->appendChild($packages[$namespace]); + } + + $packages[$namespace]->appendChild($xmlFile); + } + } + + $linesOfCode = $report->getLinesOfCode(); + + $xmlMetrics = $xmlDocument->createElement('metrics'); + $xmlMetrics->setAttribute('files', count($report)); + $xmlMetrics->setAttribute('loc', $linesOfCode['loc']); + $xmlMetrics->setAttribute('ncloc', $linesOfCode['ncloc']); + $xmlMetrics->setAttribute( + 'classes', $report->getNumClassesAndTraits() + ); + $xmlMetrics->setAttribute('methods', $report->getNumMethods()); + $xmlMetrics->setAttribute( + 'coveredmethods', $report->getNumTestedMethods() + ); + $xmlMetrics->setAttribute('conditionals', 0); + $xmlMetrics->setAttribute('coveredconditionals', 0); + $xmlMetrics->setAttribute( + 'statements', $report->getNumExecutableLines() + ); + $xmlMetrics->setAttribute( + 'coveredstatements', $report->getNumExecutedLines() + ); + $xmlMetrics->setAttribute( + 'elements', + $report->getNumMethods() + + $report->getNumExecutableLines() + /* + conditionals */ + ); + $xmlMetrics->setAttribute( + 'coveredelements', + $report->getNumTestedMethods() + + $report->getNumExecutedLines() + /* + coveredconditionals */ + ); + $xmlProject->appendChild($xmlMetrics); + + if ($target !== NULL) { + if (!is_dir(dirname($target))) { + mkdir(dirname($target), 0777, TRUE); + } + + return $xmlDocument->save($target); + } else { + return $xmlDocument->saveXML(); + } + } } diff --git a/PHP/CodeCoverage/Report/Factory.php b/PHP/CodeCoverage/Report/Factory.php index f2780fc8a..9f7dea2f1 100644 --- a/PHP/CodeCoverage/Report/Factory.php +++ b/PHP/CodeCoverage/Report/Factory.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,248 +34,248 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.1.0 */ /** * Factory for PHP_CodeCoverage_Report_Node_* object graphs. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.1.0 */ class PHP_CodeCoverage_Report_Factory { - /** - * @param PHP_CodeCoverage $coverage - */ - public function create(PHP_CodeCoverage $coverage) - { - $files = $coverage->getData(); - $commonPath = $this->reducePaths($files); - $root = new PHP_CodeCoverage_Report_Node_Directory( - $commonPath, NULL - ); + /** + * @param PHP_CodeCoverage $coverage + */ + public function create(PHP_CodeCoverage $coverage) + { + $files = $coverage->getData(); + $commonPath = $this->reducePaths($files); + $root = new PHP_CodeCoverage_Report_Node_Directory( + $commonPath, NULL + ); - $this->addItems( - $root, - $this->buildDirectoryStructure($files), - $coverage->getTests(), - $coverage->getCacheTokens() - ); + $this->addItems( + $root, + $this->buildDirectoryStructure($files), + $coverage->getTests(), + $coverage->getCacheTokens() + ); - return $root; - } + return $root; + } - /** - * @param PHP_CodeCoverage_Report_Node_Directory $root - * @param array $items - * @param array $tests - * @param boolean $cacheTokens - */ - protected function addItems(PHP_CodeCoverage_Report_Node_Directory $root, array $items, array $tests, $cacheTokens) - { - foreach ($items as $key => $value) { - if (substr($key, -2) == '/f') { - $key = substr($key, 0, -2); + /** + * @param PHP_CodeCoverage_Report_Node_Directory $root + * @param array $items + * @param array $tests + * @param boolean $cacheTokens + */ + protected function addItems(PHP_CodeCoverage_Report_Node_Directory $root, array $items, array $tests, $cacheTokens) + { + foreach ($items as $key => $value) { + if (substr($key, -2) == '/f') { + $key = substr($key, 0, -2); - if (file_exists($root->getPath() . DIRECTORY_SEPARATOR . $key)) { - $root->addFile($key, $value, $tests, $cacheTokens); - } - } else { - $child = $root->addDirectory($key); - $this->addItems($child, $value, $tests, $cacheTokens); - } - } - } + if (file_exists($root->getPath() . DIRECTORY_SEPARATOR . $key)) { + $root->addFile($key, $value, $tests, $cacheTokens); + } + } else { + $child = $root->addDirectory($key); + $this->addItems($child, $value, $tests, $cacheTokens); + } + } + } - /** - * Builds an array representation of the directory structure. - * - * For instance, - * - * - * Array - * ( - * [Money.php] => Array - * ( - * ... - * ) - * - * [MoneyBag.php] => Array - * ( - * ... - * ) - * ) - * - * - * is transformed into - * - * - * Array - * ( - * [.] => Array - * ( - * [Money.php] => Array - * ( - * ... - * ) - * - * [MoneyBag.php] => Array - * ( - * ... - * ) - * ) - * ) - * - * - * @param array $files - * @return array - */ - protected function buildDirectoryStructure($files) - { - $result = array(); + /** + * Builds an array representation of the directory structure. + * + * For instance, + * + * + * Array + * ( + * [Money.php] => Array + * ( + * ... + * ) + * + * [MoneyBag.php] => Array + * ( + * ... + * ) + * ) + * + * + * is transformed into + * + * + * Array + * ( + * [.] => Array + * ( + * [Money.php] => Array + * ( + * ... + * ) + * + * [MoneyBag.php] => Array + * ( + * ... + * ) + * ) + * ) + * + * + * @param array $files + * @return array + */ + protected function buildDirectoryStructure($files) + { + $result = array(); - foreach ($files as $path => $file) { - $path = explode('/', $path); - $pointer = &$result; - $max = count($path); + foreach ($files as $path => $file) { + $path = explode('/', $path); + $pointer = &$result; + $max = count($path); - for ($i = 0; $i < $max; $i++) { - if ($i == ($max - 1)) { - $type = '/f'; - } else { - $type = ''; - } + for ($i = 0; $i < $max; $i++) { + if ($i == ($max - 1)) { + $type = '/f'; + } else { + $type = ''; + } - $pointer = &$pointer[$path[$i] . $type]; - } + $pointer = &$pointer[$path[$i] . $type]; + } - $pointer = $file; - } + $pointer = $file; + } - return $result; - } + return $result; + } - /** - * Reduces the paths by cutting the longest common start path. - * - * For instance, - * - * - * Array - * ( - * [/home/sb/Money/Money.php] => Array - * ( - * ... - * ) - * - * [/home/sb/Money/MoneyBag.php] => Array - * ( - * ... - * ) - * ) - * - * - * is reduced to - * - * - * Array - * ( - * [Money.php] => Array - * ( - * ... - * ) - * - * [MoneyBag.php] => Array - * ( - * ... - * ) - * ) - * - * - * @param array $files - * @return string - */ - protected function reducePaths(&$files) - { - if (empty($files)) { - return '.'; - } + /** + * Reduces the paths by cutting the longest common start path. + * + * For instance, + * + * + * Array + * ( + * [/home/sb/Money/Money.php] => Array + * ( + * ... + * ) + * + * [/home/sb/Money/MoneyBag.php] => Array + * ( + * ... + * ) + * ) + * + * + * is reduced to + * + * + * Array + * ( + * [Money.php] => Array + * ( + * ... + * ) + * + * [MoneyBag.php] => Array + * ( + * ... + * ) + * ) + * + * + * @param array $files + * @return string + */ + protected function reducePaths(&$files) + { + if (empty($files)) { + return '.'; + } - $commonPath = ''; - $paths = array_keys($files); + $commonPath = ''; + $paths = array_keys($files); - if (count($files) == 1) { - $commonPath = dirname($paths[0]) . '/'; - $files[basename($paths[0])] = $files[$paths[0]]; + if (count($files) == 1) { + $commonPath = dirname($paths[0]) . '/'; + $files[basename($paths[0])] = $files[$paths[0]]; - unset($files[$paths[0]]); + unset($files[$paths[0]]); - return $commonPath; - } + return $commonPath; + } - $max = count($paths); + $max = count($paths); - for ($i = 0; $i < $max; $i++) { - // strip phar:// prefixes - if (strpos($paths[$i], 'phar://') === 0) { - $paths[$i] = substr($paths[$i], 7); - $paths[$i] = strtr($paths[$i], '/', DIRECTORY_SEPARATOR); - } - $paths[$i] = explode(DIRECTORY_SEPARATOR, $paths[$i]); + for ($i = 0; $i < $max; $i++) { + // strip phar:// prefixes + if (strpos($paths[$i], 'phar://') === 0) { + $paths[$i] = substr($paths[$i], 7); + $paths[$i] = strtr($paths[$i], '/', DIRECTORY_SEPARATOR); + } + $paths[$i] = explode(DIRECTORY_SEPARATOR, $paths[$i]); - if (empty($paths[$i][0])) { - $paths[$i][0] = DIRECTORY_SEPARATOR; - } - } + if (empty($paths[$i][0])) { + $paths[$i][0] = DIRECTORY_SEPARATOR; + } + } - $done = FALSE; - $max = count($paths); + $done = FALSE; + $max = count($paths); - while (!$done) { - for ($i = 0; $i < $max - 1; $i++) { - if (!isset($paths[$i][0]) || - !isset($paths[$i+1][0]) || - $paths[$i][0] != $paths[$i+1][0]) { - $done = TRUE; - break; - } - } + while (!$done) { + for ($i = 0; $i < $max - 1; $i++) { + if (!isset($paths[$i][0]) || + !isset($paths[$i+1][0]) || + $paths[$i][0] != $paths[$i+1][0]) { + $done = TRUE; + break; + } + } - if (!$done) { - $commonPath .= $paths[0][0]; + if (!$done) { + $commonPath .= $paths[0][0]; - if ($paths[0][0] != DIRECTORY_SEPARATOR) { - $commonPath .= DIRECTORY_SEPARATOR; - } + if ($paths[0][0] != DIRECTORY_SEPARATOR) { + $commonPath .= DIRECTORY_SEPARATOR; + } - for ($i = 0; $i < $max; $i++) { - array_shift($paths[$i]); - } - } - } + for ($i = 0; $i < $max; $i++) { + array_shift($paths[$i]); + } + } + } - $original = array_keys($files); - $max = count($original); + $original = array_keys($files); + $max = count($original); - for ($i = 0; $i < $max; $i++) { - $files[join('/', $paths[$i])] = $files[$original[$i]]; - unset($files[$original[$i]]); - } + for ($i = 0; $i < $max; $i++) { + $files[join('/', $paths[$i])] = $files[$original[$i]]; + unset($files[$original[$i]]); + } - ksort($files); + ksort($files); - return substr($commonPath, 0, -1); - } + return substr($commonPath, 0, -1); + } } diff --git a/PHP/CodeCoverage/Report/HTML.php b/PHP/CodeCoverage/Report/HTML.php index b2546259e..45d1af2ac 100644 --- a/PHP/CodeCoverage/Report/HTML.php +++ b/PHP/CodeCoverage/Report/HTML.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,189 +34,189 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.0.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.0.0 */ /** * Generates an HTML report from an PHP_CodeCoverage object. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.0.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.0.0 */ class PHP_CodeCoverage_Report_HTML { - /** - * @var string - */ - protected $templatePath; - - /** - * @var string - */ - protected $charset; - - /** - * @var string - */ - protected $generator; - - /** - * @var integer - */ - protected $lowUpperBound; - - /** - * @var integer - */ - protected $highLowerBound; - - /** - * @var boolean - */ - protected $highlight; - - /** - * Constructor. - * - * @param array $options - */ - public function __construct($charset = 'UTF-8', $highlight = FALSE, $lowUpperBound = 35, $highLowerBound = 70, $generator = '') - { - $this->charset = $charset; - $this->generator = $generator; - $this->highLowerBound = $highLowerBound; - $this->highlight = $highlight; - $this->lowUpperBound = $lowUpperBound; - - $this->templatePath = sprintf( - '%s%sHTML%sRenderer%sTemplate%s', - - dirname(__FILE__), - DIRECTORY_SEPARATOR, - DIRECTORY_SEPARATOR, - DIRECTORY_SEPARATOR, - DIRECTORY_SEPARATOR - ); - } - - /** - * @param PHP_CodeCoverage $coverage - * @param string $target - */ - public function process(PHP_CodeCoverage $coverage, $target) - { - $target = $this->getDirectory($target); - $report = $coverage->getReport(); - unset($coverage); - - if (!isset($_SERVER['REQUEST_TIME'])) { - $_SERVER['REQUEST_TIME'] = time(); - } - - $date = date('D M j G:i:s T Y', $_SERVER['REQUEST_TIME']); - - $dashboard = new PHP_CodeCoverage_Report_HTML_Renderer_Dashboard( - $this->templatePath, - $this->charset, - $this->generator, - $date, - $this->lowUpperBound, - $this->highLowerBound - ); - - $directory = new PHP_CodeCoverage_Report_HTML_Renderer_Directory( - $this->templatePath, - $this->charset, - $this->generator, - $date, - $this->lowUpperBound, - $this->highLowerBound - ); - - $file = new PHP_CodeCoverage_Report_HTML_Renderer_File( - $this->templatePath, - $this->charset, - $this->generator, - $date, - $this->lowUpperBound, - $this->highLowerBound, - $this->highlight - ); - - $dashboard->render($report, $target . 'index.dashboard.html'); - $directory->render($report, $target . 'index.html'); - - foreach ($report as $node) { - $id = $node->getId(); - - if ($node instanceof PHP_CodeCoverage_Report_Node_Directory) { - $dashboard->render($node, $target . $id . '.dashboard.html'); - $directory->render($node, $target . $id . '.html'); - } else { - $file->render($node, $target . $id . '.html'); - } - } - - $this->copyFiles($target); - } - - /** - * @param string $target - */ - protected function copyFiles($target) - { - $dir = $this->getDirectory($target . 'css'); - copy($this->templatePath . 'css/bootstrap.min.css', $dir . 'bootstrap.min.css'); - copy($this->templatePath . 'css/bootstrap-responsive.min.css', $dir . 'bootstrap-responsive.min.css'); - copy($this->templatePath . 'css/style.css', $dir . 'style.css'); - - $dir = $this->getDirectory($target . 'js'); - copy($this->templatePath . 'js/bootstrap.min.js', $dir . 'bootstrap.min.js'); - copy($this->templatePath . 'js/highcharts.js', $dir . 'highcharts.js'); - copy($this->templatePath . 'js/jquery.min.js', $dir . 'jquery.min.js'); - copy($this->templatePath . 'js/html5shiv.js', $dir . 'html5shiv.js'); - - $dir = $this->getDirectory($target . 'img'); - copy($this->templatePath . 'img/glyphicons-halflings.png', $dir . 'glyphicons-halflings.png'); - copy($this->templatePath . 'img/glyphicons-halflings-white.png', $dir . 'glyphicons-halflings-white.png'); - } - - /** - * @param string $directory - * @return string - * @throws PHP_CodeCoverage_Exception - * @since Method available since Release 1.2.0 - */ - protected function getDirectory($directory) - { - if (substr($directory, -1, 1) != DIRECTORY_SEPARATOR) { - $directory .= DIRECTORY_SEPARATOR; - } - - if (is_dir($directory)) { - return $directory; - } - - if (@mkdir($directory, 0777, TRUE)) { - return $directory; - } - - throw new PHP_CodeCoverage_Exception( - sprintf( - 'Directory "%s" does not exist.', - $directory - ) - ); - } + /** + * @var string + */ + protected $templatePath; + + /** + * @var string + */ + protected $charset; + + /** + * @var string + */ + protected $generator; + + /** + * @var integer + */ + protected $lowUpperBound; + + /** + * @var integer + */ + protected $highLowerBound; + + /** + * @var boolean + */ + protected $highlight; + + /** + * Constructor. + * + * @param array $options + */ + public function __construct($charset = 'UTF-8', $highlight = FALSE, $lowUpperBound = 35, $highLowerBound = 70, $generator = '') + { + $this->charset = $charset; + $this->generator = $generator; + $this->highLowerBound = $highLowerBound; + $this->highlight = $highlight; + $this->lowUpperBound = $lowUpperBound; + + $this->templatePath = sprintf( + '%s%sHTML%sRenderer%sTemplate%s', + + dirname(__FILE__), + DIRECTORY_SEPARATOR, + DIRECTORY_SEPARATOR, + DIRECTORY_SEPARATOR, + DIRECTORY_SEPARATOR + ); + } + + /** + * @param PHP_CodeCoverage $coverage + * @param string $target + */ + public function process(PHP_CodeCoverage $coverage, $target) + { + $target = $this->getDirectory($target); + $report = $coverage->getReport(); + unset($coverage); + + if (!isset($_SERVER['REQUEST_TIME'])) { + $_SERVER['REQUEST_TIME'] = time(); + } + + $date = date('D M j G:i:s T Y', $_SERVER['REQUEST_TIME']); + + $dashboard = new PHP_CodeCoverage_Report_HTML_Renderer_Dashboard( + $this->templatePath, + $this->charset, + $this->generator, + $date, + $this->lowUpperBound, + $this->highLowerBound + ); + + $directory = new PHP_CodeCoverage_Report_HTML_Renderer_Directory( + $this->templatePath, + $this->charset, + $this->generator, + $date, + $this->lowUpperBound, + $this->highLowerBound + ); + + $file = new PHP_CodeCoverage_Report_HTML_Renderer_File( + $this->templatePath, + $this->charset, + $this->generator, + $date, + $this->lowUpperBound, + $this->highLowerBound, + $this->highlight + ); + + $dashboard->render($report, $target . 'index.dashboard.html'); + $directory->render($report, $target . 'index.html'); + + foreach ($report as $node) { + $id = $node->getId(); + + if ($node instanceof PHP_CodeCoverage_Report_Node_Directory) { + $dashboard->render($node, $target . $id . '.dashboard.html'); + $directory->render($node, $target . $id . '.html'); + } else { + $file->render($node, $target . $id . '.html'); + } + } + + $this->copyFiles($target); + } + + /** + * @param string $target + */ + protected function copyFiles($target) + { + $dir = $this->getDirectory($target . 'css'); + copy($this->templatePath . 'css/bootstrap.min.css', $dir . 'bootstrap.min.css'); + copy($this->templatePath . 'css/bootstrap-responsive.min.css', $dir . 'bootstrap-responsive.min.css'); + copy($this->templatePath . 'css/style.css', $dir . 'style.css'); + + $dir = $this->getDirectory($target . 'js'); + copy($this->templatePath . 'js/bootstrap.min.js', $dir . 'bootstrap.min.js'); + copy($this->templatePath . 'js/highcharts.js', $dir . 'highcharts.js'); + copy($this->templatePath . 'js/jquery.min.js', $dir . 'jquery.min.js'); + copy($this->templatePath . 'js/html5shiv.js', $dir . 'html5shiv.js'); + + $dir = $this->getDirectory($target . 'img'); + copy($this->templatePath . 'img/glyphicons-halflings.png', $dir . 'glyphicons-halflings.png'); + copy($this->templatePath . 'img/glyphicons-halflings-white.png', $dir . 'glyphicons-halflings-white.png'); + } + + /** + * @param string $directory + * @return string + * @throws PHP_CodeCoverage_Exception + * @since Method available since Release 1.2.0 + */ + protected function getDirectory($directory) + { + if (substr($directory, -1, 1) != DIRECTORY_SEPARATOR) { + $directory .= DIRECTORY_SEPARATOR; + } + + if (is_dir($directory)) { + return $directory; + } + + if (@mkdir($directory, 0777, TRUE)) { + return $directory; + } + + throw new PHP_CodeCoverage_Exception( + sprintf( + 'Directory "%s" does not exist.', + $directory + ) + ); + } } diff --git a/PHP/CodeCoverage/Report/HTML/Renderer.php b/PHP/CodeCoverage/Report/HTML/Renderer.php index ac8500c0e..22b9ad7bd 100644 --- a/PHP/CodeCoverage/Report/HTML/Renderer.php +++ b/PHP/CodeCoverage/Report/HTML/Renderer.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,244 +34,244 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.1.0 */ /** * Base class for PHP_CodeCoverage_Report_Node renderers. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.1.0 */ abstract class PHP_CodeCoverage_Report_HTML_Renderer { - /** - * @var string - */ - protected $templatePath; - - /** - * @var string - */ - protected $charset; - - /** - * @var string - */ - protected $generator; - - /** - * @var string - */ - protected $date; - - /** - * @var integer - */ - protected $lowUpperBound; - - /** - * @var integer - */ - protected $highLowerBound; - - /** - * @var string - */ - protected $version; - - /** - * Constructor. - * - * @param string $templatePath - * @param string $charset - * @param string $generator - * @param string $date - * @param integer $lowUpperBound - * @param integer $highLowerBound - */ - public function __construct($templatePath, $charset, $generator, $date, $lowUpperBound, $highLowerBound) - { - $version = new SebastianBergmann\Version('1.3', __DIR__); - - $this->templatePath = $templatePath; - $this->charset = $charset; - $this->generator = $generator; - $this->date = $date; - $this->lowUpperBound = $lowUpperBound; - $this->highLowerBound = $highLowerBound; - $this->version = $version->getVersion(); - } - - /** - * @param Text_Template $template - * @param array $data - * @return string - */ - protected function renderItemTemplate(Text_Template $template, array $data) - { - $classesBar = ' '; - $classesLevel = 'None'; - $classesNumber = ' '; - - if (isset($data['numClasses']) && $data['numClasses'] > 0) { - $classesLevel = $this->getColorLevel($data['testedClassesPercent']); - - $classesNumber = $data['numTestedClasses'] . ' / ' . - $data['numClasses']; - - $classesBar = $this->getCoverageBar( - $data['testedClassesPercent'] - ); - } - - $methodsBar = ' '; - $methodsLevel = 'None'; - $methodsNumber = ' '; - - if ($data['numMethods'] > 0) { - $methodsLevel = $this->getColorLevel($data['testedMethodsPercent']); - - $methodsNumber = $data['numTestedMethods'] . ' / ' . - $data['numMethods']; - - $methodsBar = $this->getCoverageBar( - $data['testedMethodsPercent'] - ); - } - - $linesBar = ' '; - $linesLevel = 'None'; - $linesNumber = ' '; - - if ($data['numExecutableLines'] > 0) { - $linesLevel = $this->getColorLevel($data['linesExecutedPercent']); - - $linesNumber = $data['numExecutedLines'] . ' / ' . - $data['numExecutableLines']; - - $linesBar = $this->getCoverageBar( - $data['linesExecutedPercent'] - ); - } - - $template->setVar( - array( - 'icon' => isset($data['icon']) ? $data['icon'] : '', - 'crap' => isset($data['crap']) ? $data['crap'] : '', - 'name' => $data['name'], - 'lines_bar' => $linesBar, - 'lines_executed_percent' => $data['linesExecutedPercentAsString'], - 'lines_level' => $linesLevel, - 'lines_number' => $linesNumber, - 'methods_bar' => $methodsBar, - 'methods_tested_percent' => $data['testedMethodsPercentAsString'], - 'methods_level' => $methodsLevel, - 'methods_number' => $methodsNumber, - 'classes_bar' => $classesBar, - 'classes_tested_percent' => isset($data['testedClassesPercentAsString']) ? $data['testedClassesPercentAsString'] : '', - 'classes_level' => $classesLevel, - 'classes_number' => $classesNumber - ) - ); - - return $template->render(); - } - - /** - * @param Text_Template $template - * @param PHP_CodeCoverage_Report_Node $node - */ - protected function setCommonTemplateVariables(Text_Template $template, PHP_CodeCoverage_Report_Node $node) - { - $template->setVar( - array( - 'id' => $node->getId(), - 'full_path' => $node->getPath(), - 'breadcrumbs' => $this->getBreadcrumbs($node), - 'charset' => $this->charset, - 'date' => $this->date, - 'version' => $this->version, - 'php_version' => PHP_VERSION, - 'generator' => $this->generator, - 'low_upper_bound' => $this->lowUpperBound, - 'high_lower_bound' => $this->highLowerBound - ) - ); - } - - protected function getBreadcrumbs(PHP_CodeCoverage_Report_Node $node) - { - $breadcrumbs = ''; - - $path = $node->getPathAsArray(); - - foreach ($path as $step) { - if ($step !== $node) { - $breadcrumbs .= sprintf( - '
  • %s /
  • ' . "\n", - $step->getId(), - $step->getName() - ); - } else { - $breadcrumbs .= sprintf( - '
  • %s
  • ' . "\n", - $step->getName() - ); - - if ($node instanceof PHP_CodeCoverage_Report_Node_Directory) { - $breadcrumbs .= sprintf( - '
  • (Dashboard)
  • ' . "\n", - $step->getId() - ); - } - } - } - - return $breadcrumbs; - } - - protected function getCoverageBar($percent) - { - $level = $this->getColorLevel($percent); - - $template = new Text_Template( - $this->templatePath . 'coverage_bar.html' - ); - - $template->setVar(array('level' => $level, 'percent' => sprintf("%.2F", $percent))); - - return $template->render(); - } - - /** - * @param integer $percent - * @return string - */ - protected function getColorLevel($percent) - { - if ($percent < $this->lowUpperBound) { - return 'danger'; - } - - else if ($percent >= $this->lowUpperBound && - $percent < $this->highLowerBound) { - return 'warning'; - } - - else { - return 'success'; - } - } + /** + * @var string + */ + protected $templatePath; + + /** + * @var string + */ + protected $charset; + + /** + * @var string + */ + protected $generator; + + /** + * @var string + */ + protected $date; + + /** + * @var integer + */ + protected $lowUpperBound; + + /** + * @var integer + */ + protected $highLowerBound; + + /** + * @var string + */ + protected $version; + + /** + * Constructor. + * + * @param string $templatePath + * @param string $charset + * @param string $generator + * @param string $date + * @param integer $lowUpperBound + * @param integer $highLowerBound + */ + public function __construct($templatePath, $charset, $generator, $date, $lowUpperBound, $highLowerBound) + { + $version = new SebastianBergmann\Version('1.3', __DIR__); + + $this->templatePath = $templatePath; + $this->charset = $charset; + $this->generator = $generator; + $this->date = $date; + $this->lowUpperBound = $lowUpperBound; + $this->highLowerBound = $highLowerBound; + $this->version = $version->getVersion(); + } + + /** + * @param Text_Template $template + * @param array $data + * @return string + */ + protected function renderItemTemplate(Text_Template $template, array $data) + { + $classesBar = ' '; + $classesLevel = 'None'; + $classesNumber = ' '; + + if (isset($data['numClasses']) && $data['numClasses'] > 0) { + $classesLevel = $this->getColorLevel($data['testedClassesPercent']); + + $classesNumber = $data['numTestedClasses'] . ' / ' . + $data['numClasses']; + + $classesBar = $this->getCoverageBar( + $data['testedClassesPercent'] + ); + } + + $methodsBar = ' '; + $methodsLevel = 'None'; + $methodsNumber = ' '; + + if ($data['numMethods'] > 0) { + $methodsLevel = $this->getColorLevel($data['testedMethodsPercent']); + + $methodsNumber = $data['numTestedMethods'] . ' / ' . + $data['numMethods']; + + $methodsBar = $this->getCoverageBar( + $data['testedMethodsPercent'] + ); + } + + $linesBar = ' '; + $linesLevel = 'None'; + $linesNumber = ' '; + + if ($data['numExecutableLines'] > 0) { + $linesLevel = $this->getColorLevel($data['linesExecutedPercent']); + + $linesNumber = $data['numExecutedLines'] . ' / ' . + $data['numExecutableLines']; + + $linesBar = $this->getCoverageBar( + $data['linesExecutedPercent'] + ); + } + + $template->setVar( + array( + 'icon' => isset($data['icon']) ? $data['icon'] : '', + 'crap' => isset($data['crap']) ? $data['crap'] : '', + 'name' => $data['name'], + 'lines_bar' => $linesBar, + 'lines_executed_percent' => $data['linesExecutedPercentAsString'], + 'lines_level' => $linesLevel, + 'lines_number' => $linesNumber, + 'methods_bar' => $methodsBar, + 'methods_tested_percent' => $data['testedMethodsPercentAsString'], + 'methods_level' => $methodsLevel, + 'methods_number' => $methodsNumber, + 'classes_bar' => $classesBar, + 'classes_tested_percent' => isset($data['testedClassesPercentAsString']) ? $data['testedClassesPercentAsString'] : '', + 'classes_level' => $classesLevel, + 'classes_number' => $classesNumber + ) + ); + + return $template->render(); + } + + /** + * @param Text_Template $template + * @param PHP_CodeCoverage_Report_Node $node + */ + protected function setCommonTemplateVariables(Text_Template $template, PHP_CodeCoverage_Report_Node $node) + { + $template->setVar( + array( + 'id' => $node->getId(), + 'full_path' => $node->getPath(), + 'breadcrumbs' => $this->getBreadcrumbs($node), + 'charset' => $this->charset, + 'date' => $this->date, + 'version' => $this->version, + 'php_version' => PHP_VERSION, + 'generator' => $this->generator, + 'low_upper_bound' => $this->lowUpperBound, + 'high_lower_bound' => $this->highLowerBound + ) + ); + } + + protected function getBreadcrumbs(PHP_CodeCoverage_Report_Node $node) + { + $breadcrumbs = ''; + + $path = $node->getPathAsArray(); + + foreach ($path as $step) { + if ($step !== $node) { + $breadcrumbs .= sprintf( + '
  • %s /
  • ' . "\n", + $step->getId(), + $step->getName() + ); + } else { + $breadcrumbs .= sprintf( + '
  • %s
  • ' . "\n", + $step->getName() + ); + + if ($node instanceof PHP_CodeCoverage_Report_Node_Directory) { + $breadcrumbs .= sprintf( + '
  • (Dashboard)
  • ' . "\n", + $step->getId() + ); + } + } + } + + return $breadcrumbs; + } + + protected function getCoverageBar($percent) + { + $level = $this->getColorLevel($percent); + + $template = new Text_Template( + $this->templatePath . 'coverage_bar.html' + ); + + $template->setVar(array('level' => $level, 'percent' => sprintf("%.2F", $percent))); + + return $template->render(); + } + + /** + * @param integer $percent + * @return string + */ + protected function getColorLevel($percent) + { + if ($percent < $this->lowUpperBound) { + return 'danger'; + } + + else if ($percent >= $this->lowUpperBound && + $percent < $this->highLowerBound) { + return 'warning'; + } + + else { + return 'success'; + } + } } diff --git a/PHP/CodeCoverage/Report/HTML/Renderer/Dashboard.php b/PHP/CodeCoverage/Report/HTML/Renderer/Dashboard.php index f0767ac14..e44bca0d9 100644 --- a/PHP/CodeCoverage/Report/HTML/Renderer/Dashboard.php +++ b/PHP/CodeCoverage/Report/HTML/Renderer/Dashboard.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,223 +34,223 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.1.0 */ /** * Renders the dashboard for a PHP_CodeCoverage_Report_Node_Directory node. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.1.0 */ class PHP_CodeCoverage_Report_HTML_Renderer_Dashboard extends PHP_CodeCoverage_Report_HTML_Renderer { - /** - * @param PHP_CodeCoverage_Report_Node_Directory $node - * @param string $file - */ - public function render(PHP_CodeCoverage_Report_Node_Directory $node, $file) - { - $classes = $node->getClassesAndTraits(); - $template = new Text_Template( - $this->templatePath . 'dashboard.html' - ); + /** + * @param PHP_CodeCoverage_Report_Node_Directory $node + * @param string $file + */ + public function render(PHP_CodeCoverage_Report_Node_Directory $node, $file) + { + $classes = $node->getClassesAndTraits(); + $template = new Text_Template( + $this->templatePath . 'dashboard.html' + ); - $this->setCommonTemplateVariables($template, $node); + $this->setCommonTemplateVariables($template, $node); - $template->setVar( - array( - 'least_tested_methods' => $this->leastTestedMethods($classes), - 'top_project_risks' => $this->topProjectRisks($classes), - 'cc_values' => $this->classComplexity($classes), - 'ccd_values' => $this->classCoverageDistribution($classes), - 'backlink' => basename(str_replace('.dashboard', '', $file)) - ) - ); + $template->setVar( + array( + 'least_tested_methods' => $this->leastTestedMethods($classes), + 'top_project_risks' => $this->topProjectRisks($classes), + 'cc_values' => $this->classComplexity($classes), + 'ccd_values' => $this->classCoverageDistribution($classes), + 'backlink' => basename(str_replace('.dashboard', '', $file)) + ) + ); - $template->renderTo($file); - } + $template->renderTo($file); + } - /** - * Returns the data for the Class Complexity chart. - * - * @param array $classes - * @return string - */ - protected function classComplexity(array $classes) - { - $data = array(); + /** + * Returns the data for the Class Complexity chart. + * + * @param array $classes + * @return string + */ + protected function classComplexity(array $classes) + { + $data = array(); - foreach ($classes as $name => $class) { - $data[] = array( - $class['coverage'], - $class['ccn'], - sprintf( - '%s', - $class['link'], - $name - ) - ); - } + foreach ($classes as $name => $class) { + $data[] = array( + $class['coverage'], + $class['ccn'], + sprintf( + '%s', + $class['link'], + $name + ) + ); + } - return json_encode($data); - } + return json_encode($data); + } - /** - * Returns the data for the Class Coverage Distribution chart. - * - * @param array $classes - * @return string - */ - protected function classCoverageDistribution(array $classes) - { - $data = array( - '0%' => 0, - '0-10%' => 0, - '10-20%' => 0, - '20-30%' => 0, - '30-40%' => 0, - '40-50%' => 0, - '50-60%' => 0, - '60-70%' => 0, - '70-80%' => 0, - '80-90%' => 0, - '90-100%' => 0, - '100%' => 0 - ); + /** + * Returns the data for the Class Coverage Distribution chart. + * + * @param array $classes + * @return string + */ + protected function classCoverageDistribution(array $classes) + { + $data = array( + '0%' => 0, + '0-10%' => 0, + '10-20%' => 0, + '20-30%' => 0, + '30-40%' => 0, + '40-50%' => 0, + '50-60%' => 0, + '60-70%' => 0, + '70-80%' => 0, + '80-90%' => 0, + '90-100%' => 0, + '100%' => 0 + ); - foreach ($classes as $class) { - if ($class['coverage'] == 0) { - $data['0%']++; - } + foreach ($classes as $class) { + if ($class['coverage'] == 0) { + $data['0%']++; + } - else if ($class['coverage'] == 100) { - $data['100%']++; - } + else if ($class['coverage'] == 100) { + $data['100%']++; + } - else { - $key = floor($class['coverage']/10)*10; - $key = $key . '-' . ($key + 10) . '%'; - $data[$key]++; - } - } + else { + $key = floor($class['coverage']/10)*10; + $key = $key . '-' . ($key + 10) . '%'; + $data[$key]++; + } + } - return json_encode(array_values($data)); - } + return json_encode(array_values($data)); + } - /** - * Returns the least tested methods. - * - * @param array $classes - * @param integer $max - * @return string - */ - protected function leastTestedMethods(array $classes, $max = 10) - { - $methods = array(); + /** + * Returns the least tested methods. + * + * @param array $classes + * @param integer $max + * @return string + */ + protected function leastTestedMethods(array $classes, $max = 10) + { + $methods = array(); - foreach ($classes as $className => $class) { - foreach ($class['methods'] as $methodName => $method) { - if ($method['coverage'] < 100) { - if ($className != '*') { - $key = $className . '::' . $methodName; - } else { - $key = $methodName; - } + foreach ($classes as $className => $class) { + foreach ($class['methods'] as $methodName => $method) { + if ($method['coverage'] < 100) { + if ($className != '*') { + $key = $className . '::' . $methodName; + } else { + $key = $methodName; + } - $methods[$key] = $method['coverage']; - } - } - } + $methods[$key] = $method['coverage']; + } + } + } - asort($methods); + asort($methods); - $methods = array_slice($methods, 0, min($max, count($methods))); - $buffer = ''; + $methods = array_slice($methods, 0, min($max, count($methods))); + $buffer = ''; - foreach ($methods as $name => $coverage) { - list($class, $method) = explode('::', $name); + foreach ($methods as $name => $coverage) { + list($class, $method) = explode('::', $name); - $buffer .= sprintf( - '
  • %s (%d%%)
  • ' . "\n", - $classes[$class]['methods'][$method]['link'], - $name, - $coverage - ); - } + $buffer .= sprintf( + '
  • %s (%d%%)
  • ' . "\n", + $classes[$class]['methods'][$method]['link'], + $name, + $coverage + ); + } - return $buffer; - } + return $buffer; + } - /** - * Returns the top project risks according to the CRAP index. - * - * @param array $classes - * @param integer $max - * @return string - */ - protected function topProjectRisks(array $classes, $max = 10) - { - $risks = array(); + /** + * Returns the top project risks according to the CRAP index. + * + * @param array $classes + * @param integer $max + * @return string + */ + protected function topProjectRisks(array $classes, $max = 10) + { + $risks = array(); - foreach ($classes as $className => $class) { - if ($class['coverage'] < 100 && - $class['ccn'] > count($class['methods'])) { - $risks[$className] = $class['crap']; - } - } + foreach ($classes as $className => $class) { + if ($class['coverage'] < 100 && + $class['ccn'] > count($class['methods'])) { + $risks[$className] = $class['crap']; + } + } - arsort($risks); + arsort($risks); - $buffer = ''; - $risks = array_slice($risks, 0, min($max, count($risks))); + $buffer = ''; + $risks = array_slice($risks, 0, min($max, count($risks))); - foreach ($risks as $name => $crap) { - $buffer .= sprintf( - '
  • %s (%d)
  • ' . "\n", - $classes[$name]['link'], - $name, - $crap - ); - } + foreach ($risks as $name => $crap) { + $buffer .= sprintf( + '
  • %s (%d)
  • ' . "\n", + $classes[$name]['link'], + $name, + $crap + ); + } - return $buffer; - } + return $buffer; + } - protected function getBreadcrumbs(PHP_CodeCoverage_Report_Node $node) - { - $breadcrumbs = ''; + protected function getBreadcrumbs(PHP_CodeCoverage_Report_Node $node) + { + $breadcrumbs = ''; - $path = $node->getPathAsArray(); + $path = $node->getPathAsArray(); - foreach ($path as $step) { - if ($step !== $node) { - $breadcrumbs .= sprintf( - '
  • %s /
  • ' . "\n", - $step->getId(), - $step->getName() - ); - } else { - $breadcrumbs .= sprintf( - '
  • %s
  • ' . "\n" . - '
  • (Dashboard)
  • ' . "\n", - $step->getId(), - $step->getName() - ); - } - } + foreach ($path as $step) { + if ($step !== $node) { + $breadcrumbs .= sprintf( + '
  • %s /
  • ' . "\n", + $step->getId(), + $step->getName() + ); + } else { + $breadcrumbs .= sprintf( + '
  • %s
  • ' . "\n" . + '
  • (Dashboard)
  • ' . "\n", + $step->getId(), + $step->getName() + ); + } + } - return $breadcrumbs; - } + return $breadcrumbs; + } } diff --git a/PHP/CodeCoverage/Report/HTML/Renderer/Directory.php b/PHP/CodeCoverage/Report/HTML/Renderer/Directory.php index c38f84489..573e2996f 100644 --- a/PHP/CodeCoverage/Report/HTML/Renderer/Directory.php +++ b/PHP/CodeCoverage/Report/HTML/Renderer/Directory.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,99 +34,99 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.1.0 */ /** * Renders a PHP_CodeCoverage_Report_Node_Directory node. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.1.0 */ class PHP_CodeCoverage_Report_HTML_Renderer_Directory extends PHP_CodeCoverage_Report_HTML_Renderer { - /** - * @param PHP_CodeCoverage_Report_Node_Directory $node - * @param string $file - */ - public function render(PHP_CodeCoverage_Report_Node_Directory $node, $file) - { - $template = new Text_Template($this->templatePath . 'directory.html'); + /** + * @param PHP_CodeCoverage_Report_Node_Directory $node + * @param string $file + */ + public function render(PHP_CodeCoverage_Report_Node_Directory $node, $file) + { + $template = new Text_Template($this->templatePath . 'directory.html'); - $this->setCommonTemplateVariables($template, $node); + $this->setCommonTemplateVariables($template, $node); - $items = $this->renderItem($node, TRUE); + $items = $this->renderItem($node, TRUE); - foreach ($node->getDirectories() as $item) { - $items .= $this->renderItem($item); - } + foreach ($node->getDirectories() as $item) { + $items .= $this->renderItem($item); + } - foreach ($node->getFiles() as $item) { - $items .= $this->renderItem($item); - } + foreach ($node->getFiles() as $item) { + $items .= $this->renderItem($item); + } - $template->setVar( - array( - 'id' => $node->getId(), - 'items' => $items - ) - ); + $template->setVar( + array( + 'id' => $node->getId(), + 'items' => $items + ) + ); - $template->renderTo($file); - } + $template->renderTo($file); + } - /** - * @param PHP_CodeCoverage_Report_Node $item - * @param boolean $total - * @return string - */ - protected function renderItem(PHP_CodeCoverage_Report_Node $item, $total = FALSE) - { - $data = array( - 'numClasses' => $item->getNumClassesAndTraits(), - 'numTestedClasses' => $item->getNumTestedClassesAndTraits(), - 'numMethods' => $item->getNumMethods(), - 'numTestedMethods' => $item->getNumTestedMethods(), - 'linesExecutedPercent' => $item->getLineExecutedPercent(FALSE), - 'linesExecutedPercentAsString' => $item->getLineExecutedPercent(), - 'numExecutedLines' => $item->getNumExecutedLines(), - 'numExecutableLines' => $item->getNumExecutableLines(), - 'testedMethodsPercent' => $item->getTestedMethodsPercent(FALSE), - 'testedMethodsPercentAsString' => $item->getTestedMethodsPercent(), - 'testedClassesPercent' => $item->getTestedClassesAndTraitsPercent(FALSE), - 'testedClassesPercentAsString' => $item->getTestedClassesAndTraitsPercent() - ); + /** + * @param PHP_CodeCoverage_Report_Node $item + * @param boolean $total + * @return string + */ + protected function renderItem(PHP_CodeCoverage_Report_Node $item, $total = FALSE) + { + $data = array( + 'numClasses' => $item->getNumClassesAndTraits(), + 'numTestedClasses' => $item->getNumTestedClassesAndTraits(), + 'numMethods' => $item->getNumMethods(), + 'numTestedMethods' => $item->getNumTestedMethods(), + 'linesExecutedPercent' => $item->getLineExecutedPercent(FALSE), + 'linesExecutedPercentAsString' => $item->getLineExecutedPercent(), + 'numExecutedLines' => $item->getNumExecutedLines(), + 'numExecutableLines' => $item->getNumExecutableLines(), + 'testedMethodsPercent' => $item->getTestedMethodsPercent(FALSE), + 'testedMethodsPercentAsString' => $item->getTestedMethodsPercent(), + 'testedClassesPercent' => $item->getTestedClassesAndTraitsPercent(FALSE), + 'testedClassesPercentAsString' => $item->getTestedClassesAndTraitsPercent() + ); - if ($total) { - $data['name'] = 'Total'; - } else { - $data['name'] = sprintf( - '%s', - $item->getId(), - $item->getName() - ); + if ($total) { + $data['name'] = 'Total'; + } else { + $data['name'] = sprintf( + '%s', + $item->getId(), + $item->getName() + ); - if ($item instanceof PHP_CodeCoverage_Report_Node_Directory) { - $data['icon'] = ' '; - } else { - $data['icon'] = ' '; - } - } + if ($item instanceof PHP_CodeCoverage_Report_Node_Directory) { + $data['icon'] = ' '; + } else { + $data['icon'] = ' '; + } + } - return $this->renderItemTemplate( - new Text_Template($this->templatePath . 'directory_item.html'), - $data - ); - } + return $this->renderItemTemplate( + new Text_Template($this->templatePath . 'directory_item.html'), + $data + ); + } } diff --git a/PHP/CodeCoverage/Report/HTML/Renderer/File.php b/PHP/CodeCoverage/Report/HTML/Renderer/File.php index c03a84909..e17646806 100644 --- a/PHP/CodeCoverage/Report/HTML/Renderer/File.php +++ b/PHP/CodeCoverage/Report/HTML/Renderer/File.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,535 +34,535 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.1.0 */ /** * Renders a PHP_CodeCoverage_Report_Node_File node. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.1.0 */ class PHP_CodeCoverage_Report_HTML_Renderer_File extends PHP_CodeCoverage_Report_HTML_Renderer { - /** - * @var boolean - */ - protected $highlight; - - /** - * Constructor. - * - * @param string $templatePath - * @param string $charset - * @param string $generator - * @param string $date - * @param integer $lowUpperBound - * @param integer $highLowerBound - * @param boolean $highlight - */ - public function __construct($templatePath, $charset, $generator, $date, $lowUpperBound, $highLowerBound, $highlight) - { - parent::__construct( - $templatePath, - $charset, - $generator, - $date, - $lowUpperBound, - $highLowerBound - ); - - $this->highlight = $highlight; - } - - /** - * @param PHP_CodeCoverage_Report_Node_File $node - * @param string $file - */ - public function render(PHP_CodeCoverage_Report_Node_File $node, $file) - { - $template = new Text_Template($this->templatePath . 'file.html'); - - $template->setVar( - array( - 'items' => $this->renderItems($node), - 'lines' => $this->renderSource($node) - ) - ); - - $this->setCommonTemplateVariables($template, $node); - - $template->renderTo($file); - } - - /** - * @param PHP_CodeCoverage_Report_Node_File $node - * @return string - */ - protected function renderItems(PHP_CodeCoverage_Report_Node_File $node) - { - $template = new Text_Template($this->templatePath . 'file_item.html'); - - $methodItemTemplate = new Text_Template( - $this->templatePath . 'method_item.html' - ); - - $items = $this->renderItemTemplate( - $template, - array( - 'name' => 'Total', - 'numClasses' => $node->getNumClassesAndTraits(), - 'numTestedClasses' => $node->getNumTestedClassesAndTraits(), - 'numMethods' => $node->getNumMethods(), - 'numTestedMethods' => $node->getNumTestedMethods(), - 'linesExecutedPercent' => $node->getLineExecutedPercent(FALSE), - 'linesExecutedPercentAsString' => $node->getLineExecutedPercent(), - 'numExecutedLines' => $node->getNumExecutedLines(), - 'numExecutableLines' => $node->getNumExecutableLines(), - 'testedMethodsPercent' => $node->getTestedMethodsPercent(FALSE), - 'testedMethodsPercentAsString' => $node->getTestedMethodsPercent(), - 'testedClassesPercent' => $node->getTestedClassesAndTraitsPercent(FALSE), - 'testedClassesPercentAsString' => $node->getTestedClassesAndTraitsPercent(), - 'crap' => 'CRAP' - ) - ); - - $items .= $this->renderFunctionItems( - $node->getFunctions(), $methodItemTemplate - ); - - $items .= $this->renderTraitOrClassItems( - $node->getTraits(), $template, $methodItemTemplate - ); - - $items .= $this->renderTraitOrClassItems( - $node->getClasses(), $template, $methodItemTemplate - ); - - return $items; - } - - /** - * @param array $items - * @param Text_Template $template - * @return string - */ - protected function renderTraitOrClassItems(array $items, Text_Template $template, Text_Template $methodItemTemplate) - { - if (empty($items)) { - return ''; - } - - $buffer = ''; - - foreach ($items as $name => $item) { - $numMethods = count($item['methods']); - $numTestedMethods = 0; - - foreach ($item['methods'] as $method) { - if ($method['executedLines'] == $method['executableLines']) { - $numTestedMethods++; - } - } - - $buffer .= $this->renderItemTemplate( - $template, - array( - 'name' => $name, - 'numClasses' => 1, - 'numTestedClasses' => $numTestedMethods == $numMethods ? 1 : 0, - 'numMethods' => $numMethods, - 'numTestedMethods' => $numTestedMethods, - 'linesExecutedPercent' => PHP_CodeCoverage_Util::percent( - $item['executedLines'], - $item['executableLines'], - FALSE - ), - 'linesExecutedPercentAsString' => PHP_CodeCoverage_Util::percent( - $item['executedLines'], - $item['executableLines'], - TRUE - ), - 'numExecutedLines' => $item['executedLines'], - 'numExecutableLines' => $item['executableLines'], - 'testedMethodsPercent' => PHP_CodeCoverage_Util::percent( - $numTestedMethods, - $numMethods, - FALSE - ), - 'testedMethodsPercentAsString' => PHP_CodeCoverage_Util::percent( - $numTestedMethods, - $numMethods, - TRUE - ), - 'testedClassesPercent' => PHP_CodeCoverage_Util::percent( - $numTestedMethods == $numMethods ? 1 : 0, - 1, - FALSE - ), - 'testedClassesPercentAsString' => PHP_CodeCoverage_Util::percent( - $numTestedMethods == $numMethods ? 1 : 0, - 1, - TRUE - ), - 'crap' => $item['crap'] - ) - ); - - foreach ($item['methods'] as $method) { - $buffer .= $this->renderFunctionOrMethodItem( - $methodItemTemplate, $method, ' ' - ); - } - } - - return $buffer; - } - - /** - * @param array $functions - * @param Text_Template $template - * @return string - */ - protected function renderFunctionItems(array $functions, Text_Template $template) - { - if (empty($functions)) { - return ''; - } - - $buffer = ''; - - foreach ($functions as $function) { - $buffer .= $this->renderFunctionOrMethodItem( - $template, $function - ); - } - - return $buffer; - } - - /** - * @param Text_Template $template - * @return string - */ - protected function renderFunctionOrMethodItem(Text_Template $template, array $item, $indent = '') - { - $numTestedItems = $item['executedLines'] == $item['executableLines'] ? 1 : 0; - - return $this->renderItemTemplate( - $template, - array( - 'name' => sprintf( - '%s%s', - $indent, - $item['startLine'], - htmlspecialchars($item['signature']) - ), - 'numMethods' => 1, - 'numTestedMethods' => $numTestedItems, - 'linesExecutedPercent' => PHP_CodeCoverage_Util::percent( - $item['executedLines'], - $item['executableLines'], - FALSE - ), - 'linesExecutedPercentAsString' => PHP_CodeCoverage_Util::percent( - $item['executedLines'], - $item['executableLines'], - TRUE - ), - 'numExecutedLines' => $item['executedLines'], - 'numExecutableLines' => $item['executableLines'], - 'testedMethodsPercent' => PHP_CodeCoverage_Util::percent( - $numTestedItems, - 1, - FALSE - ), - 'testedMethodsPercentAsString' => PHP_CodeCoverage_Util::percent( - $numTestedItems, - 1, - TRUE - ), - 'crap' => $item['crap'] - ) - ); - } - - /** - * @param PHP_CodeCoverage_Report_Node_File $node - * @return string - */ - protected function renderSource(PHP_CodeCoverage_Report_Node_File $node) - { - $coverageData = $node->getCoverageData(); - $testData = $node->getTestData(); - $codeLines = $this->loadFile($node->getPath()); - $lines = ''; - $i = 1; - - foreach ($codeLines as $line) { - $numTests = ''; - $trClass = ''; - $popoverContent = ''; - $popoverTitle = ''; - - if (isset($coverageData[$i])) { - $numTests = count($coverageData[$i]); - - if ($coverageData[$i] === NULL) { - $trClass = ' class="warning"'; - } - - else if ($numTests == 0) { - $trClass = ' class="danger"'; - } - - else { - $trClass = ' class="success popin"'; - $popoverContent = '
      '; - - if ($numTests > 1) { - $popoverTitle = $numTests . ' tests cover line ' . $i; - } else { - $popoverTitle = '1 test covers line ' . $i; - } - - foreach ($coverageData[$i] as $test) { - switch ($testData[$test]) { - case 0: { - $testCSS = ' class="success"'; - } - break; - - case 1: - case 2: { - $testCSS = ' class="warning"'; - } - break; - - case 3: { - $testCSS = ' class="danger"'; - } - break; - - case 4: { - $testCSS = ' class="danger"'; - } - break; - - default: { - $testCSS = ''; - } - } - - $popoverContent .= sprintf( - '%s', - - $testCSS, - htmlspecialchars($test) - ); - } - - $popoverContent .= '
    '; - } - } - - if (!empty($popoverTitle)) { - $popover = sprintf( - ' data-title="%s" data-content="%s" data-placement="bottom" data-html="true"', - $popoverTitle, - htmlspecialchars($popoverContent) - ); - } else { - $popover = ''; - } - - $lines .= sprintf( - ' %s' . "\n", - $trClass, - $popover, - $i, - $i, - $i, - !$this->highlight ? htmlspecialchars($line) : $line - ); - - $i++; - } - - return $lines; - } - - /** - * @param string $file - * @return array - */ - protected function loadFile($file) - { - $buffer = file_get_contents($file); - $lines = explode("\n", str_replace("\t", ' ', $buffer)); - $result = array(); - - if (count($lines) == 0) { - return $result; - } - - $lines = array_map('rtrim', $lines); - - if (!$this->highlight) { - unset($lines[count($lines)-1]); - return $lines; - } - - $tokens = token_get_all($buffer); - $stringFlag = FALSE; - $i = 0; - $result[$i] = ''; - - foreach ($tokens as $j => $token) { - if (is_string($token)) { - if ($token === '"' && $tokens[$j - 1] !== '\\') { - $result[$i] .= sprintf( - '%s', - - htmlspecialchars($token) - ); - - $stringFlag = !$stringFlag; - } else { - $result[$i] .= sprintf( - '%s', - - htmlspecialchars($token) - ); - } - - continue; - } - - list ($token, $value) = $token; - - $value = str_replace( - array("\t", ' '), - array('    ', ' '), - htmlspecialchars($value) - ); - - if ($value === "\n") { - $result[++$i] = ''; - } else { - $lines = explode("\n", $value); - - foreach ($lines as $jj => $line) { - $line = trim($line); - - if ($line !== '') { - if ($stringFlag) { - $colour = 'string'; - } else { - switch ($token) { - case T_INLINE_HTML: { - $colour = 'html'; - } - break; - - case T_COMMENT: - case T_DOC_COMMENT: { - $colour = 'comment'; - } - break; - - case T_ABSTRACT: - case T_ARRAY: - case T_AS: - case T_BREAK: - case T_CALLABLE: - case T_CASE: - case T_CATCH: - case T_CLASS: - case T_CLONE: - case T_CONTINUE: - case T_DEFAULT: - case T_ECHO: - case T_ELSE: - case T_ELSEIF: - case T_EMPTY: - case T_ENDDECLARE: - case T_ENDFOR: - case T_ENDFOREACH: - case T_ENDIF: - case T_ENDSWITCH: - case T_ENDWHILE: - case T_EXIT: - case T_EXTENDS: - case T_FINAL: - case T_FOREACH: - case T_FUNCTION: - case T_GLOBAL: - case T_IF: - case T_IMPLEMENTS: - case T_INCLUDE: - case T_INCLUDE_ONCE: - case T_INSTANCEOF: - case T_INSTEADOF: - case T_INTERFACE: - case T_ISSET: - case T_LOGICAL_AND: - case T_LOGICAL_OR: - case T_LOGICAL_XOR: - case T_NAMESPACE: - case T_NEW: - case T_PRIVATE: - case T_PROTECTED: - case T_PUBLIC: - case T_REQUIRE: - case T_REQUIRE_ONCE: - case T_RETURN: - case T_STATIC: - case T_THROW: - case T_TRAIT: - case T_TRY: - case T_UNSET: - case T_USE: - case T_VAR: - case T_WHILE: { - $colour = 'keyword'; - } - break; - - default: { - $colour = 'default'; - } - } - } - - $result[$i] .= sprintf( - '%s', - - $colour, - $line - ); - } - - if (isset($lines[$jj + 1])) { - $result[++$i] = ''; - } - } - } - } - - unset($result[count($result)-1]); - - return $result; - } + /** + * @var boolean + */ + protected $highlight; + + /** + * Constructor. + * + * @param string $templatePath + * @param string $charset + * @param string $generator + * @param string $date + * @param integer $lowUpperBound + * @param integer $highLowerBound + * @param boolean $highlight + */ + public function __construct($templatePath, $charset, $generator, $date, $lowUpperBound, $highLowerBound, $highlight) + { + parent::__construct( + $templatePath, + $charset, + $generator, + $date, + $lowUpperBound, + $highLowerBound + ); + + $this->highlight = $highlight; + } + + /** + * @param PHP_CodeCoverage_Report_Node_File $node + * @param string $file + */ + public function render(PHP_CodeCoverage_Report_Node_File $node, $file) + { + $template = new Text_Template($this->templatePath . 'file.html'); + + $template->setVar( + array( + 'items' => $this->renderItems($node), + 'lines' => $this->renderSource($node) + ) + ); + + $this->setCommonTemplateVariables($template, $node); + + $template->renderTo($file); + } + + /** + * @param PHP_CodeCoverage_Report_Node_File $node + * @return string + */ + protected function renderItems(PHP_CodeCoverage_Report_Node_File $node) + { + $template = new Text_Template($this->templatePath . 'file_item.html'); + + $methodItemTemplate = new Text_Template( + $this->templatePath . 'method_item.html' + ); + + $items = $this->renderItemTemplate( + $template, + array( + 'name' => 'Total', + 'numClasses' => $node->getNumClassesAndTraits(), + 'numTestedClasses' => $node->getNumTestedClassesAndTraits(), + 'numMethods' => $node->getNumMethods(), + 'numTestedMethods' => $node->getNumTestedMethods(), + 'linesExecutedPercent' => $node->getLineExecutedPercent(FALSE), + 'linesExecutedPercentAsString' => $node->getLineExecutedPercent(), + 'numExecutedLines' => $node->getNumExecutedLines(), + 'numExecutableLines' => $node->getNumExecutableLines(), + 'testedMethodsPercent' => $node->getTestedMethodsPercent(FALSE), + 'testedMethodsPercentAsString' => $node->getTestedMethodsPercent(), + 'testedClassesPercent' => $node->getTestedClassesAndTraitsPercent(FALSE), + 'testedClassesPercentAsString' => $node->getTestedClassesAndTraitsPercent(), + 'crap' => 'CRAP' + ) + ); + + $items .= $this->renderFunctionItems( + $node->getFunctions(), $methodItemTemplate + ); + + $items .= $this->renderTraitOrClassItems( + $node->getTraits(), $template, $methodItemTemplate + ); + + $items .= $this->renderTraitOrClassItems( + $node->getClasses(), $template, $methodItemTemplate + ); + + return $items; + } + + /** + * @param array $items + * @param Text_Template $template + * @return string + */ + protected function renderTraitOrClassItems(array $items, Text_Template $template, Text_Template $methodItemTemplate) + { + if (empty($items)) { + return ''; + } + + $buffer = ''; + + foreach ($items as $name => $item) { + $numMethods = count($item['methods']); + $numTestedMethods = 0; + + foreach ($item['methods'] as $method) { + if ($method['executedLines'] == $method['executableLines']) { + $numTestedMethods++; + } + } + + $buffer .= $this->renderItemTemplate( + $template, + array( + 'name' => $name, + 'numClasses' => 1, + 'numTestedClasses' => $numTestedMethods == $numMethods ? 1 : 0, + 'numMethods' => $numMethods, + 'numTestedMethods' => $numTestedMethods, + 'linesExecutedPercent' => PHP_CodeCoverage_Util::percent( + $item['executedLines'], + $item['executableLines'], + FALSE + ), + 'linesExecutedPercentAsString' => PHP_CodeCoverage_Util::percent( + $item['executedLines'], + $item['executableLines'], + TRUE + ), + 'numExecutedLines' => $item['executedLines'], + 'numExecutableLines' => $item['executableLines'], + 'testedMethodsPercent' => PHP_CodeCoverage_Util::percent( + $numTestedMethods, + $numMethods, + FALSE + ), + 'testedMethodsPercentAsString' => PHP_CodeCoverage_Util::percent( + $numTestedMethods, + $numMethods, + TRUE + ), + 'testedClassesPercent' => PHP_CodeCoverage_Util::percent( + $numTestedMethods == $numMethods ? 1 : 0, + 1, + FALSE + ), + 'testedClassesPercentAsString' => PHP_CodeCoverage_Util::percent( + $numTestedMethods == $numMethods ? 1 : 0, + 1, + TRUE + ), + 'crap' => $item['crap'] + ) + ); + + foreach ($item['methods'] as $method) { + $buffer .= $this->renderFunctionOrMethodItem( + $methodItemTemplate, $method, ' ' + ); + } + } + + return $buffer; + } + + /** + * @param array $functions + * @param Text_Template $template + * @return string + */ + protected function renderFunctionItems(array $functions, Text_Template $template) + { + if (empty($functions)) { + return ''; + } + + $buffer = ''; + + foreach ($functions as $function) { + $buffer .= $this->renderFunctionOrMethodItem( + $template, $function + ); + } + + return $buffer; + } + + /** + * @param Text_Template $template + * @return string + */ + protected function renderFunctionOrMethodItem(Text_Template $template, array $item, $indent = '') + { + $numTestedItems = $item['executedLines'] == $item['executableLines'] ? 1 : 0; + + return $this->renderItemTemplate( + $template, + array( + 'name' => sprintf( + '%s%s', + $indent, + $item['startLine'], + htmlspecialchars($item['signature']) + ), + 'numMethods' => 1, + 'numTestedMethods' => $numTestedItems, + 'linesExecutedPercent' => PHP_CodeCoverage_Util::percent( + $item['executedLines'], + $item['executableLines'], + FALSE + ), + 'linesExecutedPercentAsString' => PHP_CodeCoverage_Util::percent( + $item['executedLines'], + $item['executableLines'], + TRUE + ), + 'numExecutedLines' => $item['executedLines'], + 'numExecutableLines' => $item['executableLines'], + 'testedMethodsPercent' => PHP_CodeCoverage_Util::percent( + $numTestedItems, + 1, + FALSE + ), + 'testedMethodsPercentAsString' => PHP_CodeCoverage_Util::percent( + $numTestedItems, + 1, + TRUE + ), + 'crap' => $item['crap'] + ) + ); + } + + /** + * @param PHP_CodeCoverage_Report_Node_File $node + * @return string + */ + protected function renderSource(PHP_CodeCoverage_Report_Node_File $node) + { + $coverageData = $node->getCoverageData(); + $testData = $node->getTestData(); + $codeLines = $this->loadFile($node->getPath()); + $lines = ''; + $i = 1; + + foreach ($codeLines as $line) { + $numTests = ''; + $trClass = ''; + $popoverContent = ''; + $popoverTitle = ''; + + if (isset($coverageData[$i])) { + $numTests = count($coverageData[$i]); + + if ($coverageData[$i] === NULL) { + $trClass = ' class="warning"'; + } + + else if ($numTests == 0) { + $trClass = ' class="danger"'; + } + + else { + $trClass = ' class="success popin"'; + $popoverContent = '
      '; + + if ($numTests > 1) { + $popoverTitle = $numTests . ' tests cover line ' . $i; + } else { + $popoverTitle = '1 test covers line ' . $i; + } + + foreach ($coverageData[$i] as $test) { + switch ($testData[$test]) { + case 0: { + $testCSS = ' class="success"'; + } + break; + + case 1: + case 2: { + $testCSS = ' class="warning"'; + } + break; + + case 3: { + $testCSS = ' class="danger"'; + } + break; + + case 4: { + $testCSS = ' class="danger"'; + } + break; + + default: { + $testCSS = ''; + } + } + + $popoverContent .= sprintf( + '%s', + + $testCSS, + htmlspecialchars($test) + ); + } + + $popoverContent .= '
    '; + } + } + + if (!empty($popoverTitle)) { + $popover = sprintf( + ' data-title="%s" data-content="%s" data-placement="bottom" data-html="true"', + $popoverTitle, + htmlspecialchars($popoverContent) + ); + } else { + $popover = ''; + } + + $lines .= sprintf( + ' %s' . "\n", + $trClass, + $popover, + $i, + $i, + $i, + !$this->highlight ? htmlspecialchars($line) : $line + ); + + $i++; + } + + return $lines; + } + + /** + * @param string $file + * @return array + */ + protected function loadFile($file) + { + $buffer = file_get_contents($file); + $lines = explode("\n", str_replace("\t", ' ', $buffer)); + $result = array(); + + if (count($lines) == 0) { + return $result; + } + + $lines = array_map('rtrim', $lines); + + if (!$this->highlight) { + unset($lines[count($lines)-1]); + return $lines; + } + + $tokens = token_get_all($buffer); + $stringFlag = FALSE; + $i = 0; + $result[$i] = ''; + + foreach ($tokens as $j => $token) { + if (is_string($token)) { + if ($token === '"' && $tokens[$j - 1] !== '\\') { + $result[$i] .= sprintf( + '%s', + + htmlspecialchars($token) + ); + + $stringFlag = !$stringFlag; + } else { + $result[$i] .= sprintf( + '%s', + + htmlspecialchars($token) + ); + } + + continue; + } + + list ($token, $value) = $token; + + $value = str_replace( + array("\t", ' '), + array('    ', ' '), + htmlspecialchars($value) + ); + + if ($value === "\n") { + $result[++$i] = ''; + } else { + $lines = explode("\n", $value); + + foreach ($lines as $jj => $line) { + $line = trim($line); + + if ($line !== '') { + if ($stringFlag) { + $colour = 'string'; + } else { + switch ($token) { + case T_INLINE_HTML: { + $colour = 'html'; + } + break; + + case T_COMMENT: + case T_DOC_COMMENT: { + $colour = 'comment'; + } + break; + + case T_ABSTRACT: + case T_ARRAY: + case T_AS: + case T_BREAK: + case T_CALLABLE: + case T_CASE: + case T_CATCH: + case T_CLASS: + case T_CLONE: + case T_CONTINUE: + case T_DEFAULT: + case T_ECHO: + case T_ELSE: + case T_ELSEIF: + case T_EMPTY: + case T_ENDDECLARE: + case T_ENDFOR: + case T_ENDFOREACH: + case T_ENDIF: + case T_ENDSWITCH: + case T_ENDWHILE: + case T_EXIT: + case T_EXTENDS: + case T_FINAL: + case T_FOREACH: + case T_FUNCTION: + case T_GLOBAL: + case T_IF: + case T_IMPLEMENTS: + case T_INCLUDE: + case T_INCLUDE_ONCE: + case T_INSTANCEOF: + case T_INSTEADOF: + case T_INTERFACE: + case T_ISSET: + case T_LOGICAL_AND: + case T_LOGICAL_OR: + case T_LOGICAL_XOR: + case T_NAMESPACE: + case T_NEW: + case T_PRIVATE: + case T_PROTECTED: + case T_PUBLIC: + case T_REQUIRE: + case T_REQUIRE_ONCE: + case T_RETURN: + case T_STATIC: + case T_THROW: + case T_TRAIT: + case T_TRY: + case T_UNSET: + case T_USE: + case T_VAR: + case T_WHILE: { + $colour = 'keyword'; + } + break; + + default: { + $colour = 'default'; + } + } + } + + $result[$i] .= sprintf( + '%s', + + $colour, + $line + ); + } + + if (isset($lines[$jj + 1])) { + $result[++$i] = ''; + } + } + } + } + + unset($result[count($result)-1]); + + return $result; + } } diff --git a/PHP/CodeCoverage/Report/HTML/Renderer/Template/coverage_bar.html.dist b/PHP/CodeCoverage/Report/HTML/Renderer/Template/coverage_bar.html.dist index 73a11a1a1..d7fc335b3 100644 --- a/PHP/CodeCoverage/Report/HTML/Renderer/Template/coverage_bar.html.dist +++ b/PHP/CodeCoverage/Report/HTML/Renderer/Template/coverage_bar.html.dist @@ -1,3 +1,3 @@ -
    -
    -
    +
    +
    +
    diff --git a/PHP/CodeCoverage/Report/HTML/Renderer/Template/dashboard.html.dist b/PHP/CodeCoverage/Report/HTML/Renderer/Template/dashboard.html.dist index eb58b36f9..bd510c4c3 100644 --- a/PHP/CodeCoverage/Report/HTML/Renderer/Template/dashboard.html.dist +++ b/PHP/CodeCoverage/Report/HTML/Renderer/Template/dashboard.html.dist @@ -1,117 +1,117 @@ - - Dashboard for {full_path} - - - - - + + Dashboard for {full_path} + + + + + -
    -
    -
    -
    -
    +
    +
    +
    +

    Class Coverage Distribution

    +
    +
    +
    +

    Class Complexity

    +
    +
    +
    +
    +
    +

    Top Project Risks

    +
      {top_project_risks} -
    -
    -
    -

    Least Tested Methods

    -
      +
    +
    +
    +

    Least Tested Methods

    +
      {least_tested_methods} -
    -
    -
    - -
    - - - - + + + + var classComplexity = new Highcharts.Chart({ + chart: { + renderTo: 'classComplexity', + type: 'scatter' + }, + title: {text: ''}, + legend: {enabled: false}, + credits: {enabled: false}, + xAxis: { + title: {text: 'Code Coverage (in percent)'}, + labels: {enabled: true}, + }, + yAxis: { + title: 'Cyclomatic Complexity', + labels: {enabled: true}, + }, + tooltip: { + formatter: function() { + return this.point.config[2]; + } + }, + series: [{ + data: {cc_values}, + marker: { + symbol: 'diamond' + } + }], + }); + }); + diff --git a/PHP/CodeCoverage/Report/HTML/Renderer/Template/directory.html.dist b/PHP/CodeCoverage/Report/HTML/Renderer/Template/directory.html.dist index 347440ce7..24c588505 100644 --- a/PHP/CodeCoverage/Report/HTML/Renderer/Template/directory.html.dist +++ b/PHP/CodeCoverage/Report/HTML/Renderer/Template/directory.html.dist @@ -1,58 +1,58 @@ - - Code Coverage for {full_path} - - - - - + + Code Coverage for {full_path} + + + + + -
    -
    -
    -
    -
    + diff --git a/PHP/CodeCoverage/Report/HTML/Renderer/Template/directory_item.html.dist b/PHP/CodeCoverage/Report/HTML/Renderer/Template/directory_item.html.dist index 4a19a06f4..6cd5e211b 100644 --- a/PHP/CodeCoverage/Report/HTML/Renderer/Template/directory_item.html.dist +++ b/PHP/CodeCoverage/Report/HTML/Renderer/Template/directory_item.html.dist @@ -1,13 +1,13 @@ - - {icon}{name} - {lines_bar} -
    {lines_executed_percent}
    -
    {lines_number}
    - {methods_bar} -
    {methods_tested_percent}
    -
    {methods_number}
    - {classes_bar} -
    {classes_tested_percent}
    -
    {classes_number}
    - + + {icon}{name} + {lines_bar} +
    {lines_executed_percent}
    +
    {lines_number}
    + {methods_bar} +
    {methods_tested_percent}
    +
    {methods_number}
    + {classes_bar} +
    {classes_tested_percent}
    +
    {classes_number}
    + diff --git a/PHP/CodeCoverage/Report/HTML/Renderer/Template/file.html.dist b/PHP/CodeCoverage/Report/HTML/Renderer/Template/file.html.dist index 31a513ee2..5e9c006f5 100644 --- a/PHP/CodeCoverage/Report/HTML/Renderer/Template/file.html.dist +++ b/PHP/CodeCoverage/Report/HTML/Renderer/Template/file.html.dist @@ -1,65 +1,65 @@ - - Code Coverage for {full_path} - - - - - + + Code Coverage for {full_path} + + + + + -
    -
    -
    -
    -
    + + + diff --git a/PHP/CodeCoverage/Report/HTML/Renderer/Template/file_item.html.dist b/PHP/CodeCoverage/Report/HTML/Renderer/Template/file_item.html.dist index 7bff4e53e..292bbd1e3 100644 --- a/PHP/CodeCoverage/Report/HTML/Renderer/Template/file_item.html.dist +++ b/PHP/CodeCoverage/Report/HTML/Renderer/Template/file_item.html.dist @@ -1,14 +1,14 @@ - - {name} - {classes_bar} -
    {classes_tested_percent}
    -
    {classes_number}
    - {methods_bar} -
    {methods_tested_percent}
    -
    {methods_number}
    - {crap} - {lines_bar} -
    {lines_executed_percent}
    -
    {lines_number}
    - + + {name} + {classes_bar} +
    {classes_tested_percent}
    +
    {classes_number}
    + {methods_bar} +
    {methods_tested_percent}
    +
    {methods_number}
    + {crap} + {lines_bar} +
    {lines_executed_percent}
    +
    {lines_number}
    + diff --git a/PHP/CodeCoverage/Report/HTML/Renderer/Template/img/glyphicons-halflings.png b/PHP/CodeCoverage/Report/HTML/Renderer/Template/img/glyphicons-halflings.png index a99699932..e301b506a 100644 Binary files a/PHP/CodeCoverage/Report/HTML/Renderer/Template/img/glyphicons-halflings.png and b/PHP/CodeCoverage/Report/HTML/Renderer/Template/img/glyphicons-halflings.png differ diff --git a/PHP/CodeCoverage/Report/HTML/Renderer/Template/js/jquery.min.js b/PHP/CodeCoverage/Report/HTML/Renderer/Template/js/jquery.min.js index 83589daa7..245e70619 100644 --- a/PHP/CodeCoverage/Report/HTML/Renderer/Template/js/jquery.min.js +++ b/PHP/CodeCoverage/Report/HTML/Renderer/Template/js/jquery.min.js @@ -1,2 +1,2 @@ /*! jQuery v1.8.3 jquery.com | jquery.org/license */ -(function(e,t){function _(e){var t=M[e]={};return v.each(e.split(y),function(e,n){t[n]=!0}),t}function H(e,n,r){if(r===t&&e.nodeType===1){var i="data-"+n.replace(P,"-$1").toLowerCase();r=e.getAttribute(i);if(typeof r=="string"){try{r=r==="true"?!0:r==="false"?!1:r==="null"?null:+r+""===r?+r:D.test(r)?v.parseJSON(r):r}catch(s){}v.data(e,n,r)}else r=t}return r}function B(e){var t;for(t in e){if(t==="data"&&v.isEmptyObject(e[t]))continue;if(t!=="toJSON")return!1}return!0}function et(){return!1}function tt(){return!0}function ut(e){return!e||!e.parentNode||e.parentNode.nodeType===11}function at(e,t){do e=e[t];while(e&&e.nodeType!==1);return e}function ft(e,t,n){t=t||0;if(v.isFunction(t))return v.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return v.grep(e,function(e,r){return e===t===n});if(typeof t=="string"){var r=v.grep(e,function(e){return e.nodeType===1});if(it.test(t))return v.filter(t,r,!n);t=v.filter(t,r)}return v.grep(e,function(e,r){return v.inArray(e,t)>=0===n})}function lt(e){var t=ct.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}function Lt(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function At(e,t){if(t.nodeType!==1||!v.hasData(e))return;var n,r,i,s=v._data(e),o=v._data(t,s),u=s.events;if(u){delete o.handle,o.events={};for(n in u)for(r=0,i=u[n].length;r").appendTo(i.body),n=t.css("display");t.remove();if(n==="none"||n===""){Pt=i.body.appendChild(Pt||v.extend(i.createElement("iframe"),{frameBorder:0,width:0,height:0}));if(!Ht||!Pt.createElement)Ht=(Pt.contentWindow||Pt.contentDocument).document,Ht.write(""),Ht.close();t=Ht.body.appendChild(Ht.createElement(e)),n=Dt(t,"display"),i.body.removeChild(Pt)}return Wt[e]=n,n}function fn(e,t,n,r){var i;if(v.isArray(t))v.each(t,function(t,i){n||sn.test(e)?r(e,i):fn(e+"["+(typeof i=="object"?t:"")+"]",i,n,r)});else if(!n&&v.type(t)==="object")for(i in t)fn(e+"["+i+"]",t[i],n,r);else r(e,t)}function Cn(e){return function(t,n){typeof t!="string"&&(n=t,t="*");var r,i,s,o=t.toLowerCase().split(y),u=0,a=o.length;if(v.isFunction(n))for(;u)[^>]*$|#([\w\-]*)$)/,E=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,S=/^[\],:{}\s]*$/,x=/(?:^|:|,)(?:\s*\[)+/g,T=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,N=/"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,C=/^-ms-/,k=/-([\da-z])/gi,L=function(e,t){return(t+"").toUpperCase()},A=function(){i.addEventListener?(i.removeEventListener("DOMContentLoaded",A,!1),v.ready()):i.readyState==="complete"&&(i.detachEvent("onreadystatechange",A),v.ready())},O={};v.fn=v.prototype={constructor:v,init:function(e,n,r){var s,o,u,a;if(!e)return this;if(e.nodeType)return this.context=this[0]=e,this.length=1,this;if(typeof e=="string"){e.charAt(0)==="<"&&e.charAt(e.length-1)===">"&&e.length>=3?s=[null,e,null]:s=w.exec(e);if(s&&(s[1]||!n)){if(s[1])return n=n instanceof v?n[0]:n,a=n&&n.nodeType?n.ownerDocument||n:i,e=v.parseHTML(s[1],a,!0),E.test(s[1])&&v.isPlainObject(n)&&this.attr.call(e,n,!0),v.merge(this,e);o=i.getElementById(s[2]);if(o&&o.parentNode){if(o.id!==s[2])return r.find(e);this.length=1,this[0]=o}return this.context=i,this.selector=e,this}return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e)}return v.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),v.makeArray(e,this))},selector:"",jquery:"1.8.3",length:0,size:function(){return this.length},toArray:function(){return l.call(this)},get:function(e){return e==null?this.toArray():e<0?this[this.length+e]:this[e]},pushStack:function(e,t,n){var r=v.merge(this.constructor(),e);return r.prevObject=this,r.context=this.context,t==="find"?r.selector=this.selector+(this.selector?" ":"")+n:t&&(r.selector=this.selector+"."+t+"("+n+")"),r},each:function(e,t){return v.each(this,e,t)},ready:function(e){return v.ready.promise().done(e),this},eq:function(e){return e=+e,e===-1?this.slice(e):this.slice(e,e+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(l.apply(this,arguments),"slice",l.call(arguments).join(","))},map:function(e){return this.pushStack(v.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:[].sort,splice:[].splice},v.fn.init.prototype=v.fn,v.extend=v.fn.extend=function(){var e,n,r,i,s,o,u=arguments[0]||{},a=1,f=arguments.length,l=!1;typeof u=="boolean"&&(l=u,u=arguments[1]||{},a=2),typeof u!="object"&&!v.isFunction(u)&&(u={}),f===a&&(u=this,--a);for(;a0)return;r.resolveWith(i,[v]),v.fn.trigger&&v(i).trigger("ready").off("ready")},isFunction:function(e){return v.type(e)==="function"},isArray:Array.isArray||function(e){return v.type(e)==="array"},isWindow:function(e){return e!=null&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return e==null?String(e):O[h.call(e)]||"object"},isPlainObject:function(e){if(!e||v.type(e)!=="object"||e.nodeType||v.isWindow(e))return!1;try{if(e.constructor&&!p.call(e,"constructor")&&!p.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}var r;for(r in e);return r===t||p.call(e,r)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw new Error(e)},parseHTML:function(e,t,n){var r;return!e||typeof e!="string"?null:(typeof t=="boolean"&&(n=t,t=0),t=t||i,(r=E.exec(e))?[t.createElement(r[1])]:(r=v.buildFragment([e],t,n?null:[]),v.merge([],(r.cacheable?v.clone(r.fragment):r.fragment).childNodes)))},parseJSON:function(t){if(!t||typeof t!="string")return null;t=v.trim(t);if(e.JSON&&e.JSON.parse)return e.JSON.parse(t);if(S.test(t.replace(T,"@").replace(N,"]").replace(x,"")))return(new Function("return "+t))();v.error("Invalid JSON: "+t)},parseXML:function(n){var r,i;if(!n||typeof n!="string")return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(s){r=t}return(!r||!r.documentElement||r.getElementsByTagName("parsererror").length)&&v.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&g.test(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(C,"ms-").replace(k,L)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,n,r){var i,s=0,o=e.length,u=o===t||v.isFunction(e);if(r){if(u){for(i in e)if(n.apply(e[i],r)===!1)break}else for(;s0&&e[0]&&e[a-1]||a===0||v.isArray(e));if(f)for(;u-1)a.splice(n,1),i&&(n<=o&&o--,n<=u&&u--)}),this},has:function(e){return v.inArray(e,a)>-1},empty:function(){return a=[],this},disable:function(){return a=f=n=t,this},disabled:function(){return!a},lock:function(){return f=t,n||c.disable(),this},locked:function(){return!f},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],a&&(!r||f)&&(i?f.push(t):l(t)),this},fire:function(){return c.fireWith(this,arguments),this},fired:function(){return!!r}};return c},v.extend({Deferred:function(e){var t=[["resolve","done",v.Callbacks("once memory"),"resolved"],["reject","fail",v.Callbacks("once memory"),"rejected"],["notify","progress",v.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return v.Deferred(function(n){v.each(t,function(t,r){var s=r[0],o=e[t];i[r[1]](v.isFunction(o)?function(){var e=o.apply(this,arguments);e&&v.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[s+"With"](this===i?n:this,[e])}:n[s])}),e=null}).promise()},promise:function(e){return e!=null?v.extend(e,r):r}},i={};return r.pipe=r.then,v.each(t,function(e,s){var o=s[2],u=s[3];r[s[1]]=o.add,u&&o.add(function(){n=u},t[e^1][2].disable,t[2][2].lock),i[s[0]]=o.fire,i[s[0]+"With"]=o.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=l.call(arguments),r=n.length,i=r!==1||e&&v.isFunction(e.promise)?r:0,s=i===1?e:v.Deferred(),o=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?l.call(arguments):r,n===u?s.notifyWith(t,n):--i||s.resolveWith(t,n)}},u,a,f;if(r>1){u=new Array(r),a=new Array(r),f=new Array(r);for(;t
    a",n=p.getElementsByTagName("*"),r=p.getElementsByTagName("a")[0];if(!n||!r||!n.length)return{};s=i.createElement("select"),o=s.appendChild(i.createElement("option")),u=p.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t={leadingWhitespace:p.firstChild.nodeType===3,tbody:!p.getElementsByTagName("tbody").length,htmlSerialize:!!p.getElementsByTagName("link").length,style:/top/.test(r.getAttribute("style")),hrefNormalized:r.getAttribute("href")==="/a",opacity:/^0.5/.test(r.style.opacity),cssFloat:!!r.style.cssFloat,checkOn:u.value==="on",optSelected:o.selected,getSetAttribute:p.className!=="t",enctype:!!i.createElement("form").enctype,html5Clone:i.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",boxModel:i.compatMode==="CSS1Compat",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},u.checked=!0,t.noCloneChecked=u.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!o.disabled;try{delete p.test}catch(d){t.deleteExpando=!1}!p.addEventListener&&p.attachEvent&&p.fireEvent&&(p.attachEvent("onclick",h=function(){t.noCloneEvent=!1}),p.cloneNode(!0).fireEvent("onclick"),p.detachEvent("onclick",h)),u=i.createElement("input"),u.value="t",u.setAttribute("type","radio"),t.radioValue=u.value==="t",u.setAttribute("checked","checked"),u.setAttribute("name","t"),p.appendChild(u),a=i.createDocumentFragment(),a.appendChild(p.lastChild),t.checkClone=a.cloneNode(!0).cloneNode(!0).lastChild.checked,t.appendChecked=u.checked,a.removeChild(u),a.appendChild(p);if(p.attachEvent)for(l in{submit:!0,change:!0,focusin:!0})f="on"+l,c=f in p,c||(p.setAttribute(f,"return;"),c=typeof p[f]=="function"),t[l+"Bubbles"]=c;return v(function(){var n,r,s,o,u="padding:0;margin:0;border:0;display:block;overflow:hidden;",a=i.getElementsByTagName("body")[0];if(!a)return;n=i.createElement("div"),n.style.cssText="visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px",a.insertBefore(n,a.firstChild),r=i.createElement("div"),n.appendChild(r),r.innerHTML="
    t
    ",s=r.getElementsByTagName("td"),s[0].style.cssText="padding:0;margin:0;border:0;display:none",c=s[0].offsetHeight===0,s[0].style.display="",s[1].style.display="none",t.reliableHiddenOffsets=c&&s[0].offsetHeight===0,r.innerHTML="",r.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",t.boxSizing=r.offsetWidth===4,t.doesNotIncludeMarginInBodyOffset=a.offsetTop!==1,e.getComputedStyle&&(t.pixelPosition=(e.getComputedStyle(r,null)||{}).top!=="1%",t.boxSizingReliable=(e.getComputedStyle(r,null)||{width:"4px"}).width==="4px",o=i.createElement("div"),o.style.cssText=r.style.cssText=u,o.style.marginRight=o.style.width="0",r.style.width="1px",r.appendChild(o),t.reliableMarginRight=!parseFloat((e.getComputedStyle(o,null)||{}).marginRight)),typeof r.style.zoom!="undefined"&&(r.innerHTML="",r.style.cssText=u+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=r.offsetWidth===3,r.style.display="block",r.style.overflow="visible",r.innerHTML="
    ",r.firstChild.style.width="5px",t.shrinkWrapBlocks=r.offsetWidth!==3,n.style.zoom=1),a.removeChild(n),n=r=s=o=null}),a.removeChild(p),n=r=s=o=u=a=p=null,t}();var D=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,P=/([A-Z])/g;v.extend({cache:{},deletedIds:[],uuid:0,expando:"jQuery"+(v.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(e){return e=e.nodeType?v.cache[e[v.expando]]:e[v.expando],!!e&&!B(e)},data:function(e,n,r,i){if(!v.acceptData(e))return;var s,o,u=v.expando,a=typeof n=="string",f=e.nodeType,l=f?v.cache:e,c=f?e[u]:e[u]&&u;if((!c||!l[c]||!i&&!l[c].data)&&a&&r===t)return;c||(f?e[u]=c=v.deletedIds.pop()||v.guid++:c=u),l[c]||(l[c]={},f||(l[c].toJSON=v.noop));if(typeof n=="object"||typeof n=="function")i?l[c]=v.extend(l[c],n):l[c].data=v.extend(l[c].data,n);return s=l[c],i||(s.data||(s.data={}),s=s.data),r!==t&&(s[v.camelCase(n)]=r),a?(o=s[n],o==null&&(o=s[v.camelCase(n)])):o=s,o},removeData:function(e,t,n){if(!v.acceptData(e))return;var r,i,s,o=e.nodeType,u=o?v.cache:e,a=o?e[v.expando]:v.expando;if(!u[a])return;if(t){r=n?u[a]:u[a].data;if(r){v.isArray(t)||(t in r?t=[t]:(t=v.camelCase(t),t in r?t=[t]:t=t.split(" ")));for(i=0,s=t.length;i1,null,!1))},removeData:function(e){return this.each(function(){v.removeData(this,e)})}}),v.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=v._data(e,t),n&&(!r||v.isArray(n)?r=v._data(e,t,v.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=v.queue(e,t),r=n.length,i=n.shift(),s=v._queueHooks(e,t),o=function(){v.dequeue(e,t)};i==="inprogress"&&(i=n.shift(),r--),i&&(t==="fx"&&n.unshift("inprogress"),delete s.stop,i.call(e,o,s)),!r&&s&&s.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return v._data(e,n)||v._data(e,n,{empty:v.Callbacks("once memory").add(function(){v.removeData(e,t+"queue",!0),v.removeData(e,n,!0)})})}}),v.fn.extend({queue:function(e,n){var r=2;return typeof e!="string"&&(n=e,e="fx",r--),arguments.length1)},removeAttr:function(e){return this.each(function(){v.removeAttr(this,e)})},prop:function(e,t){return v.access(this,v.prop,e,t,arguments.length>1)},removeProp:function(e){return e=v.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,s,o,u;if(v.isFunction(e))return this.each(function(t){v(this).addClass(e.call(this,t,this.className))});if(e&&typeof e=="string"){t=e.split(y);for(n=0,r=this.length;n=0)r=r.replace(" "+n[s]+" "," ");i.className=e?v.trim(r):""}}}return this},toggleClass:function(e,t){var n=typeof e,r=typeof t=="boolean";return v.isFunction(e)?this.each(function(n){v(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if(n==="string"){var i,s=0,o=v(this),u=t,a=e.split(y);while(i=a[s++])u=r?u:!o.hasClass(i),o[u?"addClass":"removeClass"](i)}else if(n==="undefined"||n==="boolean")this.className&&v._data(this,"__className__",this.className),this.className=this.className||e===!1?"":v._data(this,"__className__")||""})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;n=0)return!0;return!1},val:function(e){var n,r,i,s=this[0];if(!arguments.length){if(s)return n=v.valHooks[s.type]||v.valHooks[s.nodeName.toLowerCase()],n&&"get"in n&&(r=n.get(s,"value"))!==t?r:(r=s.value,typeof r=="string"?r.replace(R,""):r==null?"":r);return}return i=v.isFunction(e),this.each(function(r){var s,o=v(this);if(this.nodeType!==1)return;i?s=e.call(this,r,o.val()):s=e,s==null?s="":typeof s=="number"?s+="":v.isArray(s)&&(s=v.map(s,function(e){return e==null?"":e+""})),n=v.valHooks[this.type]||v.valHooks[this.nodeName.toLowerCase()];if(!n||!("set"in n)||n.set(this,s,"value")===t)this.value=s})}}),v.extend({valHooks:{option:{get:function(e){var t=e.attributes.value;return!t||t.specified?e.value:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,s=e.type==="select-one"||i<0,o=s?null:[],u=s?i+1:r.length,a=i<0?u:s?i:0;for(;a=0}),n.length||(e.selectedIndex=-1),n}}},attrFn:{},attr:function(e,n,r,i){var s,o,u,a=e.nodeType;if(!e||a===3||a===8||a===2)return;if(i&&v.isFunction(v.fn[n]))return v(e)[n](r);if(typeof e.getAttribute=="undefined")return v.prop(e,n,r);u=a!==1||!v.isXMLDoc(e),u&&(n=n.toLowerCase(),o=v.attrHooks[n]||(X.test(n)?F:j));if(r!==t){if(r===null){v.removeAttr(e,n);return}return o&&"set"in o&&u&&(s=o.set(e,r,n))!==t?s:(e.setAttribute(n,r+""),r)}return o&&"get"in o&&u&&(s=o.get(e,n))!==null?s:(s=e.getAttribute(n),s===null?t:s)},removeAttr:function(e,t){var n,r,i,s,o=0;if(t&&e.nodeType===1){r=t.split(y);for(;o=0}})});var $=/^(?:textarea|input|select)$/i,J=/^([^\.]*|)(?:\.(.+)|)$/,K=/(?:^|\s)hover(\.\S+|)\b/,Q=/^key/,G=/^(?:mouse|contextmenu)|click/,Y=/^(?:focusinfocus|focusoutblur)$/,Z=function(e){return v.event.special.hover?e:e.replace(K,"mouseenter$1 mouseleave$1")};v.event={add:function(e,n,r,i,s){var o,u,a,f,l,c,h,p,d,m,g;if(e.nodeType===3||e.nodeType===8||!n||!r||!(o=v._data(e)))return;r.handler&&(d=r,r=d.handler,s=d.selector),r.guid||(r.guid=v.guid++),a=o.events,a||(o.events=a={}),u=o.handle,u||(o.handle=u=function(e){return typeof v=="undefined"||!!e&&v.event.triggered===e.type?t:v.event.dispatch.apply(u.elem,arguments)},u.elem=e),n=v.trim(Z(n)).split(" ");for(f=0;f=0&&(y=y.slice(0,-1),a=!0),y.indexOf(".")>=0&&(b=y.split("."),y=b.shift(),b.sort());if((!s||v.event.customEvent[y])&&!v.event.global[y])return;n=typeof n=="object"?n[v.expando]?n:new v.Event(y,n):new v.Event(y),n.type=y,n.isTrigger=!0,n.exclusive=a,n.namespace=b.join("."),n.namespace_re=n.namespace?new RegExp("(^|\\.)"+b.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,h=y.indexOf(":")<0?"on"+y:"";if(!s){u=v.cache;for(f in u)u[f].events&&u[f].events[y]&&v.event.trigger(n,r,u[f].handle.elem,!0);return}n.result=t,n.target||(n.target=s),r=r!=null?v.makeArray(r):[],r.unshift(n),p=v.event.special[y]||{};if(p.trigger&&p.trigger.apply(s,r)===!1)return;m=[[s,p.bindType||y]];if(!o&&!p.noBubble&&!v.isWindow(s)){g=p.delegateType||y,l=Y.test(g+y)?s:s.parentNode;for(c=s;l;l=l.parentNode)m.push([l,g]),c=l;c===(s.ownerDocument||i)&&m.push([c.defaultView||c.parentWindow||e,g])}for(f=0;f=0:v.find(h,this,null,[s]).length),u[h]&&f.push(c);f.length&&w.push({elem:s,matches:f})}d.length>m&&w.push({elem:this,matches:d.slice(m)});for(r=0;r0?this.on(t,null,e,n):this.trigger(t)},Q.test(t)&&(v.event.fixHooks[t]=v.event.keyHooks),G.test(t)&&(v.event.fixHooks[t]=v.event.mouseHooks)}),function(e,t){function nt(e,t,n,r){n=n||[],t=t||g;var i,s,a,f,l=t.nodeType;if(!e||typeof e!="string")return n;if(l!==1&&l!==9)return[];a=o(t);if(!a&&!r)if(i=R.exec(e))if(f=i[1]){if(l===9){s=t.getElementById(f);if(!s||!s.parentNode)return n;if(s.id===f)return n.push(s),n}else if(t.ownerDocument&&(s=t.ownerDocument.getElementById(f))&&u(t,s)&&s.id===f)return n.push(s),n}else{if(i[2])return S.apply(n,x.call(t.getElementsByTagName(e),0)),n;if((f=i[3])&&Z&&t.getElementsByClassName)return S.apply(n,x.call(t.getElementsByClassName(f),0)),n}return vt(e.replace(j,"$1"),t,n,r,a)}function rt(e){return function(t){var n=t.nodeName.toLowerCase();return n==="input"&&t.type===e}}function it(e){return function(t){var n=t.nodeName.toLowerCase();return(n==="input"||n==="button")&&t.type===e}}function st(e){return N(function(t){return t=+t,N(function(n,r){var i,s=e([],n.length,t),o=s.length;while(o--)n[i=s[o]]&&(n[i]=!(r[i]=n[i]))})})}function ot(e,t,n){if(e===t)return n;var r=e.nextSibling;while(r){if(r===t)return-1;r=r.nextSibling}return 1}function ut(e,t){var n,r,s,o,u,a,f,l=L[d][e+" "];if(l)return t?0:l.slice(0);u=e,a=[],f=i.preFilter;while(u){if(!n||(r=F.exec(u)))r&&(u=u.slice(r[0].length)||u),a.push(s=[]);n=!1;if(r=I.exec(u))s.push(n=new m(r.shift())),u=u.slice(n.length),n.type=r[0].replace(j," ");for(o in i.filter)(r=J[o].exec(u))&&(!f[o]||(r=f[o](r)))&&(s.push(n=new m(r.shift())),u=u.slice(n.length),n.type=o,n.matches=r);if(!n)break}return t?u.length:u?nt.error(e):L(e,a).slice(0)}function at(e,t,r){var i=t.dir,s=r&&t.dir==="parentNode",o=w++;return t.first?function(t,n,r){while(t=t[i])if(s||t.nodeType===1)return e(t,n,r)}:function(t,r,u){if(!u){var a,f=b+" "+o+" ",l=f+n;while(t=t[i])if(s||t.nodeType===1){if((a=t[d])===l)return t.sizset;if(typeof a=="string"&&a.indexOf(f)===0){if(t.sizset)return t}else{t[d]=l;if(e(t,r,u))return t.sizset=!0,t;t.sizset=!1}}}else while(t=t[i])if(s||t.nodeType===1)if(e(t,r,u))return t}}function ft(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function lt(e,t,n,r,i){var s,o=[],u=0,a=e.length,f=t!=null;for(;u-1&&(s[f]=!(o[f]=c))}}else g=lt(g===o?g.splice(d,g.length):g),i?i(null,o,g,a):S.apply(o,g)})}function ht(e){var t,n,r,s=e.length,o=i.relative[e[0].type],u=o||i.relative[" "],a=o?1:0,f=at(function(e){return e===t},u,!0),l=at(function(e){return T.call(t,e)>-1},u,!0),h=[function(e,n,r){return!o&&(r||n!==c)||((t=n).nodeType?f(e,n,r):l(e,n,r))}];for(;a1&&ft(h),a>1&&e.slice(0,a-1).join("").replace(j,"$1"),n,a0,s=e.length>0,o=function(u,a,f,l,h){var p,d,v,m=[],y=0,w="0",x=u&&[],T=h!=null,N=c,C=u||s&&i.find.TAG("*",h&&a.parentNode||a),k=b+=N==null?1:Math.E;T&&(c=a!==g&&a,n=o.el);for(;(p=C[w])!=null;w++){if(s&&p){for(d=0;v=e[d];d++)if(v(p,a,f)){l.push(p);break}T&&(b=k,n=++o.el)}r&&((p=!v&&p)&&y--,u&&x.push(p))}y+=w;if(r&&w!==y){for(d=0;v=t[d];d++)v(x,m,a,f);if(u){if(y>0)while(w--)!x[w]&&!m[w]&&(m[w]=E.call(l));m=lt(m)}S.apply(l,m),T&&!u&&m.length>0&&y+t.length>1&&nt.uniqueSort(l)}return T&&(b=k,c=N),x};return o.el=0,r?N(o):o}function dt(e,t,n){var r=0,i=t.length;for(;r2&&(f=u[0]).type==="ID"&&t.nodeType===9&&!s&&i.relative[u[1].type]){t=i.find.ID(f.matches[0].replace($,""),t,s)[0];if(!t)return n;e=e.slice(u.shift().length)}for(o=J.POS.test(e)?-1:u.length-1;o>=0;o--){f=u[o];if(i.relative[l=f.type])break;if(c=i.find[l])if(r=c(f.matches[0].replace($,""),z.test(u[0].type)&&t.parentNode||t,s)){u.splice(o,1),e=r.length&&u.join("");if(!e)return S.apply(n,x.call(r,0)),n;break}}}return a(e,h)(r,t,s,n,z.test(e)),n}function mt(){}var n,r,i,s,o,u,a,f,l,c,h=!0,p="undefined",d=("sizcache"+Math.random()).replace(".",""),m=String,g=e.document,y=g.documentElement,b=0,w=0,E=[].pop,S=[].push,x=[].slice,T=[].indexOf||function(e){var t=0,n=this.length;for(;ti.cacheLength&&delete e[t.shift()],e[n+" "]=r},e)},k=C(),L=C(),A=C(),O="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",_=M.replace("w","w#"),D="([*^$|!~]?=)",P="\\["+O+"*("+M+")"+O+"*(?:"+D+O+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+_+")|)|)"+O+"*\\]",H=":("+M+")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:"+P+")|[^:]|\\\\.)*|.*))\\)|)",B=":(even|odd|eq|gt|lt|nth|first|last)(?:\\("+O+"*((?:-\\d)?\\d*)"+O+"*\\)|)(?=[^-]|$)",j=new RegExp("^"+O+"+|((?:^|[^\\\\])(?:\\\\.)*)"+O+"+$","g"),F=new RegExp("^"+O+"*,"+O+"*"),I=new RegExp("^"+O+"*([\\x20\\t\\r\\n\\f>+~])"+O+"*"),q=new RegExp(H),R=/^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,U=/^:not/,z=/[\x20\t\r\n\f]*[+~]/,W=/:not\($/,X=/h\d/i,V=/input|select|textarea|button/i,$=/\\(?!\\)/g,J={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),NAME:new RegExp("^\\[name=['\"]?("+M+")['\"]?\\]"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+H),POS:new RegExp(B,"i"),CHILD:new RegExp("^:(only|nth|first|last)-child(?:\\("+O+"*(even|odd|(([+-]|)(\\d*)n|)"+O+"*(?:([+-]|)"+O+"*(\\d+)|))"+O+"*\\)|)","i"),needsContext:new RegExp("^"+O+"*[>+~]|"+B,"i")},K=function(e){var t=g.createElement("div");try{return e(t)}catch(n){return!1}finally{t=null}},Q=K(function(e){return e.appendChild(g.createComment("")),!e.getElementsByTagName("*").length}),G=K(function(e){return e.innerHTML="",e.firstChild&&typeof e.firstChild.getAttribute!==p&&e.firstChild.getAttribute("href")==="#"}),Y=K(function(e){e.innerHTML="";var t=typeof e.lastChild.getAttribute("multiple");return t!=="boolean"&&t!=="string"}),Z=K(function(e){return e.innerHTML="",!e.getElementsByClassName||!e.getElementsByClassName("e").length?!1:(e.lastChild.className="e",e.getElementsByClassName("e").length===2)}),et=K(function(e){e.id=d+0,e.innerHTML="
    ",y.insertBefore(e,y.firstChild);var t=g.getElementsByName&&g.getElementsByName(d).length===2+g.getElementsByName(d+0).length;return r=!g.getElementById(d),y.removeChild(e),t});try{x.call(y.childNodes,0)[0].nodeType}catch(tt){x=function(e){var t,n=[];for(;t=this[e];e++)n.push(t);return n}}nt.matches=function(e,t){return nt(e,null,null,t)},nt.matchesSelector=function(e,t){return nt(t,null,null,[e]).length>0},s=nt.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(i===1||i===9||i===11){if(typeof e.textContent=="string")return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=s(e)}else if(i===3||i===4)return e.nodeValue}else for(;t=e[r];r++)n+=s(t);return n},o=nt.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?t.nodeName!=="HTML":!1},u=nt.contains=y.contains?function(e,t){var n=e.nodeType===9?e.documentElement:e,r=t&&t.parentNode;return e===r||!!(r&&r.nodeType===1&&n.contains&&n.contains(r))}:y.compareDocumentPosition?function(e,t){return t&&!!(e.compareDocumentPosition(t)&16)}:function(e,t){while(t=t.parentNode)if(t===e)return!0;return!1},nt.attr=function(e,t){var n,r=o(e);return r||(t=t.toLowerCase()),(n=i.attrHandle[t])?n(e):r||Y?e.getAttribute(t):(n=e.getAttributeNode(t),n?typeof e[t]=="boolean"?e[t]?t:null:n.specified?n.value:null:null)},i=nt.selectors={cacheLength:50,createPseudo:N,match:J,attrHandle:G?{}:{href:function(e){return e.getAttribute("href",2)},type:function(e){return e.getAttribute("type")}},find:{ID:r?function(e,t,n){if(typeof t.getElementById!==p&&!n){var r=t.getElementById(e);return r&&r.parentNode?[r]:[]}}:function(e,n,r){if(typeof n.getElementById!==p&&!r){var i=n.getElementById(e);return i?i.id===e||typeof i.getAttributeNode!==p&&i.getAttributeNode("id").value===e?[i]:t:[]}},TAG:Q?function(e,t){if(typeof t.getElementsByTagName!==p)return t.getElementsByTagName(e)}:function(e,t){var n=t.getElementsByTagName(e);if(e==="*"){var r,i=[],s=0;for(;r=n[s];s++)r.nodeType===1&&i.push(r);return i}return n},NAME:et&&function(e,t){if(typeof t.getElementsByName!==p)return t.getElementsByName(name)},CLASS:Z&&function(e,t,n){if(typeof t.getElementsByClassName!==p&&!n)return t.getElementsByClassName(e)}},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace($,""),e[3]=(e[4]||e[5]||"").replace($,""),e[2]==="~="&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),e[1]==="nth"?(e[2]||nt.error(e[0]),e[3]=+(e[3]?e[4]+(e[5]||1):2*(e[2]==="even"||e[2]==="odd")),e[4]=+(e[6]+e[7]||e[2]==="odd")):e[2]&&nt.error(e[0]),e},PSEUDO:function(e){var t,n;if(J.CHILD.test(e[0]))return null;if(e[3])e[2]=e[3];else if(t=e[4])q.test(t)&&(n=ut(t,!0))&&(n=t.indexOf(")",t.length-n)-t.length)&&(t=t.slice(0,n),e[0]=e[0].slice(0,n)),e[2]=t;return e.slice(0,3)}},filter:{ID:r?function(e){return e=e.replace($,""),function(t){return t.getAttribute("id")===e}}:function(e){return e=e.replace($,""),function(t){var n=typeof t.getAttributeNode!==p&&t.getAttributeNode("id");return n&&n.value===e}},TAG:function(e){return e==="*"?function(){return!0}:(e=e.replace($,"").toLowerCase(),function(t){return t.nodeName&&t.nodeName.toLowerCase()===e})},CLASS:function(e){var t=k[d][e+" "];return t||(t=new RegExp("(^|"+O+")"+e+"("+O+"|$)"))&&k(e,function(e){return t.test(e.className||typeof e.getAttribute!==p&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r,i){var s=nt.attr(r,e);return s==null?t==="!=":t?(s+="",t==="="?s===n:t==="!="?s!==n:t==="^="?n&&s.indexOf(n)===0:t==="*="?n&&s.indexOf(n)>-1:t==="$="?n&&s.substr(s.length-n.length)===n:t==="~="?(" "+s+" ").indexOf(n)>-1:t==="|="?s===n||s.substr(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r){return e==="nth"?function(e){var t,i,s=e.parentNode;if(n===1&&r===0)return!0;if(s){i=0;for(t=s.firstChild;t;t=t.nextSibling)if(t.nodeType===1){i++;if(e===t)break}}return i-=r,i===n||i%n===0&&i/n>=0}:function(t){var n=t;switch(e){case"only":case"first":while(n=n.previousSibling)if(n.nodeType===1)return!1;if(e==="first")return!0;n=t;case"last":while(n=n.nextSibling)if(n.nodeType===1)return!1;return!0}}},PSEUDO:function(e,t){var n,r=i.pseudos[e]||i.setFilters[e.toLowerCase()]||nt.error("unsupported pseudo: "+e);return r[d]?r(t):r.length>1?(n=[e,e,"",t],i.setFilters.hasOwnProperty(e.toLowerCase())?N(function(e,n){var i,s=r(e,t),o=s.length;while(o--)i=T.call(e,s[o]),e[i]=!(n[i]=s[o])}):function(e){return r(e,0,n)}):r}},pseudos:{not:N(function(e){var t=[],n=[],r=a(e.replace(j,"$1"));return r[d]?N(function(e,t,n,i){var s,o=r(e,null,i,[]),u=e.length;while(u--)if(s=o[u])e[u]=!(t[u]=s)}):function(e,i,s){return t[0]=e,r(t,null,s,n),!n.pop()}}),has:N(function(e){return function(t){return nt(e,t).length>0}}),contains:N(function(e){return function(t){return(t.textContent||t.innerText||s(t)).indexOf(e)>-1}}),enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return t==="input"&&!!e.checked||t==="option"&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},parent:function(e){return!i.pseudos.empty(e)},empty:function(e){var t;e=e.firstChild;while(e){if(e.nodeName>"@"||(t=e.nodeType)===3||t===4)return!1;e=e.nextSibling}return!0},header:function(e){return X.test(e.nodeName)},text:function(e){var t,n;return e.nodeName.toLowerCase()==="input"&&(t=e.type)==="text"&&((n=e.getAttribute("type"))==null||n.toLowerCase()===t)},radio:rt("radio"),checkbox:rt("checkbox"),file:rt("file"),password:rt("password"),image:rt("image"),submit:it("submit"),reset:it("reset"),button:function(e){var t=e.nodeName.toLowerCase();return t==="input"&&e.type==="button"||t==="button"},input:function(e){return V.test(e.nodeName)},focus:function(e){var t=e.ownerDocument;return e===t.activeElement&&(!t.hasFocus||t.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},active:function(e){return e===e.ownerDocument.activeElement},first:st(function(){return[0]}),last:st(function(e,t){return[t-1]}),eq:st(function(e,t,n){return[n<0?n+t:n]}),even:st(function(e,t){for(var n=0;n=0;)e.push(r);return e}),gt:st(function(e,t,n){for(var r=n<0?n+t:n;++r",e.querySelectorAll("[selected]").length||i.push("\\["+O+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),e.querySelectorAll(":checked").length||i.push(":checked")}),K(function(e){e.innerHTML="

    ",e.querySelectorAll("[test^='']").length&&i.push("[*^$]="+O+"*(?:\"\"|'')"),e.innerHTML="",e.querySelectorAll(":enabled").length||i.push(":enabled",":disabled")}),i=new RegExp(i.join("|")),vt=function(e,r,s,o,u){if(!o&&!u&&!i.test(e)){var a,f,l=!0,c=d,h=r,p=r.nodeType===9&&e;if(r.nodeType===1&&r.nodeName.toLowerCase()!=="object"){a=ut(e),(l=r.getAttribute("id"))?c=l.replace(n,"\\$&"):r.setAttribute("id",c),c="[id='"+c+"'] ",f=a.length;while(f--)a[f]=c+a[f].join("");h=z.test(e)&&r.parentNode||r,p=a.join(",")}if(p)try{return S.apply(s,x.call(h.querySelectorAll(p),0)),s}catch(v){}finally{l||r.removeAttribute("id")}}return t(e,r,s,o,u)},u&&(K(function(t){e=u.call(t,"div");try{u.call(t,"[test!='']:sizzle"),s.push("!=",H)}catch(n){}}),s=new RegExp(s.join("|")),nt.matchesSelector=function(t,n){n=n.replace(r,"='$1']");if(!o(t)&&!s.test(n)&&!i.test(n))try{var a=u.call(t,n);if(a||e||t.document&&t.document.nodeType!==11)return a}catch(f){}return nt(n,null,null,[t]).length>0})}(),i.pseudos.nth=i.pseudos.eq,i.filters=mt.prototype=i.pseudos,i.setFilters=new mt,nt.attr=v.attr,v.find=nt,v.expr=nt.selectors,v.expr[":"]=v.expr.pseudos,v.unique=nt.uniqueSort,v.text=nt.getText,v.isXMLDoc=nt.isXML,v.contains=nt.contains}(e);var nt=/Until$/,rt=/^(?:parents|prev(?:Until|All))/,it=/^.[^:#\[\.,]*$/,st=v.expr.match.needsContext,ot={children:!0,contents:!0,next:!0,prev:!0};v.fn.extend({find:function(e){var t,n,r,i,s,o,u=this;if(typeof e!="string")return v(e).filter(function(){for(t=0,n=u.length;t0)for(i=r;i=0:v.filter(e,this).length>0:this.filter(e).length>0)},closest:function(e,t){var n,r=0,i=this.length,s=[],o=st.test(e)||typeof e!="string"?v(e,t||this.context):0;for(;r-1:v.find.matchesSelector(n,e)){s.push(n);break}n=n.parentNode}}return s=s.length>1?v.unique(s):s,this.pushStack(s,"closest",e)},index:function(e){return e?typeof e=="string"?v.inArray(this[0],v(e)):v.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.prevAll().length:-1},add:function(e,t){var n=typeof e=="string"?v(e,t):v.makeArray(e&&e.nodeType?[e]:e),r=v.merge(this.get(),n);return this.pushStack(ut(n[0])||ut(r[0])?r:v.unique(r))},addBack:function(e){return this.add(e==null?this.prevObject:this.prevObject.filter(e))}}),v.fn.andSelf=v.fn.addBack,v.each({parent:function(e){var t=e.parentNode;return t&&t.nodeType!==11?t:null},parents:function(e){return v.dir(e,"parentNode")},parentsUntil:function(e,t,n){return v.dir(e,"parentNode",n)},next:function(e){return at(e,"nextSibling")},prev:function(e){return at(e,"previousSibling")},nextAll:function(e){return v.dir(e,"nextSibling")},prevAll:function(e){return v.dir(e,"previousSibling")},nextUntil:function(e,t,n){return v.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return v.dir(e,"previousSibling",n)},siblings:function(e){return v.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return v.sibling(e.firstChild)},contents:function(e){return v.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:v.merge([],e.childNodes)}},function(e,t){v.fn[e]=function(n,r){var i=v.map(this,t,n);return nt.test(e)||(r=n),r&&typeof r=="string"&&(i=v.filter(r,i)),i=this.length>1&&!ot[e]?v.unique(i):i,this.length>1&&rt.test(e)&&(i=i.reverse()),this.pushStack(i,e,l.call(arguments).join(","))}}),v.extend({filter:function(e,t,n){return n&&(e=":not("+e+")"),t.length===1?v.find.matchesSelector(t[0],e)?[t[0]]:[]:v.find.matches(e,t)},dir:function(e,n,r){var i=[],s=e[n];while(s&&s.nodeType!==9&&(r===t||s.nodeType!==1||!v(s).is(r)))s.nodeType===1&&i.push(s),s=s[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)e.nodeType===1&&e!==t&&n.push(e);return n}});var ct="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",ht=/ jQuery\d+="(?:null|\d+)"/g,pt=/^\s+/,dt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,vt=/<([\w:]+)/,mt=/]","i"),Et=/^(?:checkbox|radio)$/,St=/checked\s*(?:[^=]|=\s*.checked.)/i,xt=/\/(java|ecma)script/i,Tt=/^\s*\s*$/g,Nt={option:[1,""],legend:[1,"
    ","
    "],thead:[1,"","
    "],tr:[2,"","
    "],td:[3,"","
    "],col:[2,"","
    "],area:[1,"",""],_default:[0,"",""]},Ct=lt(i),kt=Ct.appendChild(i.createElement("div"));Nt.optgroup=Nt.option,Nt.tbody=Nt.tfoot=Nt.colgroup=Nt.caption=Nt.thead,Nt.th=Nt.td,v.support.htmlSerialize||(Nt._default=[1,"X
    ","
    "]),v.fn.extend({text:function(e){return v.access(this,function(e){return e===t?v.text(this):this.empty().append((this[0]&&this[0].ownerDocument||i).createTextNode(e))},null,e,arguments.length)},wrapAll:function(e){if(v.isFunction(e))return this.each(function(t){v(this).wrapAll(e.call(this,t))});if(this[0]){var t=v(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&e.firstChild.nodeType===1)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return v.isFunction(e)?this.each(function(t){v(this).wrapInner(e.call(this,t))}):this.each(function(){var t=v(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=v.isFunction(e);return this.each(function(n){v(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){v.nodeName(this,"body")||v(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(e){(this.nodeType===1||this.nodeType===11)&&this.appendChild(e)})},prepend:function(){return this.domManip(arguments,!0,function(e){(this.nodeType===1||this.nodeType===11)&&this.insertBefore(e,this.firstChild)})},before:function(){if(!ut(this[0]))return this.domManip(arguments,!1,function(e){this.parentNode.insertBefore(e,this)});if(arguments.length){var e=v.clean(arguments);return this.pushStack(v.merge(e,this),"before",this.selector)}},after:function(){if(!ut(this[0]))return this.domManip(arguments,!1,function(e){this.parentNode.insertBefore(e,this.nextSibling)});if(arguments.length){var e=v.clean(arguments);return this.pushStack(v.merge(this,e),"after",this.selector)}},remove:function(e,t){var n,r=0;for(;(n=this[r])!=null;r++)if(!e||v.filter(e,[n]).length)!t&&n.nodeType===1&&(v.cleanData(n.getElementsByTagName("*")),v.cleanData([n])),n.parentNode&&n.parentNode.removeChild(n);return this},empty:function(){var e,t=0;for(;(e=this[t])!=null;t++){e.nodeType===1&&v.cleanData(e.getElementsByTagName("*"));while(e.firstChild)e.removeChild(e.firstChild)}return this},clone:function(e,t){return e=e==null?!1:e,t=t==null?e:t,this.map(function(){return v.clone(this,e,t)})},html:function(e){return v.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return n.nodeType===1?n.innerHTML.replace(ht,""):t;if(typeof e=="string"&&!yt.test(e)&&(v.support.htmlSerialize||!wt.test(e))&&(v.support.leadingWhitespace||!pt.test(e))&&!Nt[(vt.exec(e)||["",""])[1].toLowerCase()]){e=e.replace(dt,"<$1>");try{for(;r1&&typeof f=="string"&&St.test(f))return this.each(function(){v(this).domManip(e,n,r)});if(v.isFunction(f))return this.each(function(i){var s=v(this);e[0]=f.call(this,i,n?s.html():t),s.domManip(e,n,r)});if(this[0]){i=v.buildFragment(e,this,l),o=i.fragment,s=o.firstChild,o.childNodes.length===1&&(o=s);if(s){n=n&&v.nodeName(s,"tr");for(u=i.cacheable||c-1;a0?this.clone(!0):this).get(),v(o[i])[t](r),s=s.concat(r);return this.pushStack(s,e,o.selector)}}),v.extend({clone:function(e,t,n){var r,i,s,o;v.support.html5Clone||v.isXMLDoc(e)||!wt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(kt.innerHTML=e.outerHTML,kt.removeChild(o=kt.firstChild));if((!v.support.noCloneEvent||!v.support.noCloneChecked)&&(e.nodeType===1||e.nodeType===11)&&!v.isXMLDoc(e)){Ot(e,o),r=Mt(e),i=Mt(o);for(s=0;r[s];++s)i[s]&&Ot(r[s],i[s])}if(t){At(e,o);if(n){r=Mt(e),i=Mt(o);for(s=0;r[s];++s)At(r[s],i[s])}}return r=i=null,o},clean:function(e,t,n,r){var s,o,u,a,f,l,c,h,p,d,m,g,y=t===i&&Ct,b=[];if(!t||typeof t.createDocumentFragment=="undefined")t=i;for(s=0;(u=e[s])!=null;s++){typeof u=="number"&&(u+="");if(!u)continue;if(typeof u=="string")if(!gt.test(u))u=t.createTextNode(u);else{y=y||lt(t),c=t.createElement("div"),y.appendChild(c),u=u.replace(dt,"<$1>"),a=(vt.exec(u)||["",""])[1].toLowerCase(),f=Nt[a]||Nt._default,l=f[0],c.innerHTML=f[1]+u+f[2];while(l--)c=c.lastChild;if(!v.support.tbody){h=mt.test(u),p=a==="table"&&!h?c.firstChild&&c.firstChild.childNodes:f[1]===""&&!h?c.childNodes:[];for(o=p.length-1;o>=0;--o)v.nodeName(p[o],"tbody")&&!p[o].childNodes.length&&p[o].parentNode.removeChild(p[o])}!v.support.leadingWhitespace&&pt.test(u)&&c.insertBefore(t.createTextNode(pt.exec(u)[0]),c.firstChild),u=c.childNodes,c.parentNode.removeChild(c)}u.nodeType?b.push(u):v.merge(b,u)}c&&(u=c=y=null);if(!v.support.appendChecked)for(s=0;(u=b[s])!=null;s++)v.nodeName(u,"input")?_t(u):typeof u.getElementsByTagName!="undefined"&&v.grep(u.getElementsByTagName("input"),_t);if(n){m=function(e){if(!e.type||xt.test(e.type))return r?r.push(e.parentNode?e.parentNode.removeChild(e):e):n.appendChild(e)};for(s=0;(u=b[s])!=null;s++)if(!v.nodeName(u,"script")||!m(u))n.appendChild(u),typeof u.getElementsByTagName!="undefined"&&(g=v.grep(v.merge([],u.getElementsByTagName("script")),m),b.splice.apply(b,[s+1,0].concat(g)),s+=g.length)}return b},cleanData:function(e,t){var n,r,i,s,o=0,u=v.expando,a=v.cache,f=v.support.deleteExpando,l=v.event.special;for(;(i=e[o])!=null;o++)if(t||v.acceptData(i)){r=i[u],n=r&&a[r];if(n){if(n.events)for(s in n.events)l[s]?v.event.remove(i,s):v.removeEvent(i,s,n.handle);a[r]&&(delete a[r],f?delete i[u]:i.removeAttribute?i.removeAttribute(u):i[u]=null,v.deletedIds.push(r))}}}}),function(){var e,t;v.uaMatch=function(e){e=e.toLowerCase();var t=/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return{browser:t[1]||"",version:t[2]||"0"}},e=v.uaMatch(o.userAgent),t={},e.browser&&(t[e.browser]=!0,t.version=e.version),t.chrome?t.webkit=!0:t.webkit&&(t.safari=!0),v.browser=t,v.sub=function(){function e(t,n){return new e.fn.init(t,n)}v.extend(!0,e,this),e.superclass=this,e.fn=e.prototype=this(),e.fn.constructor=e,e.sub=this.sub,e.fn.init=function(r,i){return i&&i instanceof v&&!(i instanceof e)&&(i=e(i)),v.fn.init.call(this,r,i,t)},e.fn.init.prototype=e.fn;var t=e(i);return e}}();var Dt,Pt,Ht,Bt=/alpha\([^)]*\)/i,jt=/opacity=([^)]*)/,Ft=/^(top|right|bottom|left)$/,It=/^(none|table(?!-c[ea]).+)/,qt=/^margin/,Rt=new RegExp("^("+m+")(.*)$","i"),Ut=new RegExp("^("+m+")(?!px)[a-z%]+$","i"),zt=new RegExp("^([-+])=("+m+")","i"),Wt={BODY:"block"},Xt={position:"absolute",visibility:"hidden",display:"block"},Vt={letterSpacing:0,fontWeight:400},$t=["Top","Right","Bottom","Left"],Jt=["Webkit","O","Moz","ms"],Kt=v.fn.toggle;v.fn.extend({css:function(e,n){return v.access(this,function(e,n,r){return r!==t?v.style(e,n,r):v.css(e,n)},e,n,arguments.length>1)},show:function(){return Yt(this,!0)},hide:function(){return Yt(this)},toggle:function(e,t){var n=typeof e=="boolean";return v.isFunction(e)&&v.isFunction(t)?Kt.apply(this,arguments):this.each(function(){(n?e:Gt(this))?v(this).show():v(this).hide()})}}),v.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Dt(e,"opacity");return n===""?"1":n}}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":v.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(!e||e.nodeType===3||e.nodeType===8||!e.style)return;var s,o,u,a=v.camelCase(n),f=e.style;n=v.cssProps[a]||(v.cssProps[a]=Qt(f,a)),u=v.cssHooks[n]||v.cssHooks[a];if(r===t)return u&&"get"in u&&(s=u.get(e,!1,i))!==t?s:f[n];o=typeof r,o==="string"&&(s=zt.exec(r))&&(r=(s[1]+1)*s[2]+parseFloat(v.css(e,n)),o="number");if(r==null||o==="number"&&isNaN(r))return;o==="number"&&!v.cssNumber[a]&&(r+="px");if(!u||!("set"in u)||(r=u.set(e,r,i))!==t)try{f[n]=r}catch(l){}},css:function(e,n,r,i){var s,o,u,a=v.camelCase(n);return n=v.cssProps[a]||(v.cssProps[a]=Qt(e.style,a)),u=v.cssHooks[n]||v.cssHooks[a],u&&"get"in u&&(s=u.get(e,!0,i)),s===t&&(s=Dt(e,n)),s==="normal"&&n in Vt&&(s=Vt[n]),r||i!==t?(o=parseFloat(s),r||v.isNumeric(o)?o||0:s):s},swap:function(e,t,n){var r,i,s={};for(i in t)s[i]=e.style[i],e.style[i]=t[i];r=n.call(e);for(i in t)e.style[i]=s[i];return r}}),e.getComputedStyle?Dt=function(t,n){var r,i,s,o,u=e.getComputedStyle(t,null),a=t.style;return u&&(r=u.getPropertyValue(n)||u[n],r===""&&!v.contains(t.ownerDocument,t)&&(r=v.style(t,n)),Ut.test(r)&&qt.test(n)&&(i=a.width,s=a.minWidth,o=a.maxWidth,a.minWidth=a.maxWidth=a.width=r,r=u.width,a.width=i,a.minWidth=s,a.maxWidth=o)),r}:i.documentElement.currentStyle&&(Dt=function(e,t){var n,r,i=e.currentStyle&&e.currentStyle[t],s=e.style;return i==null&&s&&s[t]&&(i=s[t]),Ut.test(i)&&!Ft.test(t)&&(n=s.left,r=e.runtimeStyle&&e.runtimeStyle.left,r&&(e.runtimeStyle.left=e.currentStyle.left),s.left=t==="fontSize"?"1em":i,i=s.pixelLeft+"px",s.left=n,r&&(e.runtimeStyle.left=r)),i===""?"auto":i}),v.each(["height","width"],function(e,t){v.cssHooks[t]={get:function(e,n,r){if(n)return e.offsetWidth===0&&It.test(Dt(e,"display"))?v.swap(e,Xt,function(){return tn(e,t,r)}):tn(e,t,r)},set:function(e,n,r){return Zt(e,n,r?en(e,t,r,v.support.boxSizing&&v.css(e,"boxSizing")==="border-box"):0)}}}),v.support.opacity||(v.cssHooks.opacity={get:function(e,t){return jt.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var n=e.style,r=e.currentStyle,i=v.isNumeric(t)?"alpha(opacity="+t*100+")":"",s=r&&r.filter||n.filter||"";n.zoom=1;if(t>=1&&v.trim(s.replace(Bt,""))===""&&n.removeAttribute){n.removeAttribute("filter");if(r&&!r.filter)return}n.filter=Bt.test(s)?s.replace(Bt,i):s+" "+i}}),v(function(){v.support.reliableMarginRight||(v.cssHooks.marginRight={get:function(e,t){return v.swap(e,{display:"inline-block"},function(){if(t)return Dt(e,"marginRight")})}}),!v.support.pixelPosition&&v.fn.position&&v.each(["top","left"],function(e,t){v.cssHooks[t]={get:function(e,n){if(n){var r=Dt(e,t);return Ut.test(r)?v(e).position()[t]+"px":r}}}})}),v.expr&&v.expr.filters&&(v.expr.filters.hidden=function(e){return e.offsetWidth===0&&e.offsetHeight===0||!v.support.reliableHiddenOffsets&&(e.style&&e.style.display||Dt(e,"display"))==="none"},v.expr.filters.visible=function(e){return!v.expr.filters.hidden(e)}),v.each({margin:"",padding:"",border:"Width"},function(e,t){v.cssHooks[e+t]={expand:function(n){var r,i=typeof n=="string"?n.split(" "):[n],s={};for(r=0;r<4;r++)s[e+$t[r]+t]=i[r]||i[r-2]||i[0];return s}},qt.test(e)||(v.cssHooks[e+t].set=Zt)});var rn=/%20/g,sn=/\[\]$/,on=/\r?\n/g,un=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,an=/^(?:select|textarea)/i;v.fn.extend({serialize:function(){return v.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?v.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||an.test(this.nodeName)||un.test(this.type))}).map(function(e,t){var n=v(this).val();return n==null?null:v.isArray(n)?v.map(n,function(e,n){return{name:t.name,value:e.replace(on,"\r\n")}}):{name:t.name,value:n.replace(on,"\r\n")}}).get()}}),v.param=function(e,n){var r,i=[],s=function(e,t){t=v.isFunction(t)?t():t==null?"":t,i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};n===t&&(n=v.ajaxSettings&&v.ajaxSettings.traditional);if(v.isArray(e)||e.jquery&&!v.isPlainObject(e))v.each(e,function(){s(this.name,this.value)});else for(r in e)fn(r,e[r],n,s);return i.join("&").replace(rn,"+")};var ln,cn,hn=/#.*$/,pn=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,dn=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,vn=/^(?:GET|HEAD)$/,mn=/^\/\//,gn=/\?/,yn=/)<[^<]*)*<\/script>/gi,bn=/([?&])_=[^&]*/,wn=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,En=v.fn.load,Sn={},xn={},Tn=["*/"]+["*"];try{cn=s.href}catch(Nn){cn=i.createElement("a"),cn.href="",cn=cn.href}ln=wn.exec(cn.toLowerCase())||[],v.fn.load=function(e,n,r){if(typeof e!="string"&&En)return En.apply(this,arguments);if(!this.length)return this;var i,s,o,u=this,a=e.indexOf(" ");return a>=0&&(i=e.slice(a,e.length),e=e.slice(0,a)),v.isFunction(n)?(r=n,n=t):n&&typeof n=="object"&&(s="POST"),v.ajax({url:e,type:s,dataType:"html",data:n,complete:function(e,t){r&&u.each(r,o||[e.responseText,t,e])}}).done(function(e){o=arguments,u.html(i?v("
    ").append(e.replace(yn,"")).find(i):e)}),this},v.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(e,t){v.fn[t]=function(e){return this.on(t,e)}}),v.each(["get","post"],function(e,n){v[n]=function(e,r,i,s){return v.isFunction(r)&&(s=s||i,i=r,r=t),v.ajax({type:n,url:e,data:r,success:i,dataType:s})}}),v.extend({getScript:function(e,n){return v.get(e,t,n,"script")},getJSON:function(e,t,n){return v.get(e,t,n,"json")},ajaxSetup:function(e,t){return t?Ln(e,v.ajaxSettings):(t=e,e=v.ajaxSettings),Ln(e,t),e},ajaxSettings:{url:cn,isLocal:dn.test(ln[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":Tn},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":e.String,"text html":!0,"text json":v.parseJSON,"text xml":v.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:Cn(Sn),ajaxTransport:Cn(xn),ajax:function(e,n){function T(e,n,s,a){var l,y,b,w,S,T=n;if(E===2)return;E=2,u&&clearTimeout(u),o=t,i=a||"",x.readyState=e>0?4:0,s&&(w=An(c,x,s));if(e>=200&&e<300||e===304)c.ifModified&&(S=x.getResponseHeader("Last-Modified"),S&&(v.lastModified[r]=S),S=x.getResponseHeader("Etag"),S&&(v.etag[r]=S)),e===304?(T="notmodified",l=!0):(l=On(c,w),T=l.state,y=l.data,b=l.error,l=!b);else{b=T;if(!T||e)T="error",e<0&&(e=0)}x.status=e,x.statusText=(n||T)+"",l?d.resolveWith(h,[y,T,x]):d.rejectWith(h,[x,T,b]),x.statusCode(g),g=t,f&&p.trigger("ajax"+(l?"Success":"Error"),[x,c,l?y:b]),m.fireWith(h,[x,T]),f&&(p.trigger("ajaxComplete",[x,c]),--v.active||v.event.trigger("ajaxStop"))}typeof e=="object"&&(n=e,e=t),n=n||{};var r,i,s,o,u,a,f,l,c=v.ajaxSetup({},n),h=c.context||c,p=h!==c&&(h.nodeType||h instanceof v)?v(h):v.event,d=v.Deferred(),m=v.Callbacks("once memory"),g=c.statusCode||{},b={},w={},E=0,S="canceled",x={readyState:0,setRequestHeader:function(e,t){if(!E){var n=e.toLowerCase();e=w[n]=w[n]||e,b[e]=t}return this},getAllResponseHeaders:function(){return E===2?i:null},getResponseHeader:function(e){var n;if(E===2){if(!s){s={};while(n=pn.exec(i))s[n[1].toLowerCase()]=n[2]}n=s[e.toLowerCase()]}return n===t?null:n},overrideMimeType:function(e){return E||(c.mimeType=e),this},abort:function(e){return e=e||S,o&&o.abort(e),T(0,e),this}};d.promise(x),x.success=x.done,x.error=x.fail,x.complete=m.add,x.statusCode=function(e){if(e){var t;if(E<2)for(t in e)g[t]=[g[t],e[t]];else t=e[x.status],x.always(t)}return this},c.url=((e||c.url)+"").replace(hn,"").replace(mn,ln[1]+"//"),c.dataTypes=v.trim(c.dataType||"*").toLowerCase().split(y),c.crossDomain==null&&(a=wn.exec(c.url.toLowerCase()),c.crossDomain=!(!a||a[1]===ln[1]&&a[2]===ln[2]&&(a[3]||(a[1]==="http:"?80:443))==(ln[3]||(ln[1]==="http:"?80:443)))),c.data&&c.processData&&typeof c.data!="string"&&(c.data=v.param(c.data,c.traditional)),kn(Sn,c,n,x);if(E===2)return x;f=c.global,c.type=c.type.toUpperCase(),c.hasContent=!vn.test(c.type),f&&v.active++===0&&v.event.trigger("ajaxStart");if(!c.hasContent){c.data&&(c.url+=(gn.test(c.url)?"&":"?")+c.data,delete c.data),r=c.url;if(c.cache===!1){var N=v.now(),C=c.url.replace(bn,"$1_="+N);c.url=C+(C===c.url?(gn.test(c.url)?"&":"?")+"_="+N:"")}}(c.data&&c.hasContent&&c.contentType!==!1||n.contentType)&&x.setRequestHeader("Content-Type",c.contentType),c.ifModified&&(r=r||c.url,v.lastModified[r]&&x.setRequestHeader("If-Modified-Since",v.lastModified[r]),v.etag[r]&&x.setRequestHeader("If-None-Match",v.etag[r])),x.setRequestHeader("Accept",c.dataTypes[0]&&c.accepts[c.dataTypes[0]]?c.accepts[c.dataTypes[0]]+(c.dataTypes[0]!=="*"?", "+Tn+"; q=0.01":""):c.accepts["*"]);for(l in c.headers)x.setRequestHeader(l,c.headers[l]);if(!c.beforeSend||c.beforeSend.call(h,x,c)!==!1&&E!==2){S="abort";for(l in{success:1,error:1,complete:1})x[l](c[l]);o=kn(xn,c,n,x);if(!o)T(-1,"No Transport");else{x.readyState=1,f&&p.trigger("ajaxSend",[x,c]),c.async&&c.timeout>0&&(u=setTimeout(function(){x.abort("timeout")},c.timeout));try{E=1,o.send(b,T)}catch(k){if(!(E<2))throw k;T(-1,k)}}return x}return x.abort()},active:0,lastModified:{},etag:{}});var Mn=[],_n=/\?/,Dn=/(=)\?(?=&|$)|\?\?/,Pn=v.now();v.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Mn.pop()||v.expando+"_"+Pn++;return this[e]=!0,e}}),v.ajaxPrefilter("json jsonp",function(n,r,i){var s,o,u,a=n.data,f=n.url,l=n.jsonp!==!1,c=l&&Dn.test(f),h=l&&!c&&typeof a=="string"&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Dn.test(a);if(n.dataTypes[0]==="jsonp"||c||h)return s=n.jsonpCallback=v.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,o=e[s],c?n.url=f.replace(Dn,"$1"+s):h?n.data=a.replace(Dn,"$1"+s):l&&(n.url+=(_n.test(f)?"&":"?")+n.jsonp+"="+s),n.converters["script json"]=function(){return u||v.error(s+" was not called"),u[0]},n.dataTypes[0]="json",e[s]=function(){u=arguments},i.always(function(){e[s]=o,n[s]&&(n.jsonpCallback=r.jsonpCallback,Mn.push(s)),u&&v.isFunction(o)&&o(u[0]),u=o=t}),"script"}),v.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(e){return v.globalEval(e),e}}}),v.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),v.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=i.head||i.getElementsByTagName("head")[0]||i.documentElement;return{send:function(s,o){n=i.createElement("script"),n.async="async",e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,i){if(i||!n.readyState||/loaded|complete/.test(n.readyState))n.onload=n.onreadystatechange=null,r&&n.parentNode&&r.removeChild(n),n=t,i||o(200,"success")},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(0,1)}}}});var Hn,Bn=e.ActiveXObject?function(){for(var e in Hn)Hn[e](0,1)}:!1,jn=0;v.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&Fn()||In()}:Fn,function(e){v.extend(v.support,{ajax:!!e,cors:!!e&&"withCredentials"in e})}(v.ajaxSettings.xhr()),v.support.ajax&&v.ajaxTransport(function(n){if(!n.crossDomain||v.support.cors){var r;return{send:function(i,s){var o,u,a=n.xhr();n.username?a.open(n.type,n.url,n.async,n.username,n.password):a.open(n.type,n.url,n.async);if(n.xhrFields)for(u in n.xhrFields)a[u]=n.xhrFields[u];n.mimeType&&a.overrideMimeType&&a.overrideMimeType(n.mimeType),!n.crossDomain&&!i["X-Requested-With"]&&(i["X-Requested-With"]="XMLHttpRequest");try{for(u in i)a.setRequestHeader(u,i[u])}catch(f){}a.send(n.hasContent&&n.data||null),r=function(e,i){var u,f,l,c,h;try{if(r&&(i||a.readyState===4)){r=t,o&&(a.onreadystatechange=v.noop,Bn&&delete Hn[o]);if(i)a.readyState!==4&&a.abort();else{u=a.status,l=a.getAllResponseHeaders(),c={},h=a.responseXML,h&&h.documentElement&&(c.xml=h);try{c.text=a.responseText}catch(p){}try{f=a.statusText}catch(p){f=""}!u&&n.isLocal&&!n.crossDomain?u=c.text?200:404:u===1223&&(u=204)}}}catch(d){i||s(-1,d)}c&&s(u,f,c,l)},n.async?a.readyState===4?setTimeout(r,0):(o=++jn,Bn&&(Hn||(Hn={},v(e).unload(Bn)),Hn[o]=r),a.onreadystatechange=r):r()},abort:function(){r&&r(0,1)}}}});var qn,Rn,Un=/^(?:toggle|show|hide)$/,zn=new RegExp("^(?:([-+])=|)("+m+")([a-z%]*)$","i"),Wn=/queueHooks$/,Xn=[Gn],Vn={"*":[function(e,t){var n,r,i=this.createTween(e,t),s=zn.exec(t),o=i.cur(),u=+o||0,a=1,f=20;if(s){n=+s[2],r=s[3]||(v.cssNumber[e]?"":"px");if(r!=="px"&&u){u=v.css(i.elem,e,!0)||n||1;do a=a||".5",u/=a,v.style(i.elem,e,u+r);while(a!==(a=i.cur()/o)&&a!==1&&--f)}i.unit=r,i.start=u,i.end=s[1]?u+(s[1]+1)*n:n}return i}]};v.Animation=v.extend(Kn,{tweener:function(e,t){v.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;r-1,f={},l={},c,h;a?(l=i.position(),c=l.top,h=l.left):(c=parseFloat(o)||0,h=parseFloat(u)||0),v.isFunction(t)&&(t=t.call(e,n,s)),t.top!=null&&(f.top=t.top-s.top+c),t.left!=null&&(f.left=t.left-s.left+h),"using"in t?t.using.call(e,f):i.css(f)}},v.fn.extend({position:function(){if(!this[0])return;var e=this[0],t=this.offsetParent(),n=this.offset(),r=er.test(t[0].nodeName)?{top:0,left:0}:t.offset();return n.top-=parseFloat(v.css(e,"marginTop"))||0,n.left-=parseFloat(v.css(e,"marginLeft"))||0,r.top+=parseFloat(v.css(t[0],"borderTopWidth"))||0,r.left+=parseFloat(v.css(t[0],"borderLeftWidth"))||0,{top:n.top-r.top,left:n.left-r.left}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||i.body;while(e&&!er.test(e.nodeName)&&v.css(e,"position")==="static")e=e.offsetParent;return e||i.body})}}),v.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);v.fn[e]=function(i){return v.access(this,function(e,i,s){var o=tr(e);if(s===t)return o?n in o?o[n]:o.document.documentElement[i]:e[i];o?o.scrollTo(r?v(o).scrollLeft():s,r?s:v(o).scrollTop()):e[i]=s},e,i,arguments.length,null)}}),v.each({Height:"height",Width:"width"},function(e,n){v.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){v.fn[i]=function(i,s){var o=arguments.length&&(r||typeof i!="boolean"),u=r||(i===!0||s===!0?"margin":"border");return v.access(this,function(n,r,i){var s;return v.isWindow(n)?n.document.documentElement["client"+e]:n.nodeType===9?(s=n.documentElement,Math.max(n.body["scroll"+e],s["scroll"+e],n.body["offset"+e],s["offset"+e],s["client"+e])):i===t?v.css(n,r,i,u):v.style(n,r,i,u)},n,o?i:t,o,null)}})}),e.jQuery=e.$=v,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return v})})(window); \ No newline at end of file +(function(e,t){function _(e){var t=M[e]={};return v.each(e.split(y),function(e,n){t[n]=!0}),t}function H(e,n,r){if(r===t&&e.nodeType===1){var i="data-"+n.replace(P,"-$1").toLowerCase();r=e.getAttribute(i);if(typeof r=="string"){try{r=r==="true"?!0:r==="false"?!1:r==="null"?null:+r+""===r?+r:D.test(r)?v.parseJSON(r):r}catch(s){}v.data(e,n,r)}else r=t}return r}function B(e){var t;for(t in e){if(t==="data"&&v.isEmptyObject(e[t]))continue;if(t!=="toJSON")return!1}return!0}function et(){return!1}function tt(){return!0}function ut(e){return!e||!e.parentNode||e.parentNode.nodeType===11}function at(e,t){do e=e[t];while(e&&e.nodeType!==1);return e}function ft(e,t,n){t=t||0;if(v.isFunction(t))return v.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return v.grep(e,function(e,r){return e===t===n});if(typeof t=="string"){var r=v.grep(e,function(e){return e.nodeType===1});if(it.test(t))return v.filter(t,r,!n);t=v.filter(t,r)}return v.grep(e,function(e,r){return v.inArray(e,t)>=0===n})}function lt(e){var t=ct.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}function Lt(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function At(e,t){if(t.nodeType!==1||!v.hasData(e))return;var n,r,i,s=v._data(e),o=v._data(t,s),u=s.events;if(u){delete o.handle,o.events={};for(n in u)for(r=0,i=u[n].length;r").appendTo(i.body),n=t.css("display");t.remove();if(n==="none"||n===""){Pt=i.body.appendChild(Pt||v.extend(i.createElement("iframe"),{frameBorder:0,width:0,height:0}));if(!Ht||!Pt.createElement)Ht=(Pt.contentWindow||Pt.contentDocument).document,Ht.write(""),Ht.close();t=Ht.body.appendChild(Ht.createElement(e)),n=Dt(t,"display"),i.body.removeChild(Pt)}return Wt[e]=n,n}function fn(e,t,n,r){var i;if(v.isArray(t))v.each(t,function(t,i){n||sn.test(e)?r(e,i):fn(e+"["+(typeof i=="object"?t:"")+"]",i,n,r)});else if(!n&&v.type(t)==="object")for(i in t)fn(e+"["+i+"]",t[i],n,r);else r(e,t)}function Cn(e){return function(t,n){typeof t!="string"&&(n=t,t="*");var r,i,s,o=t.toLowerCase().split(y),u=0,a=o.length;if(v.isFunction(n))for(;u)[^>]*$|#([\w\-]*)$)/,E=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,S=/^[\],:{}\s]*$/,x=/(?:^|:|,)(?:\s*\[)+/g,T=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,N=/"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,C=/^-ms-/,k=/-([\da-z])/gi,L=function(e,t){return(t+"").toUpperCase()},A=function(){i.addEventListener?(i.removeEventListener("DOMContentLoaded",A,!1),v.ready()):i.readyState==="complete"&&(i.detachEvent("onreadystatechange",A),v.ready())},O={};v.fn=v.prototype={constructor:v,init:function(e,n,r){var s,o,u,a;if(!e)return this;if(e.nodeType)return this.context=this[0]=e,this.length=1,this;if(typeof e=="string"){e.charAt(0)==="<"&&e.charAt(e.length-1)===">"&&e.length>=3?s=[null,e,null]:s=w.exec(e);if(s&&(s[1]||!n)){if(s[1])return n=n instanceof v?n[0]:n,a=n&&n.nodeType?n.ownerDocument||n:i,e=v.parseHTML(s[1],a,!0),E.test(s[1])&&v.isPlainObject(n)&&this.attr.call(e,n,!0),v.merge(this,e);o=i.getElementById(s[2]);if(o&&o.parentNode){if(o.id!==s[2])return r.find(e);this.length=1,this[0]=o}return this.context=i,this.selector=e,this}return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e)}return v.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),v.makeArray(e,this))},selector:"",jquery:"1.8.3",length:0,size:function(){return this.length},toArray:function(){return l.call(this)},get:function(e){return e==null?this.toArray():e<0?this[this.length+e]:this[e]},pushStack:function(e,t,n){var r=v.merge(this.constructor(),e);return r.prevObject=this,r.context=this.context,t==="find"?r.selector=this.selector+(this.selector?" ":"")+n:t&&(r.selector=this.selector+"."+t+"("+n+")"),r},each:function(e,t){return v.each(this,e,t)},ready:function(e){return v.ready.promise().done(e),this},eq:function(e){return e=+e,e===-1?this.slice(e):this.slice(e,e+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(l.apply(this,arguments),"slice",l.call(arguments).join(","))},map:function(e){return this.pushStack(v.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:[].sort,splice:[].splice},v.fn.init.prototype=v.fn,v.extend=v.fn.extend=function(){var e,n,r,i,s,o,u=arguments[0]||{},a=1,f=arguments.length,l=!1;typeof u=="boolean"&&(l=u,u=arguments[1]||{},a=2),typeof u!="object"&&!v.isFunction(u)&&(u={}),f===a&&(u=this,--a);for(;a0)return;r.resolveWith(i,[v]),v.fn.trigger&&v(i).trigger("ready").off("ready")},isFunction:function(e){return v.type(e)==="function"},isArray:Array.isArray||function(e){return v.type(e)==="array"},isWindow:function(e){return e!=null&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return e==null?String(e):O[h.call(e)]||"object"},isPlainObject:function(e){if(!e||v.type(e)!=="object"||e.nodeType||v.isWindow(e))return!1;try{if(e.constructor&&!p.call(e,"constructor")&&!p.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}var r;for(r in e);return r===t||p.call(e,r)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw new Error(e)},parseHTML:function(e,t,n){var r;return!e||typeof e!="string"?null:(typeof t=="boolean"&&(n=t,t=0),t=t||i,(r=E.exec(e))?[t.createElement(r[1])]:(r=v.buildFragment([e],t,n?null:[]),v.merge([],(r.cacheable?v.clone(r.fragment):r.fragment).childNodes)))},parseJSON:function(t){if(!t||typeof t!="string")return null;t=v.trim(t);if(e.JSON&&e.JSON.parse)return e.JSON.parse(t);if(S.test(t.replace(T,"@").replace(N,"]").replace(x,"")))return(new Function("return "+t))();v.error("Invalid JSON: "+t)},parseXML:function(n){var r,i;if(!n||typeof n!="string")return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(s){r=t}return(!r||!r.documentElement||r.getElementsByTagName("parsererror").length)&&v.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&g.test(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(C,"ms-").replace(k,L)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,n,r){var i,s=0,o=e.length,u=o===t||v.isFunction(e);if(r){if(u){for(i in e)if(n.apply(e[i],r)===!1)break}else for(;s0&&e[0]&&e[a-1]||a===0||v.isArray(e));if(f)for(;u-1)a.splice(n,1),i&&(n<=o&&o--,n<=u&&u--)}),this},has:function(e){return v.inArray(e,a)>-1},empty:function(){return a=[],this},disable:function(){return a=f=n=t,this},disabled:function(){return!a},lock:function(){return f=t,n||c.disable(),this},locked:function(){return!f},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],a&&(!r||f)&&(i?f.push(t):l(t)),this},fire:function(){return c.fireWith(this,arguments),this},fired:function(){return!!r}};return c},v.extend({Deferred:function(e){var t=[["resolve","done",v.Callbacks("once memory"),"resolved"],["reject","fail",v.Callbacks("once memory"),"rejected"],["notify","progress",v.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return v.Deferred(function(n){v.each(t,function(t,r){var s=r[0],o=e[t];i[r[1]](v.isFunction(o)?function(){var e=o.apply(this,arguments);e&&v.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[s+"With"](this===i?n:this,[e])}:n[s])}),e=null}).promise()},promise:function(e){return e!=null?v.extend(e,r):r}},i={};return r.pipe=r.then,v.each(t,function(e,s){var o=s[2],u=s[3];r[s[1]]=o.add,u&&o.add(function(){n=u},t[e^1][2].disable,t[2][2].lock),i[s[0]]=o.fire,i[s[0]+"With"]=o.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=l.call(arguments),r=n.length,i=r!==1||e&&v.isFunction(e.promise)?r:0,s=i===1?e:v.Deferred(),o=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?l.call(arguments):r,n===u?s.notifyWith(t,n):--i||s.resolveWith(t,n)}},u,a,f;if(r>1){u=new Array(r),a=new Array(r),f=new Array(r);for(;t
    a",n=p.getElementsByTagName("*"),r=p.getElementsByTagName("a")[0];if(!n||!r||!n.length)return{};s=i.createElement("select"),o=s.appendChild(i.createElement("option")),u=p.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t={leadingWhitespace:p.firstChild.nodeType===3,tbody:!p.getElementsByTagName("tbody").length,htmlSerialize:!!p.getElementsByTagName("link").length,style:/top/.test(r.getAttribute("style")),hrefNormalized:r.getAttribute("href")==="/a",opacity:/^0.5/.test(r.style.opacity),cssFloat:!!r.style.cssFloat,checkOn:u.value==="on",optSelected:o.selected,getSetAttribute:p.className!=="t",enctype:!!i.createElement("form").enctype,html5Clone:i.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",boxModel:i.compatMode==="CSS1Compat",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},u.checked=!0,t.noCloneChecked=u.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!o.disabled;try{delete p.test}catch(d){t.deleteExpando=!1}!p.addEventListener&&p.attachEvent&&p.fireEvent&&(p.attachEvent("onclick",h=function(){t.noCloneEvent=!1}),p.cloneNode(!0).fireEvent("onclick"),p.detachEvent("onclick",h)),u=i.createElement("input"),u.value="t",u.setAttribute("type","radio"),t.radioValue=u.value==="t",u.setAttribute("checked","checked"),u.setAttribute("name","t"),p.appendChild(u),a=i.createDocumentFragment(),a.appendChild(p.lastChild),t.checkClone=a.cloneNode(!0).cloneNode(!0).lastChild.checked,t.appendChecked=u.checked,a.removeChild(u),a.appendChild(p);if(p.attachEvent)for(l in{submit:!0,change:!0,focusin:!0})f="on"+l,c=f in p,c||(p.setAttribute(f,"return;"),c=typeof p[f]=="function"),t[l+"Bubbles"]=c;return v(function(){var n,r,s,o,u="padding:0;margin:0;border:0;display:block;overflow:hidden;",a=i.getElementsByTagName("body")[0];if(!a)return;n=i.createElement("div"),n.style.cssText="visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px",a.insertBefore(n,a.firstChild),r=i.createElement("div"),n.appendChild(r),r.innerHTML="
    t
    ",s=r.getElementsByTagName("td"),s[0].style.cssText="padding:0;margin:0;border:0;display:none",c=s[0].offsetHeight===0,s[0].style.display="",s[1].style.display="none",t.reliableHiddenOffsets=c&&s[0].offsetHeight===0,r.innerHTML="",r.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",t.boxSizing=r.offsetWidth===4,t.doesNotIncludeMarginInBodyOffset=a.offsetTop!==1,e.getComputedStyle&&(t.pixelPosition=(e.getComputedStyle(r,null)||{}).top!=="1%",t.boxSizingReliable=(e.getComputedStyle(r,null)||{width:"4px"}).width==="4px",o=i.createElement("div"),o.style.cssText=r.style.cssText=u,o.style.marginRight=o.style.width="0",r.style.width="1px",r.appendChild(o),t.reliableMarginRight=!parseFloat((e.getComputedStyle(o,null)||{}).marginRight)),typeof r.style.zoom!="undefined"&&(r.innerHTML="",r.style.cssText=u+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=r.offsetWidth===3,r.style.display="block",r.style.overflow="visible",r.innerHTML="
    ",r.firstChild.style.width="5px",t.shrinkWrapBlocks=r.offsetWidth!==3,n.style.zoom=1),a.removeChild(n),n=r=s=o=null}),a.removeChild(p),n=r=s=o=u=a=p=null,t}();var D=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,P=/([A-Z])/g;v.extend({cache:{},deletedIds:[],uuid:0,expando:"jQuery"+(v.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(e){return e=e.nodeType?v.cache[e[v.expando]]:e[v.expando],!!e&&!B(e)},data:function(e,n,r,i){if(!v.acceptData(e))return;var s,o,u=v.expando,a=typeof n=="string",f=e.nodeType,l=f?v.cache:e,c=f?e[u]:e[u]&&u;if((!c||!l[c]||!i&&!l[c].data)&&a&&r===t)return;c||(f?e[u]=c=v.deletedIds.pop()||v.guid++:c=u),l[c]||(l[c]={},f||(l[c].toJSON=v.noop));if(typeof n=="object"||typeof n=="function")i?l[c]=v.extend(l[c],n):l[c].data=v.extend(l[c].data,n);return s=l[c],i||(s.data||(s.data={}),s=s.data),r!==t&&(s[v.camelCase(n)]=r),a?(o=s[n],o==null&&(o=s[v.camelCase(n)])):o=s,o},removeData:function(e,t,n){if(!v.acceptData(e))return;var r,i,s,o=e.nodeType,u=o?v.cache:e,a=o?e[v.expando]:v.expando;if(!u[a])return;if(t){r=n?u[a]:u[a].data;if(r){v.isArray(t)||(t in r?t=[t]:(t=v.camelCase(t),t in r?t=[t]:t=t.split(" ")));for(i=0,s=t.length;i1,null,!1))},removeData:function(e){return this.each(function(){v.removeData(this,e)})}}),v.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=v._data(e,t),n&&(!r||v.isArray(n)?r=v._data(e,t,v.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=v.queue(e,t),r=n.length,i=n.shift(),s=v._queueHooks(e,t),o=function(){v.dequeue(e,t)};i==="inprogress"&&(i=n.shift(),r--),i&&(t==="fx"&&n.unshift("inprogress"),delete s.stop,i.call(e,o,s)),!r&&s&&s.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return v._data(e,n)||v._data(e,n,{empty:v.Callbacks("once memory").add(function(){v.removeData(e,t+"queue",!0),v.removeData(e,n,!0)})})}}),v.fn.extend({queue:function(e,n){var r=2;return typeof e!="string"&&(n=e,e="fx",r--),arguments.length1)},removeAttr:function(e){return this.each(function(){v.removeAttr(this,e)})},prop:function(e,t){return v.access(this,v.prop,e,t,arguments.length>1)},removeProp:function(e){return e=v.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,s,o,u;if(v.isFunction(e))return this.each(function(t){v(this).addClass(e.call(this,t,this.className))});if(e&&typeof e=="string"){t=e.split(y);for(n=0,r=this.length;n=0)r=r.replace(" "+n[s]+" "," ");i.className=e?v.trim(r):""}}}return this},toggleClass:function(e,t){var n=typeof e,r=typeof t=="boolean";return v.isFunction(e)?this.each(function(n){v(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if(n==="string"){var i,s=0,o=v(this),u=t,a=e.split(y);while(i=a[s++])u=r?u:!o.hasClass(i),o[u?"addClass":"removeClass"](i)}else if(n==="undefined"||n==="boolean")this.className&&v._data(this,"__className__",this.className),this.className=this.className||e===!1?"":v._data(this,"__className__")||""})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;n=0)return!0;return!1},val:function(e){var n,r,i,s=this[0];if(!arguments.length){if(s)return n=v.valHooks[s.type]||v.valHooks[s.nodeName.toLowerCase()],n&&"get"in n&&(r=n.get(s,"value"))!==t?r:(r=s.value,typeof r=="string"?r.replace(R,""):r==null?"":r);return}return i=v.isFunction(e),this.each(function(r){var s,o=v(this);if(this.nodeType!==1)return;i?s=e.call(this,r,o.val()):s=e,s==null?s="":typeof s=="number"?s+="":v.isArray(s)&&(s=v.map(s,function(e){return e==null?"":e+""})),n=v.valHooks[this.type]||v.valHooks[this.nodeName.toLowerCase()];if(!n||!("set"in n)||n.set(this,s,"value")===t)this.value=s})}}),v.extend({valHooks:{option:{get:function(e){var t=e.attributes.value;return!t||t.specified?e.value:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,s=e.type==="select-one"||i<0,o=s?null:[],u=s?i+1:r.length,a=i<0?u:s?i:0;for(;a=0}),n.length||(e.selectedIndex=-1),n}}},attrFn:{},attr:function(e,n,r,i){var s,o,u,a=e.nodeType;if(!e||a===3||a===8||a===2)return;if(i&&v.isFunction(v.fn[n]))return v(e)[n](r);if(typeof e.getAttribute=="undefined")return v.prop(e,n,r);u=a!==1||!v.isXMLDoc(e),u&&(n=n.toLowerCase(),o=v.attrHooks[n]||(X.test(n)?F:j));if(r!==t){if(r===null){v.removeAttr(e,n);return}return o&&"set"in o&&u&&(s=o.set(e,r,n))!==t?s:(e.setAttribute(n,r+""),r)}return o&&"get"in o&&u&&(s=o.get(e,n))!==null?s:(s=e.getAttribute(n),s===null?t:s)},removeAttr:function(e,t){var n,r,i,s,o=0;if(t&&e.nodeType===1){r=t.split(y);for(;o=0}})});var $=/^(?:textarea|input|select)$/i,J=/^([^\.]*|)(?:\.(.+)|)$/,K=/(?:^|\s)hover(\.\S+|)\b/,Q=/^key/,G=/^(?:mouse|contextmenu)|click/,Y=/^(?:focusinfocus|focusoutblur)$/,Z=function(e){return v.event.special.hover?e:e.replace(K,"mouseenter$1 mouseleave$1")};v.event={add:function(e,n,r,i,s){var o,u,a,f,l,c,h,p,d,m,g;if(e.nodeType===3||e.nodeType===8||!n||!r||!(o=v._data(e)))return;r.handler&&(d=r,r=d.handler,s=d.selector),r.guid||(r.guid=v.guid++),a=o.events,a||(o.events=a={}),u=o.handle,u||(o.handle=u=function(e){return typeof v=="undefined"||!!e&&v.event.triggered===e.type?t:v.event.dispatch.apply(u.elem,arguments)},u.elem=e),n=v.trim(Z(n)).split(" ");for(f=0;f=0&&(y=y.slice(0,-1),a=!0),y.indexOf(".")>=0&&(b=y.split("."),y=b.shift(),b.sort());if((!s||v.event.customEvent[y])&&!v.event.global[y])return;n=typeof n=="object"?n[v.expando]?n:new v.Event(y,n):new v.Event(y),n.type=y,n.isTrigger=!0,n.exclusive=a,n.namespace=b.join("."),n.namespace_re=n.namespace?new RegExp("(^|\\.)"+b.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,h=y.indexOf(":")<0?"on"+y:"";if(!s){u=v.cache;for(f in u)u[f].events&&u[f].events[y]&&v.event.trigger(n,r,u[f].handle.elem,!0);return}n.result=t,n.target||(n.target=s),r=r!=null?v.makeArray(r):[],r.unshift(n),p=v.event.special[y]||{};if(p.trigger&&p.trigger.apply(s,r)===!1)return;m=[[s,p.bindType||y]];if(!o&&!p.noBubble&&!v.isWindow(s)){g=p.delegateType||y,l=Y.test(g+y)?s:s.parentNode;for(c=s;l;l=l.parentNode)m.push([l,g]),c=l;c===(s.ownerDocument||i)&&m.push([c.defaultView||c.parentWindow||e,g])}for(f=0;f=0:v.find(h,this,null,[s]).length),u[h]&&f.push(c);f.length&&w.push({elem:s,matches:f})}d.length>m&&w.push({elem:this,matches:d.slice(m)});for(r=0;r0?this.on(t,null,e,n):this.trigger(t)},Q.test(t)&&(v.event.fixHooks[t]=v.event.keyHooks),G.test(t)&&(v.event.fixHooks[t]=v.event.mouseHooks)}),function(e,t){function nt(e,t,n,r){n=n||[],t=t||g;var i,s,a,f,l=t.nodeType;if(!e||typeof e!="string")return n;if(l!==1&&l!==9)return[];a=o(t);if(!a&&!r)if(i=R.exec(e))if(f=i[1]){if(l===9){s=t.getElementById(f);if(!s||!s.parentNode)return n;if(s.id===f)return n.push(s),n}else if(t.ownerDocument&&(s=t.ownerDocument.getElementById(f))&&u(t,s)&&s.id===f)return n.push(s),n}else{if(i[2])return S.apply(n,x.call(t.getElementsByTagName(e),0)),n;if((f=i[3])&&Z&&t.getElementsByClassName)return S.apply(n,x.call(t.getElementsByClassName(f),0)),n}return vt(e.replace(j,"$1"),t,n,r,a)}function rt(e){return function(t){var n=t.nodeName.toLowerCase();return n==="input"&&t.type===e}}function it(e){return function(t){var n=t.nodeName.toLowerCase();return(n==="input"||n==="button")&&t.type===e}}function st(e){return N(function(t){return t=+t,N(function(n,r){var i,s=e([],n.length,t),o=s.length;while(o--)n[i=s[o]]&&(n[i]=!(r[i]=n[i]))})})}function ot(e,t,n){if(e===t)return n;var r=e.nextSibling;while(r){if(r===t)return-1;r=r.nextSibling}return 1}function ut(e,t){var n,r,s,o,u,a,f,l=L[d][e+" "];if(l)return t?0:l.slice(0);u=e,a=[],f=i.preFilter;while(u){if(!n||(r=F.exec(u)))r&&(u=u.slice(r[0].length)||u),a.push(s=[]);n=!1;if(r=I.exec(u))s.push(n=new m(r.shift())),u=u.slice(n.length),n.type=r[0].replace(j," ");for(o in i.filter)(r=J[o].exec(u))&&(!f[o]||(r=f[o](r)))&&(s.push(n=new m(r.shift())),u=u.slice(n.length),n.type=o,n.matches=r);if(!n)break}return t?u.length:u?nt.error(e):L(e,a).slice(0)}function at(e,t,r){var i=t.dir,s=r&&t.dir==="parentNode",o=w++;return t.first?function(t,n,r){while(t=t[i])if(s||t.nodeType===1)return e(t,n,r)}:function(t,r,u){if(!u){var a,f=b+" "+o+" ",l=f+n;while(t=t[i])if(s||t.nodeType===1){if((a=t[d])===l)return t.sizset;if(typeof a=="string"&&a.indexOf(f)===0){if(t.sizset)return t}else{t[d]=l;if(e(t,r,u))return t.sizset=!0,t;t.sizset=!1}}}else while(t=t[i])if(s||t.nodeType===1)if(e(t,r,u))return t}}function ft(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function lt(e,t,n,r,i){var s,o=[],u=0,a=e.length,f=t!=null;for(;u-1&&(s[f]=!(o[f]=c))}}else g=lt(g===o?g.splice(d,g.length):g),i?i(null,o,g,a):S.apply(o,g)})}function ht(e){var t,n,r,s=e.length,o=i.relative[e[0].type],u=o||i.relative[" "],a=o?1:0,f=at(function(e){return e===t},u,!0),l=at(function(e){return T.call(t,e)>-1},u,!0),h=[function(e,n,r){return!o&&(r||n!==c)||((t=n).nodeType?f(e,n,r):l(e,n,r))}];for(;a1&&ft(h),a>1&&e.slice(0,a-1).join("").replace(j,"$1"),n,a0,s=e.length>0,o=function(u,a,f,l,h){var p,d,v,m=[],y=0,w="0",x=u&&[],T=h!=null,N=c,C=u||s&&i.find.TAG("*",h&&a.parentNode||a),k=b+=N==null?1:Math.E;T&&(c=a!==g&&a,n=o.el);for(;(p=C[w])!=null;w++){if(s&&p){for(d=0;v=e[d];d++)if(v(p,a,f)){l.push(p);break}T&&(b=k,n=++o.el)}r&&((p=!v&&p)&&y--,u&&x.push(p))}y+=w;if(r&&w!==y){for(d=0;v=t[d];d++)v(x,m,a,f);if(u){if(y>0)while(w--)!x[w]&&!m[w]&&(m[w]=E.call(l));m=lt(m)}S.apply(l,m),T&&!u&&m.length>0&&y+t.length>1&&nt.uniqueSort(l)}return T&&(b=k,c=N),x};return o.el=0,r?N(o):o}function dt(e,t,n){var r=0,i=t.length;for(;r2&&(f=u[0]).type==="ID"&&t.nodeType===9&&!s&&i.relative[u[1].type]){t=i.find.ID(f.matches[0].replace($,""),t,s)[0];if(!t)return n;e=e.slice(u.shift().length)}for(o=J.POS.test(e)?-1:u.length-1;o>=0;o--){f=u[o];if(i.relative[l=f.type])break;if(c=i.find[l])if(r=c(f.matches[0].replace($,""),z.test(u[0].type)&&t.parentNode||t,s)){u.splice(o,1),e=r.length&&u.join("");if(!e)return S.apply(n,x.call(r,0)),n;break}}}return a(e,h)(r,t,s,n,z.test(e)),n}function mt(){}var n,r,i,s,o,u,a,f,l,c,h=!0,p="undefined",d=("sizcache"+Math.random()).replace(".",""),m=String,g=e.document,y=g.documentElement,b=0,w=0,E=[].pop,S=[].push,x=[].slice,T=[].indexOf||function(e){var t=0,n=this.length;for(;ti.cacheLength&&delete e[t.shift()],e[n+" "]=r},e)},k=C(),L=C(),A=C(),O="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",_=M.replace("w","w#"),D="([*^$|!~]?=)",P="\\["+O+"*("+M+")"+O+"*(?:"+D+O+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+_+")|)|)"+O+"*\\]",H=":("+M+")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:"+P+")|[^:]|\\\\.)*|.*))\\)|)",B=":(even|odd|eq|gt|lt|nth|first|last)(?:\\("+O+"*((?:-\\d)?\\d*)"+O+"*\\)|)(?=[^-]|$)",j=new RegExp("^"+O+"+|((?:^|[^\\\\])(?:\\\\.)*)"+O+"+$","g"),F=new RegExp("^"+O+"*,"+O+"*"),I=new RegExp("^"+O+"*([\\x20\\t\\r\\n\\f>+~])"+O+"*"),q=new RegExp(H),R=/^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,U=/^:not/,z=/[\x20\t\r\n\f]*[+~]/,W=/:not\($/,X=/h\d/i,V=/input|select|textarea|button/i,$=/\\(?!\\)/g,J={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),NAME:new RegExp("^\\[name=['\"]?("+M+")['\"]?\\]"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+H),POS:new RegExp(B,"i"),CHILD:new RegExp("^:(only|nth|first|last)-child(?:\\("+O+"*(even|odd|(([+-]|)(\\d*)n|)"+O+"*(?:([+-]|)"+O+"*(\\d+)|))"+O+"*\\)|)","i"),needsContext:new RegExp("^"+O+"*[>+~]|"+B,"i")},K=function(e){var t=g.createElement("div");try{return e(t)}catch(n){return!1}finally{t=null}},Q=K(function(e){return e.appendChild(g.createComment("")),!e.getElementsByTagName("*").length}),G=K(function(e){return e.innerHTML="",e.firstChild&&typeof e.firstChild.getAttribute!==p&&e.firstChild.getAttribute("href")==="#"}),Y=K(function(e){e.innerHTML="";var t=typeof e.lastChild.getAttribute("multiple");return t!=="boolean"&&t!=="string"}),Z=K(function(e){return e.innerHTML="",!e.getElementsByClassName||!e.getElementsByClassName("e").length?!1:(e.lastChild.className="e",e.getElementsByClassName("e").length===2)}),et=K(function(e){e.id=d+0,e.innerHTML="
    ",y.insertBefore(e,y.firstChild);var t=g.getElementsByName&&g.getElementsByName(d).length===2+g.getElementsByName(d+0).length;return r=!g.getElementById(d),y.removeChild(e),t});try{x.call(y.childNodes,0)[0].nodeType}catch(tt){x=function(e){var t,n=[];for(;t=this[e];e++)n.push(t);return n}}nt.matches=function(e,t){return nt(e,null,null,t)},nt.matchesSelector=function(e,t){return nt(t,null,null,[e]).length>0},s=nt.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(i===1||i===9||i===11){if(typeof e.textContent=="string")return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=s(e)}else if(i===3||i===4)return e.nodeValue}else for(;t=e[r];r++)n+=s(t);return n},o=nt.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?t.nodeName!=="HTML":!1},u=nt.contains=y.contains?function(e,t){var n=e.nodeType===9?e.documentElement:e,r=t&&t.parentNode;return e===r||!!(r&&r.nodeType===1&&n.contains&&n.contains(r))}:y.compareDocumentPosition?function(e,t){return t&&!!(e.compareDocumentPosition(t)&16)}:function(e,t){while(t=t.parentNode)if(t===e)return!0;return!1},nt.attr=function(e,t){var n,r=o(e);return r||(t=t.toLowerCase()),(n=i.attrHandle[t])?n(e):r||Y?e.getAttribute(t):(n=e.getAttributeNode(t),n?typeof e[t]=="boolean"?e[t]?t:null:n.specified?n.value:null:null)},i=nt.selectors={cacheLength:50,createPseudo:N,match:J,attrHandle:G?{}:{href:function(e){return e.getAttribute("href",2)},type:function(e){return e.getAttribute("type")}},find:{ID:r?function(e,t,n){if(typeof t.getElementById!==p&&!n){var r=t.getElementById(e);return r&&r.parentNode?[r]:[]}}:function(e,n,r){if(typeof n.getElementById!==p&&!r){var i=n.getElementById(e);return i?i.id===e||typeof i.getAttributeNode!==p&&i.getAttributeNode("id").value===e?[i]:t:[]}},TAG:Q?function(e,t){if(typeof t.getElementsByTagName!==p)return t.getElementsByTagName(e)}:function(e,t){var n=t.getElementsByTagName(e);if(e==="*"){var r,i=[],s=0;for(;r=n[s];s++)r.nodeType===1&&i.push(r);return i}return n},NAME:et&&function(e,t){if(typeof t.getElementsByName!==p)return t.getElementsByName(name)},CLASS:Z&&function(e,t,n){if(typeof t.getElementsByClassName!==p&&!n)return t.getElementsByClassName(e)}},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace($,""),e[3]=(e[4]||e[5]||"").replace($,""),e[2]==="~="&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),e[1]==="nth"?(e[2]||nt.error(e[0]),e[3]=+(e[3]?e[4]+(e[5]||1):2*(e[2]==="even"||e[2]==="odd")),e[4]=+(e[6]+e[7]||e[2]==="odd")):e[2]&&nt.error(e[0]),e},PSEUDO:function(e){var t,n;if(J.CHILD.test(e[0]))return null;if(e[3])e[2]=e[3];else if(t=e[4])q.test(t)&&(n=ut(t,!0))&&(n=t.indexOf(")",t.length-n)-t.length)&&(t=t.slice(0,n),e[0]=e[0].slice(0,n)),e[2]=t;return e.slice(0,3)}},filter:{ID:r?function(e){return e=e.replace($,""),function(t){return t.getAttribute("id")===e}}:function(e){return e=e.replace($,""),function(t){var n=typeof t.getAttributeNode!==p&&t.getAttributeNode("id");return n&&n.value===e}},TAG:function(e){return e==="*"?function(){return!0}:(e=e.replace($,"").toLowerCase(),function(t){return t.nodeName&&t.nodeName.toLowerCase()===e})},CLASS:function(e){var t=k[d][e+" "];return t||(t=new RegExp("(^|"+O+")"+e+"("+O+"|$)"))&&k(e,function(e){return t.test(e.className||typeof e.getAttribute!==p&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r,i){var s=nt.attr(r,e);return s==null?t==="!=":t?(s+="",t==="="?s===n:t==="!="?s!==n:t==="^="?n&&s.indexOf(n)===0:t==="*="?n&&s.indexOf(n)>-1:t==="$="?n&&s.substr(s.length-n.length)===n:t==="~="?(" "+s+" ").indexOf(n)>-1:t==="|="?s===n||s.substr(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r){return e==="nth"?function(e){var t,i,s=e.parentNode;if(n===1&&r===0)return!0;if(s){i=0;for(t=s.firstChild;t;t=t.nextSibling)if(t.nodeType===1){i++;if(e===t)break}}return i-=r,i===n||i%n===0&&i/n>=0}:function(t){var n=t;switch(e){case"only":case"first":while(n=n.previousSibling)if(n.nodeType===1)return!1;if(e==="first")return!0;n=t;case"last":while(n=n.nextSibling)if(n.nodeType===1)return!1;return!0}}},PSEUDO:function(e,t){var n,r=i.pseudos[e]||i.setFilters[e.toLowerCase()]||nt.error("unsupported pseudo: "+e);return r[d]?r(t):r.length>1?(n=[e,e,"",t],i.setFilters.hasOwnProperty(e.toLowerCase())?N(function(e,n){var i,s=r(e,t),o=s.length;while(o--)i=T.call(e,s[o]),e[i]=!(n[i]=s[o])}):function(e){return r(e,0,n)}):r}},pseudos:{not:N(function(e){var t=[],n=[],r=a(e.replace(j,"$1"));return r[d]?N(function(e,t,n,i){var s,o=r(e,null,i,[]),u=e.length;while(u--)if(s=o[u])e[u]=!(t[u]=s)}):function(e,i,s){return t[0]=e,r(t,null,s,n),!n.pop()}}),has:N(function(e){return function(t){return nt(e,t).length>0}}),contains:N(function(e){return function(t){return(t.textContent||t.innerText||s(t)).indexOf(e)>-1}}),enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return t==="input"&&!!e.checked||t==="option"&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},parent:function(e){return!i.pseudos.empty(e)},empty:function(e){var t;e=e.firstChild;while(e){if(e.nodeName>"@"||(t=e.nodeType)===3||t===4)return!1;e=e.nextSibling}return!0},header:function(e){return X.test(e.nodeName)},text:function(e){var t,n;return e.nodeName.toLowerCase()==="input"&&(t=e.type)==="text"&&((n=e.getAttribute("type"))==null||n.toLowerCase()===t)},radio:rt("radio"),checkbox:rt("checkbox"),file:rt("file"),password:rt("password"),image:rt("image"),submit:it("submit"),reset:it("reset"),button:function(e){var t=e.nodeName.toLowerCase();return t==="input"&&e.type==="button"||t==="button"},input:function(e){return V.test(e.nodeName)},focus:function(e){var t=e.ownerDocument;return e===t.activeElement&&(!t.hasFocus||t.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},active:function(e){return e===e.ownerDocument.activeElement},first:st(function(){return[0]}),last:st(function(e,t){return[t-1]}),eq:st(function(e,t,n){return[n<0?n+t:n]}),even:st(function(e,t){for(var n=0;n=0;)e.push(r);return e}),gt:st(function(e,t,n){for(var r=n<0?n+t:n;++r",e.querySelectorAll("[selected]").length||i.push("\\["+O+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),e.querySelectorAll(":checked").length||i.push(":checked")}),K(function(e){e.innerHTML="

    ",e.querySelectorAll("[test^='']").length&&i.push("[*^$]="+O+"*(?:\"\"|'')"),e.innerHTML="",e.querySelectorAll(":enabled").length||i.push(":enabled",":disabled")}),i=new RegExp(i.join("|")),vt=function(e,r,s,o,u){if(!o&&!u&&!i.test(e)){var a,f,l=!0,c=d,h=r,p=r.nodeType===9&&e;if(r.nodeType===1&&r.nodeName.toLowerCase()!=="object"){a=ut(e),(l=r.getAttribute("id"))?c=l.replace(n,"\\$&"):r.setAttribute("id",c),c="[id='"+c+"'] ",f=a.length;while(f--)a[f]=c+a[f].join("");h=z.test(e)&&r.parentNode||r,p=a.join(",")}if(p)try{return S.apply(s,x.call(h.querySelectorAll(p),0)),s}catch(v){}finally{l||r.removeAttribute("id")}}return t(e,r,s,o,u)},u&&(K(function(t){e=u.call(t,"div");try{u.call(t,"[test!='']:sizzle"),s.push("!=",H)}catch(n){}}),s=new RegExp(s.join("|")),nt.matchesSelector=function(t,n){n=n.replace(r,"='$1']");if(!o(t)&&!s.test(n)&&!i.test(n))try{var a=u.call(t,n);if(a||e||t.document&&t.document.nodeType!==11)return a}catch(f){}return nt(n,null,null,[t]).length>0})}(),i.pseudos.nth=i.pseudos.eq,i.filters=mt.prototype=i.pseudos,i.setFilters=new mt,nt.attr=v.attr,v.find=nt,v.expr=nt.selectors,v.expr[":"]=v.expr.pseudos,v.unique=nt.uniqueSort,v.text=nt.getText,v.isXMLDoc=nt.isXML,v.contains=nt.contains}(e);var nt=/Until$/,rt=/^(?:parents|prev(?:Until|All))/,it=/^.[^:#\[\.,]*$/,st=v.expr.match.needsContext,ot={children:!0,contents:!0,next:!0,prev:!0};v.fn.extend({find:function(e){var t,n,r,i,s,o,u=this;if(typeof e!="string")return v(e).filter(function(){for(t=0,n=u.length;t0)for(i=r;i=0:v.filter(e,this).length>0:this.filter(e).length>0)},closest:function(e,t){var n,r=0,i=this.length,s=[],o=st.test(e)||typeof e!="string"?v(e,t||this.context):0;for(;r-1:v.find.matchesSelector(n,e)){s.push(n);break}n=n.parentNode}}return s=s.length>1?v.unique(s):s,this.pushStack(s,"closest",e)},index:function(e){return e?typeof e=="string"?v.inArray(this[0],v(e)):v.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.prevAll().length:-1},add:function(e,t){var n=typeof e=="string"?v(e,t):v.makeArray(e&&e.nodeType?[e]:e),r=v.merge(this.get(),n);return this.pushStack(ut(n[0])||ut(r[0])?r:v.unique(r))},addBack:function(e){return this.add(e==null?this.prevObject:this.prevObject.filter(e))}}),v.fn.andSelf=v.fn.addBack,v.each({parent:function(e){var t=e.parentNode;return t&&t.nodeType!==11?t:null},parents:function(e){return v.dir(e,"parentNode")},parentsUntil:function(e,t,n){return v.dir(e,"parentNode",n)},next:function(e){return at(e,"nextSibling")},prev:function(e){return at(e,"previousSibling")},nextAll:function(e){return v.dir(e,"nextSibling")},prevAll:function(e){return v.dir(e,"previousSibling")},nextUntil:function(e,t,n){return v.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return v.dir(e,"previousSibling",n)},siblings:function(e){return v.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return v.sibling(e.firstChild)},contents:function(e){return v.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:v.merge([],e.childNodes)}},function(e,t){v.fn[e]=function(n,r){var i=v.map(this,t,n);return nt.test(e)||(r=n),r&&typeof r=="string"&&(i=v.filter(r,i)),i=this.length>1&&!ot[e]?v.unique(i):i,this.length>1&&rt.test(e)&&(i=i.reverse()),this.pushStack(i,e,l.call(arguments).join(","))}}),v.extend({filter:function(e,t,n){return n&&(e=":not("+e+")"),t.length===1?v.find.matchesSelector(t[0],e)?[t[0]]:[]:v.find.matches(e,t)},dir:function(e,n,r){var i=[],s=e[n];while(s&&s.nodeType!==9&&(r===t||s.nodeType!==1||!v(s).is(r)))s.nodeType===1&&i.push(s),s=s[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)e.nodeType===1&&e!==t&&n.push(e);return n}});var ct="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",ht=/ jQuery\d+="(?:null|\d+)"/g,pt=/^\s+/,dt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,vt=/<([\w:]+)/,mt=/]","i"),Et=/^(?:checkbox|radio)$/,St=/checked\s*(?:[^=]|=\s*.checked.)/i,xt=/\/(java|ecma)script/i,Tt=/^\s*\s*$/g,Nt={option:[1,""],legend:[1,"
    ","
    "],thead:[1,"","
    "],tr:[2,"","
    "],td:[3,"","
    "],col:[2,"","
    "],area:[1,"",""],_default:[0,"",""]},Ct=lt(i),kt=Ct.appendChild(i.createElement("div"));Nt.optgroup=Nt.option,Nt.tbody=Nt.tfoot=Nt.colgroup=Nt.caption=Nt.thead,Nt.th=Nt.td,v.support.htmlSerialize||(Nt._default=[1,"X
    ","
    "]),v.fn.extend({text:function(e){return v.access(this,function(e){return e===t?v.text(this):this.empty().append((this[0]&&this[0].ownerDocument||i).createTextNode(e))},null,e,arguments.length)},wrapAll:function(e){if(v.isFunction(e))return this.each(function(t){v(this).wrapAll(e.call(this,t))});if(this[0]){var t=v(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&e.firstChild.nodeType===1)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return v.isFunction(e)?this.each(function(t){v(this).wrapInner(e.call(this,t))}):this.each(function(){var t=v(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=v.isFunction(e);return this.each(function(n){v(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){v.nodeName(this,"body")||v(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(e){(this.nodeType===1||this.nodeType===11)&&this.appendChild(e)})},prepend:function(){return this.domManip(arguments,!0,function(e){(this.nodeType===1||this.nodeType===11)&&this.insertBefore(e,this.firstChild)})},before:function(){if(!ut(this[0]))return this.domManip(arguments,!1,function(e){this.parentNode.insertBefore(e,this)});if(arguments.length){var e=v.clean(arguments);return this.pushStack(v.merge(e,this),"before",this.selector)}},after:function(){if(!ut(this[0]))return this.domManip(arguments,!1,function(e){this.parentNode.insertBefore(e,this.nextSibling)});if(arguments.length){var e=v.clean(arguments);return this.pushStack(v.merge(this,e),"after",this.selector)}},remove:function(e,t){var n,r=0;for(;(n=this[r])!=null;r++)if(!e||v.filter(e,[n]).length)!t&&n.nodeType===1&&(v.cleanData(n.getElementsByTagName("*")),v.cleanData([n])),n.parentNode&&n.parentNode.removeChild(n);return this},empty:function(){var e,t=0;for(;(e=this[t])!=null;t++){e.nodeType===1&&v.cleanData(e.getElementsByTagName("*"));while(e.firstChild)e.removeChild(e.firstChild)}return this},clone:function(e,t){return e=e==null?!1:e,t=t==null?e:t,this.map(function(){return v.clone(this,e,t)})},html:function(e){return v.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return n.nodeType===1?n.innerHTML.replace(ht,""):t;if(typeof e=="string"&&!yt.test(e)&&(v.support.htmlSerialize||!wt.test(e))&&(v.support.leadingWhitespace||!pt.test(e))&&!Nt[(vt.exec(e)||["",""])[1].toLowerCase()]){e=e.replace(dt,"<$1>");try{for(;r1&&typeof f=="string"&&St.test(f))return this.each(function(){v(this).domManip(e,n,r)});if(v.isFunction(f))return this.each(function(i){var s=v(this);e[0]=f.call(this,i,n?s.html():t),s.domManip(e,n,r)});if(this[0]){i=v.buildFragment(e,this,l),o=i.fragment,s=o.firstChild,o.childNodes.length===1&&(o=s);if(s){n=n&&v.nodeName(s,"tr");for(u=i.cacheable||c-1;a0?this.clone(!0):this).get(),v(o[i])[t](r),s=s.concat(r);return this.pushStack(s,e,o.selector)}}),v.extend({clone:function(e,t,n){var r,i,s,o;v.support.html5Clone||v.isXMLDoc(e)||!wt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(kt.innerHTML=e.outerHTML,kt.removeChild(o=kt.firstChild));if((!v.support.noCloneEvent||!v.support.noCloneChecked)&&(e.nodeType===1||e.nodeType===11)&&!v.isXMLDoc(e)){Ot(e,o),r=Mt(e),i=Mt(o);for(s=0;r[s];++s)i[s]&&Ot(r[s],i[s])}if(t){At(e,o);if(n){r=Mt(e),i=Mt(o);for(s=0;r[s];++s)At(r[s],i[s])}}return r=i=null,o},clean:function(e,t,n,r){var s,o,u,a,f,l,c,h,p,d,m,g,y=t===i&&Ct,b=[];if(!t||typeof t.createDocumentFragment=="undefined")t=i;for(s=0;(u=e[s])!=null;s++){typeof u=="number"&&(u+="");if(!u)continue;if(typeof u=="string")if(!gt.test(u))u=t.createTextNode(u);else{y=y||lt(t),c=t.createElement("div"),y.appendChild(c),u=u.replace(dt,"<$1>"),a=(vt.exec(u)||["",""])[1].toLowerCase(),f=Nt[a]||Nt._default,l=f[0],c.innerHTML=f[1]+u+f[2];while(l--)c=c.lastChild;if(!v.support.tbody){h=mt.test(u),p=a==="table"&&!h?c.firstChild&&c.firstChild.childNodes:f[1]===""&&!h?c.childNodes:[];for(o=p.length-1;o>=0;--o)v.nodeName(p[o],"tbody")&&!p[o].childNodes.length&&p[o].parentNode.removeChild(p[o])}!v.support.leadingWhitespace&&pt.test(u)&&c.insertBefore(t.createTextNode(pt.exec(u)[0]),c.firstChild),u=c.childNodes,c.parentNode.removeChild(c)}u.nodeType?b.push(u):v.merge(b,u)}c&&(u=c=y=null);if(!v.support.appendChecked)for(s=0;(u=b[s])!=null;s++)v.nodeName(u,"input")?_t(u):typeof u.getElementsByTagName!="undefined"&&v.grep(u.getElementsByTagName("input"),_t);if(n){m=function(e){if(!e.type||xt.test(e.type))return r?r.push(e.parentNode?e.parentNode.removeChild(e):e):n.appendChild(e)};for(s=0;(u=b[s])!=null;s++)if(!v.nodeName(u,"script")||!m(u))n.appendChild(u),typeof u.getElementsByTagName!="undefined"&&(g=v.grep(v.merge([],u.getElementsByTagName("script")),m),b.splice.apply(b,[s+1,0].concat(g)),s+=g.length)}return b},cleanData:function(e,t){var n,r,i,s,o=0,u=v.expando,a=v.cache,f=v.support.deleteExpando,l=v.event.special;for(;(i=e[o])!=null;o++)if(t||v.acceptData(i)){r=i[u],n=r&&a[r];if(n){if(n.events)for(s in n.events)l[s]?v.event.remove(i,s):v.removeEvent(i,s,n.handle);a[r]&&(delete a[r],f?delete i[u]:i.removeAttribute?i.removeAttribute(u):i[u]=null,v.deletedIds.push(r))}}}}),function(){var e,t;v.uaMatch=function(e){e=e.toLowerCase();var t=/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return{browser:t[1]||"",version:t[2]||"0"}},e=v.uaMatch(o.userAgent),t={},e.browser&&(t[e.browser]=!0,t.version=e.version),t.chrome?t.webkit=!0:t.webkit&&(t.safari=!0),v.browser=t,v.sub=function(){function e(t,n){return new e.fn.init(t,n)}v.extend(!0,e,this),e.superclass=this,e.fn=e.prototype=this(),e.fn.constructor=e,e.sub=this.sub,e.fn.init=function(r,i){return i&&i instanceof v&&!(i instanceof e)&&(i=e(i)),v.fn.init.call(this,r,i,t)},e.fn.init.prototype=e.fn;var t=e(i);return e}}();var Dt,Pt,Ht,Bt=/alpha\([^)]*\)/i,jt=/opacity=([^)]*)/,Ft=/^(top|right|bottom|left)$/,It=/^(none|table(?!-c[ea]).+)/,qt=/^margin/,Rt=new RegExp("^("+m+")(.*)$","i"),Ut=new RegExp("^("+m+")(?!px)[a-z%]+$","i"),zt=new RegExp("^([-+])=("+m+")","i"),Wt={BODY:"block"},Xt={position:"absolute",visibility:"hidden",display:"block"},Vt={letterSpacing:0,fontWeight:400},$t=["Top","Right","Bottom","Left"],Jt=["Webkit","O","Moz","ms"],Kt=v.fn.toggle;v.fn.extend({css:function(e,n){return v.access(this,function(e,n,r){return r!==t?v.style(e,n,r):v.css(e,n)},e,n,arguments.length>1)},show:function(){return Yt(this,!0)},hide:function(){return Yt(this)},toggle:function(e,t){var n=typeof e=="boolean";return v.isFunction(e)&&v.isFunction(t)?Kt.apply(this,arguments):this.each(function(){(n?e:Gt(this))?v(this).show():v(this).hide()})}}),v.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Dt(e,"opacity");return n===""?"1":n}}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":v.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(!e||e.nodeType===3||e.nodeType===8||!e.style)return;var s,o,u,a=v.camelCase(n),f=e.style;n=v.cssProps[a]||(v.cssProps[a]=Qt(f,a)),u=v.cssHooks[n]||v.cssHooks[a];if(r===t)return u&&"get"in u&&(s=u.get(e,!1,i))!==t?s:f[n];o=typeof r,o==="string"&&(s=zt.exec(r))&&(r=(s[1]+1)*s[2]+parseFloat(v.css(e,n)),o="number");if(r==null||o==="number"&&isNaN(r))return;o==="number"&&!v.cssNumber[a]&&(r+="px");if(!u||!("set"in u)||(r=u.set(e,r,i))!==t)try{f[n]=r}catch(l){}},css:function(e,n,r,i){var s,o,u,a=v.camelCase(n);return n=v.cssProps[a]||(v.cssProps[a]=Qt(e.style,a)),u=v.cssHooks[n]||v.cssHooks[a],u&&"get"in u&&(s=u.get(e,!0,i)),s===t&&(s=Dt(e,n)),s==="normal"&&n in Vt&&(s=Vt[n]),r||i!==t?(o=parseFloat(s),r||v.isNumeric(o)?o||0:s):s},swap:function(e,t,n){var r,i,s={};for(i in t)s[i]=e.style[i],e.style[i]=t[i];r=n.call(e);for(i in t)e.style[i]=s[i];return r}}),e.getComputedStyle?Dt=function(t,n){var r,i,s,o,u=e.getComputedStyle(t,null),a=t.style;return u&&(r=u.getPropertyValue(n)||u[n],r===""&&!v.contains(t.ownerDocument,t)&&(r=v.style(t,n)),Ut.test(r)&&qt.test(n)&&(i=a.width,s=a.minWidth,o=a.maxWidth,a.minWidth=a.maxWidth=a.width=r,r=u.width,a.width=i,a.minWidth=s,a.maxWidth=o)),r}:i.documentElement.currentStyle&&(Dt=function(e,t){var n,r,i=e.currentStyle&&e.currentStyle[t],s=e.style;return i==null&&s&&s[t]&&(i=s[t]),Ut.test(i)&&!Ft.test(t)&&(n=s.left,r=e.runtimeStyle&&e.runtimeStyle.left,r&&(e.runtimeStyle.left=e.currentStyle.left),s.left=t==="fontSize"?"1em":i,i=s.pixelLeft+"px",s.left=n,r&&(e.runtimeStyle.left=r)),i===""?"auto":i}),v.each(["height","width"],function(e,t){v.cssHooks[t]={get:function(e,n,r){if(n)return e.offsetWidth===0&&It.test(Dt(e,"display"))?v.swap(e,Xt,function(){return tn(e,t,r)}):tn(e,t,r)},set:function(e,n,r){return Zt(e,n,r?en(e,t,r,v.support.boxSizing&&v.css(e,"boxSizing")==="border-box"):0)}}}),v.support.opacity||(v.cssHooks.opacity={get:function(e,t){return jt.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var n=e.style,r=e.currentStyle,i=v.isNumeric(t)?"alpha(opacity="+t*100+")":"",s=r&&r.filter||n.filter||"";n.zoom=1;if(t>=1&&v.trim(s.replace(Bt,""))===""&&n.removeAttribute){n.removeAttribute("filter");if(r&&!r.filter)return}n.filter=Bt.test(s)?s.replace(Bt,i):s+" "+i}}),v(function(){v.support.reliableMarginRight||(v.cssHooks.marginRight={get:function(e,t){return v.swap(e,{display:"inline-block"},function(){if(t)return Dt(e,"marginRight")})}}),!v.support.pixelPosition&&v.fn.position&&v.each(["top","left"],function(e,t){v.cssHooks[t]={get:function(e,n){if(n){var r=Dt(e,t);return Ut.test(r)?v(e).position()[t]+"px":r}}}})}),v.expr&&v.expr.filters&&(v.expr.filters.hidden=function(e){return e.offsetWidth===0&&e.offsetHeight===0||!v.support.reliableHiddenOffsets&&(e.style&&e.style.display||Dt(e,"display"))==="none"},v.expr.filters.visible=function(e){return!v.expr.filters.hidden(e)}),v.each({margin:"",padding:"",border:"Width"},function(e,t){v.cssHooks[e+t]={expand:function(n){var r,i=typeof n=="string"?n.split(" "):[n],s={};for(r=0;r<4;r++)s[e+$t[r]+t]=i[r]||i[r-2]||i[0];return s}},qt.test(e)||(v.cssHooks[e+t].set=Zt)});var rn=/%20/g,sn=/\[\]$/,on=/\r?\n/g,un=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,an=/^(?:select|textarea)/i;v.fn.extend({serialize:function(){return v.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?v.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||an.test(this.nodeName)||un.test(this.type))}).map(function(e,t){var n=v(this).val();return n==null?null:v.isArray(n)?v.map(n,function(e,n){return{name:t.name,value:e.replace(on,"\r\n")}}):{name:t.name,value:n.replace(on,"\r\n")}}).get()}}),v.param=function(e,n){var r,i=[],s=function(e,t){t=v.isFunction(t)?t():t==null?"":t,i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};n===t&&(n=v.ajaxSettings&&v.ajaxSettings.traditional);if(v.isArray(e)||e.jquery&&!v.isPlainObject(e))v.each(e,function(){s(this.name,this.value)});else for(r in e)fn(r,e[r],n,s);return i.join("&").replace(rn,"+")};var ln,cn,hn=/#.*$/,pn=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,dn=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,vn=/^(?:GET|HEAD)$/,mn=/^\/\//,gn=/\?/,yn=/)<[^<]*)*<\/script>/gi,bn=/([?&])_=[^&]*/,wn=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,En=v.fn.load,Sn={},xn={},Tn=["*/"]+["*"];try{cn=s.href}catch(Nn){cn=i.createElement("a"),cn.href="",cn=cn.href}ln=wn.exec(cn.toLowerCase())||[],v.fn.load=function(e,n,r){if(typeof e!="string"&&En)return En.apply(this,arguments);if(!this.length)return this;var i,s,o,u=this,a=e.indexOf(" ");return a>=0&&(i=e.slice(a,e.length),e=e.slice(0,a)),v.isFunction(n)?(r=n,n=t):n&&typeof n=="object"&&(s="POST"),v.ajax({url:e,type:s,dataType:"html",data:n,complete:function(e,t){r&&u.each(r,o||[e.responseText,t,e])}}).done(function(e){o=arguments,u.html(i?v("
    ").append(e.replace(yn,"")).find(i):e)}),this},v.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(e,t){v.fn[t]=function(e){return this.on(t,e)}}),v.each(["get","post"],function(e,n){v[n]=function(e,r,i,s){return v.isFunction(r)&&(s=s||i,i=r,r=t),v.ajax({type:n,url:e,data:r,success:i,dataType:s})}}),v.extend({getScript:function(e,n){return v.get(e,t,n,"script")},getJSON:function(e,t,n){return v.get(e,t,n,"json")},ajaxSetup:function(e,t){return t?Ln(e,v.ajaxSettings):(t=e,e=v.ajaxSettings),Ln(e,t),e},ajaxSettings:{url:cn,isLocal:dn.test(ln[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":Tn},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":e.String,"text html":!0,"text json":v.parseJSON,"text xml":v.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:Cn(Sn),ajaxTransport:Cn(xn),ajax:function(e,n){function T(e,n,s,a){var l,y,b,w,S,T=n;if(E===2)return;E=2,u&&clearTimeout(u),o=t,i=a||"",x.readyState=e>0?4:0,s&&(w=An(c,x,s));if(e>=200&&e<300||e===304)c.ifModified&&(S=x.getResponseHeader("Last-Modified"),S&&(v.lastModified[r]=S),S=x.getResponseHeader("Etag"),S&&(v.etag[r]=S)),e===304?(T="notmodified",l=!0):(l=On(c,w),T=l.state,y=l.data,b=l.error,l=!b);else{b=T;if(!T||e)T="error",e<0&&(e=0)}x.status=e,x.statusText=(n||T)+"",l?d.resolveWith(h,[y,T,x]):d.rejectWith(h,[x,T,b]),x.statusCode(g),g=t,f&&p.trigger("ajax"+(l?"Success":"Error"),[x,c,l?y:b]),m.fireWith(h,[x,T]),f&&(p.trigger("ajaxComplete",[x,c]),--v.active||v.event.trigger("ajaxStop"))}typeof e=="object"&&(n=e,e=t),n=n||{};var r,i,s,o,u,a,f,l,c=v.ajaxSetup({},n),h=c.context||c,p=h!==c&&(h.nodeType||h instanceof v)?v(h):v.event,d=v.Deferred(),m=v.Callbacks("once memory"),g=c.statusCode||{},b={},w={},E=0,S="canceled",x={readyState:0,setRequestHeader:function(e,t){if(!E){var n=e.toLowerCase();e=w[n]=w[n]||e,b[e]=t}return this},getAllResponseHeaders:function(){return E===2?i:null},getResponseHeader:function(e){var n;if(E===2){if(!s){s={};while(n=pn.exec(i))s[n[1].toLowerCase()]=n[2]}n=s[e.toLowerCase()]}return n===t?null:n},overrideMimeType:function(e){return E||(c.mimeType=e),this},abort:function(e){return e=e||S,o&&o.abort(e),T(0,e),this}};d.promise(x),x.success=x.done,x.error=x.fail,x.complete=m.add,x.statusCode=function(e){if(e){var t;if(E<2)for(t in e)g[t]=[g[t],e[t]];else t=e[x.status],x.always(t)}return this},c.url=((e||c.url)+"").replace(hn,"").replace(mn,ln[1]+"//"),c.dataTypes=v.trim(c.dataType||"*").toLowerCase().split(y),c.crossDomain==null&&(a=wn.exec(c.url.toLowerCase()),c.crossDomain=!(!a||a[1]===ln[1]&&a[2]===ln[2]&&(a[3]||(a[1]==="http:"?80:443))==(ln[3]||(ln[1]==="http:"?80:443)))),c.data&&c.processData&&typeof c.data!="string"&&(c.data=v.param(c.data,c.traditional)),kn(Sn,c,n,x);if(E===2)return x;f=c.global,c.type=c.type.toUpperCase(),c.hasContent=!vn.test(c.type),f&&v.active++===0&&v.event.trigger("ajaxStart");if(!c.hasContent){c.data&&(c.url+=(gn.test(c.url)?"&":"?")+c.data,delete c.data),r=c.url;if(c.cache===!1){var N=v.now(),C=c.url.replace(bn,"$1_="+N);c.url=C+(C===c.url?(gn.test(c.url)?"&":"?")+"_="+N:"")}}(c.data&&c.hasContent&&c.contentType!==!1||n.contentType)&&x.setRequestHeader("Content-Type",c.contentType),c.ifModified&&(r=r||c.url,v.lastModified[r]&&x.setRequestHeader("If-Modified-Since",v.lastModified[r]),v.etag[r]&&x.setRequestHeader("If-None-Match",v.etag[r])),x.setRequestHeader("Accept",c.dataTypes[0]&&c.accepts[c.dataTypes[0]]?c.accepts[c.dataTypes[0]]+(c.dataTypes[0]!=="*"?", "+Tn+"; q=0.01":""):c.accepts["*"]);for(l in c.headers)x.setRequestHeader(l,c.headers[l]);if(!c.beforeSend||c.beforeSend.call(h,x,c)!==!1&&E!==2){S="abort";for(l in{success:1,error:1,complete:1})x[l](c[l]);o=kn(xn,c,n,x);if(!o)T(-1,"No Transport");else{x.readyState=1,f&&p.trigger("ajaxSend",[x,c]),c.async&&c.timeout>0&&(u=setTimeout(function(){x.abort("timeout")},c.timeout));try{E=1,o.send(b,T)}catch(k){if(!(E<2))throw k;T(-1,k)}}return x}return x.abort()},active:0,lastModified:{},etag:{}});var Mn=[],_n=/\?/,Dn=/(=)\?(?=&|$)|\?\?/,Pn=v.now();v.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Mn.pop()||v.expando+"_"+Pn++;return this[e]=!0,e}}),v.ajaxPrefilter("json jsonp",function(n,r,i){var s,o,u,a=n.data,f=n.url,l=n.jsonp!==!1,c=l&&Dn.test(f),h=l&&!c&&typeof a=="string"&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Dn.test(a);if(n.dataTypes[0]==="jsonp"||c||h)return s=n.jsonpCallback=v.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,o=e[s],c?n.url=f.replace(Dn,"$1"+s):h?n.data=a.replace(Dn,"$1"+s):l&&(n.url+=(_n.test(f)?"&":"?")+n.jsonp+"="+s),n.converters["script json"]=function(){return u||v.error(s+" was not called"),u[0]},n.dataTypes[0]="json",e[s]=function(){u=arguments},i.always(function(){e[s]=o,n[s]&&(n.jsonpCallback=r.jsonpCallback,Mn.push(s)),u&&v.isFunction(o)&&o(u[0]),u=o=t}),"script"}),v.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(e){return v.globalEval(e),e}}}),v.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),v.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=i.head||i.getElementsByTagName("head")[0]||i.documentElement;return{send:function(s,o){n=i.createElement("script"),n.async="async",e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,i){if(i||!n.readyState||/loaded|complete/.test(n.readyState))n.onload=n.onreadystatechange=null,r&&n.parentNode&&r.removeChild(n),n=t,i||o(200,"success")},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(0,1)}}}});var Hn,Bn=e.ActiveXObject?function(){for(var e in Hn)Hn[e](0,1)}:!1,jn=0;v.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&Fn()||In()}:Fn,function(e){v.extend(v.support,{ajax:!!e,cors:!!e&&"withCredentials"in e})}(v.ajaxSettings.xhr()),v.support.ajax&&v.ajaxTransport(function(n){if(!n.crossDomain||v.support.cors){var r;return{send:function(i,s){var o,u,a=n.xhr();n.username?a.open(n.type,n.url,n.async,n.username,n.password):a.open(n.type,n.url,n.async);if(n.xhrFields)for(u in n.xhrFields)a[u]=n.xhrFields[u];n.mimeType&&a.overrideMimeType&&a.overrideMimeType(n.mimeType),!n.crossDomain&&!i["X-Requested-With"]&&(i["X-Requested-With"]="XMLHttpRequest");try{for(u in i)a.setRequestHeader(u,i[u])}catch(f){}a.send(n.hasContent&&n.data||null),r=function(e,i){var u,f,l,c,h;try{if(r&&(i||a.readyState===4)){r=t,o&&(a.onreadystatechange=v.noop,Bn&&delete Hn[o]);if(i)a.readyState!==4&&a.abort();else{u=a.status,l=a.getAllResponseHeaders(),c={},h=a.responseXML,h&&h.documentElement&&(c.xml=h);try{c.text=a.responseText}catch(p){}try{f=a.statusText}catch(p){f=""}!u&&n.isLocal&&!n.crossDomain?u=c.text?200:404:u===1223&&(u=204)}}}catch(d){i||s(-1,d)}c&&s(u,f,c,l)},n.async?a.readyState===4?setTimeout(r,0):(o=++jn,Bn&&(Hn||(Hn={},v(e).unload(Bn)),Hn[o]=r),a.onreadystatechange=r):r()},abort:function(){r&&r(0,1)}}}});var qn,Rn,Un=/^(?:toggle|show|hide)$/,zn=new RegExp("^(?:([-+])=|)("+m+")([a-z%]*)$","i"),Wn=/queueHooks$/,Xn=[Gn],Vn={"*":[function(e,t){var n,r,i=this.createTween(e,t),s=zn.exec(t),o=i.cur(),u=+o||0,a=1,f=20;if(s){n=+s[2],r=s[3]||(v.cssNumber[e]?"":"px");if(r!=="px"&&u){u=v.css(i.elem,e,!0)||n||1;do a=a||".5",u/=a,v.style(i.elem,e,u+r);while(a!==(a=i.cur()/o)&&a!==1&&--f)}i.unit=r,i.start=u,i.end=s[1]?u+(s[1]+1)*n:n}return i}]};v.Animation=v.extend(Kn,{tweener:function(e,t){v.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;r-1,f={},l={},c,h;a?(l=i.position(),c=l.top,h=l.left):(c=parseFloat(o)||0,h=parseFloat(u)||0),v.isFunction(t)&&(t=t.call(e,n,s)),t.top!=null&&(f.top=t.top-s.top+c),t.left!=null&&(f.left=t.left-s.left+h),"using"in t?t.using.call(e,f):i.css(f)}},v.fn.extend({position:function(){if(!this[0])return;var e=this[0],t=this.offsetParent(),n=this.offset(),r=er.test(t[0].nodeName)?{top:0,left:0}:t.offset();return n.top-=parseFloat(v.css(e,"marginTop"))||0,n.left-=parseFloat(v.css(e,"marginLeft"))||0,r.top+=parseFloat(v.css(t[0],"borderTopWidth"))||0,r.left+=parseFloat(v.css(t[0],"borderLeftWidth"))||0,{top:n.top-r.top,left:n.left-r.left}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||i.body;while(e&&!er.test(e.nodeName)&&v.css(e,"position")==="static")e=e.offsetParent;return e||i.body})}}),v.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);v.fn[e]=function(i){return v.access(this,function(e,i,s){var o=tr(e);if(s===t)return o?n in o?o[n]:o.document.documentElement[i]:e[i];o?o.scrollTo(r?v(o).scrollLeft():s,r?s:v(o).scrollTop()):e[i]=s},e,i,arguments.length,null)}}),v.each({Height:"height",Width:"width"},function(e,n){v.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){v.fn[i]=function(i,s){var o=arguments.length&&(r||typeof i!="boolean"),u=r||(i===!0||s===!0?"margin":"border");return v.access(this,function(n,r,i){var s;return v.isWindow(n)?n.document.documentElement["client"+e]:n.nodeType===9?(s=n.documentElement,Math.max(n.body["scroll"+e],s["scroll"+e],n.body["offset"+e],s["offset"+e],s["client"+e])):i===t?v.css(n,r,i,u):v.style(n,r,i,u)},n,o?i:t,o,null)}})}),e.jQuery=e.$=v,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return v})})(window); \ No newline at end of file diff --git a/PHP/CodeCoverage/Report/HTML/Renderer/Template/method_item.html.dist b/PHP/CodeCoverage/Report/HTML/Renderer/Template/method_item.html.dist index 95ac7839a..72d033f0a 100644 --- a/PHP/CodeCoverage/Report/HTML/Renderer/Template/method_item.html.dist +++ b/PHP/CodeCoverage/Report/HTML/Renderer/Template/method_item.html.dist @@ -1,11 +1,11 @@ -
    - - - - - - - - - + + + + + + + + + + diff --git a/PHP/CodeCoverage/Report/Node.php b/PHP/CodeCoverage/Report/Node.php index 4a0fcd931..672802fd2 100644 --- a/PHP/CodeCoverage/Report/Node.php +++ b/PHP/CodeCoverage/Report/Node.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,347 +34,347 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.1.0 */ /** * Base class for nodes in the code coverage information tree. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.1.0 */ abstract class PHP_CodeCoverage_Report_Node implements Countable { - /** - * @var string - */ - protected $name; - - /** - * @var string - */ - protected $path; - - /** - * @var array - */ - protected $pathArray; - - /** - * @var PHP_CodeCoverage_Report_Node - */ - protected $parent; - - /** - * @var string - */ - protected $id; - - /** - * Constructor. - * - * @param string $name - * @param PHP_CodeCoverage_Report_Node $parent - */ - public function __construct($name, PHP_CodeCoverage_Report_Node $parent = NULL) - { - if (substr($name, -1) == '/') { - $name = substr($name, 0, -1); - } - - $this->name = $name; - $this->parent = $parent; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @return string - */ - public function getId() - { - if ($this->id === NULL) { - $parent = $this->getParent(); - - if ($parent === NULL) { - $this->id = 'index'; - } else { - $parentId = $parent->getId(); - - if ($parentId == 'index') { - $this->id = str_replace(':', '_', $this->name); - } else { - $this->id = $parentId . '_' . $this->name; - } - } - } - - return $this->id; - } - - /** - * @return string - */ - public function getPath() - { - if ($this->path === NULL) { - if ($this->parent === NULL) { - $this->path = $this->name; - } else { - $this->path = $this->parent->getPath() . '/' . $this->name; - } - } - - return $this->path; - } - - /** - * @return array - */ - public function getPathAsArray() - { - if ($this->pathArray === NULL) { - if ($this->parent === NULL) { - $this->pathArray = array(); - } else { - $this->pathArray = $this->parent->getPathAsArray(); - } - - $this->pathArray[] = $this; - } - - return $this->pathArray; - } - - /** - * @return PHP_CodeCoverage_Report_Node - */ - public function getParent() - { - return $this->parent; - } - - /** - * Returns the percentage of classes that has been tested. - * - * @param boolean $asString - * @return integer - */ - public function getTestedClassesPercent($asString = TRUE) - { - return PHP_CodeCoverage_Util::percent( - $this->getNumTestedClasses(), - $this->getNumClasses(), - $asString - ); - } - - /** - * Returns the percentage of traits that has been tested. - * - * @param boolean $asString - * @return integer - */ - public function getTestedTraitsPercent($asString = TRUE) - { - return PHP_CodeCoverage_Util::percent( - $this->getNumTestedTraits(), - $this->getNumTraits(), - $asString - ); - } - - /** - * Returns the percentage of traits that has been tested. - * - * @param boolean $asString - * @return integer - * @since Method available since Release 1.2.0 - */ - public function getTestedClassesAndTraitsPercent($asString = TRUE) - { - return PHP_CodeCoverage_Util::percent( - $this->getNumTestedClassesAndTraits(), - $this->getNumClassesAndTraits(), - $asString - ); - } - - /** - * Returns the percentage of methods that has been tested. - * - * @param boolean $asString - * @return integer - */ - public function getTestedMethodsPercent($asString = TRUE) - { - return PHP_CodeCoverage_Util::percent( - $this->getNumTestedMethods(), - $this->getNumMethods(), - $asString - ); - } - - /** - * Returns the percentage of executed lines. - * - * @param boolean $asString - * @return integer - */ - public function getLineExecutedPercent($asString = TRUE) - { - return PHP_CodeCoverage_Util::percent( - $this->getNumExecutedLines(), - $this->getNumExecutableLines(), - $asString - ); - } - - /** - * Returns the number of classes and traits. - * - * @return integer - * @since Method available since Release 1.2.0 - */ - public function getNumClassesAndTraits() - { - return $this->getNumClasses() + $this->getNumTraits(); - } - - /** - * Returns the number of tested classes and traits. - * - * @return integer - * @since Method available since Release 1.2.0 - */ - public function getNumTestedClassesAndTraits() - { - return $this->getNumTestedClasses() + $this->getNumTestedTraits(); - } - - /** - * Returns the classes and traits of this node. - * - * @return array - * @since Method available since Release 1.2.0 - */ - public function getClassesAndTraits() - { - return array_merge($this->getClasses(), $this->getTraits()); - } - - /** - * Returns the classes of this node. - * - * @return array - */ - abstract public function getClasses(); - - /** - * Returns the traits of this node. - * - * @return array - */ - abstract public function getTraits(); - - /** - * Returns the functions of this node. - * - * @return array - */ - abstract public function getFunctions(); - - /** - * Returns the LOC/CLOC/NCLOC of this node. - * - * @return array - */ - abstract public function getLinesOfCode(); - - /** - * Returns the number of executable lines. - * - * @return integer - */ - abstract public function getNumExecutableLines(); - - /** - * Returns the number of executed lines. - * - * @return integer - */ - abstract public function getNumExecutedLines(); - - /** - * Returns the number of classes. - * - * @return integer - */ - abstract public function getNumClasses(); - - /** - * Returns the number of tested classes. - * - * @return integer - */ - abstract public function getNumTestedClasses(); - - /** - * Returns the number of traits. - * - * @return integer - */ - abstract public function getNumTraits(); - - /** - * Returns the number of tested traits. - * - * @return integer - */ - abstract public function getNumTestedTraits(); - - /** - * Returns the number of methods. - * - * @return integer - */ - abstract public function getNumMethods(); - - /** - * Returns the number of tested methods. - * - * @return integer - */ - abstract public function getNumTestedMethods(); - - /** - * Returns the number of functions. - * - * @return integer - */ - abstract public function getNumFunctions(); - - /** - * Returns the number of tested functions. - * - * @return integer - */ - abstract public function getNumTestedFunctions(); + /** + * @var string + */ + protected $name; + + /** + * @var string + */ + protected $path; + + /** + * @var array + */ + protected $pathArray; + + /** + * @var PHP_CodeCoverage_Report_Node + */ + protected $parent; + + /** + * @var string + */ + protected $id; + + /** + * Constructor. + * + * @param string $name + * @param PHP_CodeCoverage_Report_Node $parent + */ + public function __construct($name, PHP_CodeCoverage_Report_Node $parent = NULL) + { + if (substr($name, -1) == '/') { + $name = substr($name, 0, -1); + } + + $this->name = $name; + $this->parent = $parent; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @return string + */ + public function getId() + { + if ($this->id === NULL) { + $parent = $this->getParent(); + + if ($parent === NULL) { + $this->id = 'index'; + } else { + $parentId = $parent->getId(); + + if ($parentId == 'index') { + $this->id = str_replace(':', '_', $this->name); + } else { + $this->id = $parentId . '_' . $this->name; + } + } + } + + return $this->id; + } + + /** + * @return string + */ + public function getPath() + { + if ($this->path === NULL) { + if ($this->parent === NULL) { + $this->path = $this->name; + } else { + $this->path = $this->parent->getPath() . '/' . $this->name; + } + } + + return $this->path; + } + + /** + * @return array + */ + public function getPathAsArray() + { + if ($this->pathArray === NULL) { + if ($this->parent === NULL) { + $this->pathArray = array(); + } else { + $this->pathArray = $this->parent->getPathAsArray(); + } + + $this->pathArray[] = $this; + } + + return $this->pathArray; + } + + /** + * @return PHP_CodeCoverage_Report_Node + */ + public function getParent() + { + return $this->parent; + } + + /** + * Returns the percentage of classes that has been tested. + * + * @param boolean $asString + * @return integer + */ + public function getTestedClassesPercent($asString = TRUE) + { + return PHP_CodeCoverage_Util::percent( + $this->getNumTestedClasses(), + $this->getNumClasses(), + $asString + ); + } + + /** + * Returns the percentage of traits that has been tested. + * + * @param boolean $asString + * @return integer + */ + public function getTestedTraitsPercent($asString = TRUE) + { + return PHP_CodeCoverage_Util::percent( + $this->getNumTestedTraits(), + $this->getNumTraits(), + $asString + ); + } + + /** + * Returns the percentage of traits that has been tested. + * + * @param boolean $asString + * @return integer + * @since Method available since Release 1.2.0 + */ + public function getTestedClassesAndTraitsPercent($asString = TRUE) + { + return PHP_CodeCoverage_Util::percent( + $this->getNumTestedClassesAndTraits(), + $this->getNumClassesAndTraits(), + $asString + ); + } + + /** + * Returns the percentage of methods that has been tested. + * + * @param boolean $asString + * @return integer + */ + public function getTestedMethodsPercent($asString = TRUE) + { + return PHP_CodeCoverage_Util::percent( + $this->getNumTestedMethods(), + $this->getNumMethods(), + $asString + ); + } + + /** + * Returns the percentage of executed lines. + * + * @param boolean $asString + * @return integer + */ + public function getLineExecutedPercent($asString = TRUE) + { + return PHP_CodeCoverage_Util::percent( + $this->getNumExecutedLines(), + $this->getNumExecutableLines(), + $asString + ); + } + + /** + * Returns the number of classes and traits. + * + * @return integer + * @since Method available since Release 1.2.0 + */ + public function getNumClassesAndTraits() + { + return $this->getNumClasses() + $this->getNumTraits(); + } + + /** + * Returns the number of tested classes and traits. + * + * @return integer + * @since Method available since Release 1.2.0 + */ + public function getNumTestedClassesAndTraits() + { + return $this->getNumTestedClasses() + $this->getNumTestedTraits(); + } + + /** + * Returns the classes and traits of this node. + * + * @return array + * @since Method available since Release 1.2.0 + */ + public function getClassesAndTraits() + { + return array_merge($this->getClasses(), $this->getTraits()); + } + + /** + * Returns the classes of this node. + * + * @return array + */ + abstract public function getClasses(); + + /** + * Returns the traits of this node. + * + * @return array + */ + abstract public function getTraits(); + + /** + * Returns the functions of this node. + * + * @return array + */ + abstract public function getFunctions(); + + /** + * Returns the LOC/CLOC/NCLOC of this node. + * + * @return array + */ + abstract public function getLinesOfCode(); + + /** + * Returns the number of executable lines. + * + * @return integer + */ + abstract public function getNumExecutableLines(); + + /** + * Returns the number of executed lines. + * + * @return integer + */ + abstract public function getNumExecutedLines(); + + /** + * Returns the number of classes. + * + * @return integer + */ + abstract public function getNumClasses(); + + /** + * Returns the number of tested classes. + * + * @return integer + */ + abstract public function getNumTestedClasses(); + + /** + * Returns the number of traits. + * + * @return integer + */ + abstract public function getNumTraits(); + + /** + * Returns the number of tested traits. + * + * @return integer + */ + abstract public function getNumTestedTraits(); + + /** + * Returns the number of methods. + * + * @return integer + */ + abstract public function getNumMethods(); + + /** + * Returns the number of tested methods. + * + * @return integer + */ + abstract public function getNumTestedMethods(); + + /** + * Returns the number of functions. + * + * @return integer + */ + abstract public function getNumFunctions(); + + /** + * Returns the number of tested functions. + * + * @return integer + */ + abstract public function getNumTestedFunctions(); } diff --git a/PHP/CodeCoverage/Report/Node/Directory.php b/PHP/CodeCoverage/Report/Node/Directory.php index 44e151e13..d610457a2 100644 --- a/PHP/CodeCoverage/Report/Node/Directory.php +++ b/PHP/CodeCoverage/Report/Node/Directory.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,479 +34,479 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.1.0 */ /** * Represents a directory in the code coverage information tree. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.1.0 */ class PHP_CodeCoverage_Report_Node_Directory extends PHP_CodeCoverage_Report_Node implements IteratorAggregate { - /** - * @var PHP_CodeCoverage_Report_Node[] - */ - protected $children = array(); - - /** - * @var PHP_CodeCoverage_Report_Node_Directory[] - */ - protected $directories = array(); - - /** - * @var PHP_CodeCoverage_Report_Node_File[] - */ - protected $files = array(); - - /** - * @var array - */ - protected $classes; - - /** - * @var array - */ - protected $traits; - - /** - * @var array - */ - protected $functions; - - /** - * @var array - */ - protected $linesOfCode = NULL; - - /** - * @var integer - */ - protected $numFiles = -1; - - /** - * @var integer - */ - protected $numExecutableLines = -1; - - /** - * @var integer - */ - protected $numExecutedLines = -1; - - /** - * @var integer - */ - protected $numClasses = -1; - - /** - * @var integer - */ - protected $numTestedClasses = -1; - - /** - * @var integer - */ - protected $numTraits = -1; - - /** - * @var integer - */ - protected $numTestedTraits = -1; - - /** - * @var integer - */ - protected $numMethods = -1; - - /** - * @var integer - */ - protected $numTestedMethods = -1; - - /** - * @var integer - */ - protected $numFunctions = -1; - - /** - * @var integer - */ - protected $numTestedFunctions = -1; - - /** - * Returns the number of files in/under this node. - * - * @return integer - */ - public function count() - { - if ($this->numFiles == -1) { - $this->numFiles = 0; - - foreach ($this->children as $child) { - $this->numFiles += count($child); - } - } - - return $this->numFiles; - } - - /** - * Returns an iterator for this node. - * - * @return RecursiveIteratorIterator - */ - public function getIterator() - { - return new RecursiveIteratorIterator( - new PHP_CodeCoverage_Report_Node_Iterator($this), - RecursiveIteratorIterator::SELF_FIRST - ); - } - - /** - * Adds a new directory. - * - * @param string $name - * @return PHP_CodeCoverage_Report_Node_Directory - */ - public function addDirectory($name) - { - $directory = new PHP_CodeCoverage_Report_Node_Directory($name, $this); - - $this->children[] = $directory; - $this->directories[] = &$this->children[count($this->children) - 1]; - - return $directory; - } - - /** - * Adds a new file. - * - * @param string $name - * @param array $coverageData - * @param array $testData - * @param boolean $cacheTokens - * @return PHP_CodeCoverage_Report_Node_File - * @throws PHP_CodeCoverage_Exception - */ - public function addFile($name, array $coverageData, array $testData, $cacheTokens) - { - $file = new PHP_CodeCoverage_Report_Node_File( - $name, $this, $coverageData, $testData, $cacheTokens - ); - - $this->children[] = $file; - $this->files[] = &$this->children[count($this->children) - 1]; - - $this->numExecutableLines = -1; - $this->numExecutedLines = -1; - - return $file; - } - - /** - * Returns the directories in this directory. - * - * @return array - */ - public function getDirectories() - { - return $this->directories; - } - - /** - * Returns the files in this directory. - * - * @return array - */ - public function getFiles() - { - return $this->files; - } - - /** - * Returns the child nodes of this node. - * - * @return array - */ - public function getChildNodes() - { - return $this->children; - } - - /** - * Returns the classes of this node. - * - * @return array - */ - public function getClasses() - { - if ($this->classes === NULL) { - $this->classes = array(); - - foreach ($this->children as $child) { - $this->classes = array_merge( - $this->classes, $child->getClasses() - ); - } - } - - return $this->classes; - } - - /** - * Returns the traits of this node. - * - * @return array - */ - public function getTraits() - { - if ($this->traits === NULL) { - $this->traits = array(); - - foreach ($this->children as $child) { - $this->traits = array_merge( - $this->traits, $child->getTraits() - ); - } - } - - return $this->traits; - } - - /** - * Returns the functions of this node. - * - * @return array - */ - public function getFunctions() - { - if ($this->functions === NULL) { - $this->functions = array(); - - foreach ($this->children as $child) { - $this->functions = array_merge( - $this->functions, $child->getFunctions() - ); - } - } - - return $this->functions; - } - - /** - * Returns the LOC/CLOC/NCLOC of this node. - * - * @return array - */ - public function getLinesOfCode() - { - if ($this->linesOfCode === NULL) { - $this->linesOfCode = array('loc' => 0, 'cloc' => 0, 'ncloc' => 0); - - foreach ($this->children as $child) { - $linesOfCode = $child->getLinesOfCode(); - - $this->linesOfCode['loc'] += $linesOfCode['loc']; - $this->linesOfCode['cloc'] += $linesOfCode['cloc']; - $this->linesOfCode['ncloc'] += $linesOfCode['ncloc']; - } - } - - return $this->linesOfCode; - } - - /** - * Returns the number of executable lines. - * - * @return integer - */ - public function getNumExecutableLines() - { - if ($this->numExecutableLines == -1) { - $this->numExecutableLines = 0; - - foreach ($this->children as $child) { - $this->numExecutableLines += $child->getNumExecutableLines(); - } - } - - return $this->numExecutableLines; - } - - /** - * Returns the number of executed lines. - * - * @return integer - */ - public function getNumExecutedLines() - { - if ($this->numExecutedLines == -1) { - $this->numExecutedLines = 0; - - foreach ($this->children as $child) { - $this->numExecutedLines += $child->getNumExecutedLines(); - } - } - - return $this->numExecutedLines; - } - - /** - * Returns the number of classes. - * - * @return integer - */ - public function getNumClasses() - { - if ($this->numClasses == -1) { - $this->numClasses = 0; - - foreach ($this->children as $child) { - $this->numClasses += $child->getNumClasses(); - } - } - - return $this->numClasses; - } - - /** - * Returns the number of tested classes. - * - * @return integer - */ - public function getNumTestedClasses() - { - if ($this->numTestedClasses == -1) { - $this->numTestedClasses = 0; - - foreach ($this->children as $child) { - $this->numTestedClasses += $child->getNumTestedClasses(); - } - } - - return $this->numTestedClasses; - } - - /** - * Returns the number of traits. - * - * @return integer - */ - public function getNumTraits() - { - if ($this->numTraits == -1) { - $this->numTraits = 0; - - foreach ($this->children as $child) { - $this->numTraits += $child->getNumTraits(); - } - } - - return $this->numTraits; - } - - /** - * Returns the number of tested traits. - * - * @return integer - */ - public function getNumTestedTraits() - { - if ($this->numTestedTraits == -1) { - $this->numTestedTraits = 0; - - foreach ($this->children as $child) { - $this->numTestedTraits += $child->getNumTestedTraits(); - } - } - - return $this->numTestedTraits; - } - - /** - * Returns the number of methods. - * - * @return integer - */ - public function getNumMethods() - { - if ($this->numMethods == -1) { - $this->numMethods = 0; - - foreach ($this->children as $child) { - $this->numMethods += $child->getNumMethods(); - } - } - - return $this->numMethods; - } - - /** - * Returns the number of tested methods. - * - * @return integer - */ - public function getNumTestedMethods() - { - if ($this->numTestedMethods == -1) { - $this->numTestedMethods = 0; - - foreach ($this->children as $child) { - $this->numTestedMethods += $child->getNumTestedMethods(); - } - } - - return $this->numTestedMethods; - } - - /** - * Returns the number of functions. - * - * @return integer - */ - public function getNumFunctions() - { - if ($this->numFunctions == -1) { - $this->numFunctions = 0; - - foreach ($this->children as $child) { - $this->numFunctions += $child->getNumFunctions(); - } - } - - return $this->numFunctions; - } - - /** - * Returns the number of tested functions. - * - * @return integer - */ - public function getNumTestedFunctions() - { - if ($this->numTestedFunctions == -1) { - $this->numTestedFunctions = 0; - - foreach ($this->children as $child) { - $this->numTestedFunctions += $child->getNumTestedFunctions(); - } - } - - return $this->numTestedFunctions; - } + /** + * @var PHP_CodeCoverage_Report_Node[] + */ + protected $children = array(); + + /** + * @var PHP_CodeCoverage_Report_Node_Directory[] + */ + protected $directories = array(); + + /** + * @var PHP_CodeCoverage_Report_Node_File[] + */ + protected $files = array(); + + /** + * @var array + */ + protected $classes; + + /** + * @var array + */ + protected $traits; + + /** + * @var array + */ + protected $functions; + + /** + * @var array + */ + protected $linesOfCode = NULL; + + /** + * @var integer + */ + protected $numFiles = -1; + + /** + * @var integer + */ + protected $numExecutableLines = -1; + + /** + * @var integer + */ + protected $numExecutedLines = -1; + + /** + * @var integer + */ + protected $numClasses = -1; + + /** + * @var integer + */ + protected $numTestedClasses = -1; + + /** + * @var integer + */ + protected $numTraits = -1; + + /** + * @var integer + */ + protected $numTestedTraits = -1; + + /** + * @var integer + */ + protected $numMethods = -1; + + /** + * @var integer + */ + protected $numTestedMethods = -1; + + /** + * @var integer + */ + protected $numFunctions = -1; + + /** + * @var integer + */ + protected $numTestedFunctions = -1; + + /** + * Returns the number of files in/under this node. + * + * @return integer + */ + public function count() + { + if ($this->numFiles == -1) { + $this->numFiles = 0; + + foreach ($this->children as $child) { + $this->numFiles += count($child); + } + } + + return $this->numFiles; + } + + /** + * Returns an iterator for this node. + * + * @return RecursiveIteratorIterator + */ + public function getIterator() + { + return new RecursiveIteratorIterator( + new PHP_CodeCoverage_Report_Node_Iterator($this), + RecursiveIteratorIterator::SELF_FIRST + ); + } + + /** + * Adds a new directory. + * + * @param string $name + * @return PHP_CodeCoverage_Report_Node_Directory + */ + public function addDirectory($name) + { + $directory = new PHP_CodeCoverage_Report_Node_Directory($name, $this); + + $this->children[] = $directory; + $this->directories[] = &$this->children[count($this->children) - 1]; + + return $directory; + } + + /** + * Adds a new file. + * + * @param string $name + * @param array $coverageData + * @param array $testData + * @param boolean $cacheTokens + * @return PHP_CodeCoverage_Report_Node_File + * @throws PHP_CodeCoverage_Exception + */ + public function addFile($name, array $coverageData, array $testData, $cacheTokens) + { + $file = new PHP_CodeCoverage_Report_Node_File( + $name, $this, $coverageData, $testData, $cacheTokens + ); + + $this->children[] = $file; + $this->files[] = &$this->children[count($this->children) - 1]; + + $this->numExecutableLines = -1; + $this->numExecutedLines = -1; + + return $file; + } + + /** + * Returns the directories in this directory. + * + * @return array + */ + public function getDirectories() + { + return $this->directories; + } + + /** + * Returns the files in this directory. + * + * @return array + */ + public function getFiles() + { + return $this->files; + } + + /** + * Returns the child nodes of this node. + * + * @return array + */ + public function getChildNodes() + { + return $this->children; + } + + /** + * Returns the classes of this node. + * + * @return array + */ + public function getClasses() + { + if ($this->classes === NULL) { + $this->classes = array(); + + foreach ($this->children as $child) { + $this->classes = array_merge( + $this->classes, $child->getClasses() + ); + } + } + + return $this->classes; + } + + /** + * Returns the traits of this node. + * + * @return array + */ + public function getTraits() + { + if ($this->traits === NULL) { + $this->traits = array(); + + foreach ($this->children as $child) { + $this->traits = array_merge( + $this->traits, $child->getTraits() + ); + } + } + + return $this->traits; + } + + /** + * Returns the functions of this node. + * + * @return array + */ + public function getFunctions() + { + if ($this->functions === NULL) { + $this->functions = array(); + + foreach ($this->children as $child) { + $this->functions = array_merge( + $this->functions, $child->getFunctions() + ); + } + } + + return $this->functions; + } + + /** + * Returns the LOC/CLOC/NCLOC of this node. + * + * @return array + */ + public function getLinesOfCode() + { + if ($this->linesOfCode === NULL) { + $this->linesOfCode = array('loc' => 0, 'cloc' => 0, 'ncloc' => 0); + + foreach ($this->children as $child) { + $linesOfCode = $child->getLinesOfCode(); + + $this->linesOfCode['loc'] += $linesOfCode['loc']; + $this->linesOfCode['cloc'] += $linesOfCode['cloc']; + $this->linesOfCode['ncloc'] += $linesOfCode['ncloc']; + } + } + + return $this->linesOfCode; + } + + /** + * Returns the number of executable lines. + * + * @return integer + */ + public function getNumExecutableLines() + { + if ($this->numExecutableLines == -1) { + $this->numExecutableLines = 0; + + foreach ($this->children as $child) { + $this->numExecutableLines += $child->getNumExecutableLines(); + } + } + + return $this->numExecutableLines; + } + + /** + * Returns the number of executed lines. + * + * @return integer + */ + public function getNumExecutedLines() + { + if ($this->numExecutedLines == -1) { + $this->numExecutedLines = 0; + + foreach ($this->children as $child) { + $this->numExecutedLines += $child->getNumExecutedLines(); + } + } + + return $this->numExecutedLines; + } + + /** + * Returns the number of classes. + * + * @return integer + */ + public function getNumClasses() + { + if ($this->numClasses == -1) { + $this->numClasses = 0; + + foreach ($this->children as $child) { + $this->numClasses += $child->getNumClasses(); + } + } + + return $this->numClasses; + } + + /** + * Returns the number of tested classes. + * + * @return integer + */ + public function getNumTestedClasses() + { + if ($this->numTestedClasses == -1) { + $this->numTestedClasses = 0; + + foreach ($this->children as $child) { + $this->numTestedClasses += $child->getNumTestedClasses(); + } + } + + return $this->numTestedClasses; + } + + /** + * Returns the number of traits. + * + * @return integer + */ + public function getNumTraits() + { + if ($this->numTraits == -1) { + $this->numTraits = 0; + + foreach ($this->children as $child) { + $this->numTraits += $child->getNumTraits(); + } + } + + return $this->numTraits; + } + + /** + * Returns the number of tested traits. + * + * @return integer + */ + public function getNumTestedTraits() + { + if ($this->numTestedTraits == -1) { + $this->numTestedTraits = 0; + + foreach ($this->children as $child) { + $this->numTestedTraits += $child->getNumTestedTraits(); + } + } + + return $this->numTestedTraits; + } + + /** + * Returns the number of methods. + * + * @return integer + */ + public function getNumMethods() + { + if ($this->numMethods == -1) { + $this->numMethods = 0; + + foreach ($this->children as $child) { + $this->numMethods += $child->getNumMethods(); + } + } + + return $this->numMethods; + } + + /** + * Returns the number of tested methods. + * + * @return integer + */ + public function getNumTestedMethods() + { + if ($this->numTestedMethods == -1) { + $this->numTestedMethods = 0; + + foreach ($this->children as $child) { + $this->numTestedMethods += $child->getNumTestedMethods(); + } + } + + return $this->numTestedMethods; + } + + /** + * Returns the number of functions. + * + * @return integer + */ + public function getNumFunctions() + { + if ($this->numFunctions == -1) { + $this->numFunctions = 0; + + foreach ($this->children as $child) { + $this->numFunctions += $child->getNumFunctions(); + } + } + + return $this->numFunctions; + } + + /** + * Returns the number of tested functions. + * + * @return integer + */ + public function getNumTestedFunctions() + { + if ($this->numTestedFunctions == -1) { + $this->numTestedFunctions = 0; + + foreach ($this->children as $child) { + $this->numTestedFunctions += $child->getNumTestedFunctions(); + } + } + + return $this->numTestedFunctions; + } } diff --git a/PHP/CodeCoverage/Report/Node/File.php b/PHP/CodeCoverage/Report/Node/File.php index 96715da69..5974cf45a 100644 --- a/PHP/CodeCoverage/Report/Node/File.php +++ b/PHP/CodeCoverage/Report/Node/File.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,670 +34,670 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.1.0 */ /** * Represents a file in the code coverage information tree. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.1.0 */ class PHP_CodeCoverage_Report_Node_File extends PHP_CodeCoverage_Report_Node { - /** - * @var array - */ - protected $coverageData; - - /** - * @var array - */ - protected $testData; - - /** - * @var integer - */ - protected $numExecutableLines = 0; - - /** - * @var integer - */ - protected $numExecutedLines = 0; - - /** - * @var array - */ - protected $classes = array(); - - /** - * @var array - */ - protected $traits = array(); - - /** - * @var array - */ - protected $functions = array(); - - /** - * @var array - */ - protected $linesOfCode = array(); - - /** - * @var integer - */ - protected $numTestedTraits = 0; - - /** - * @var integer - */ - protected $numTestedClasses = 0; - - /** - * @var integer - */ - protected $numMethods = NULL; - - /** - * @var integer - */ - protected $numTestedMethods = NULL; - - /** - * @var integer - */ - protected $numTestedFunctions = NULL; - - /** - * @var array - */ - protected $startLines = array(); - - /** - * @var array - */ - protected $endLines = array(); - - /** - * @var boolean - */ - protected $cacheTokens; - - /** - * Constructor. - * - * @param string $name - * @param PHP_CodeCoverage_Report_Node $parent - * @param array $coverageData - * @param array $testData - * @param boolean $cacheTokens - * @throws PHP_CodeCoverage_Exception - */ - public function __construct($name, PHP_CodeCoverage_Report_Node $parent, array $coverageData, array $testData, $cacheTokens) - { - if (!is_bool($cacheTokens)) { - throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory( - 1, 'boolean' - ); - } - - parent::__construct($name, $parent); - - $this->coverageData = $coverageData; - $this->testData = $testData; - $this->cacheTokens = $cacheTokens; - - $this->calculateStatistics(); - } - - /** - * Returns the number of files in/under this node. - * - * @return integer - */ - public function count() - { - return 1; - } - - /** - * Returns the code coverage data of this node. - * - * @return array - */ - public function getCoverageData() - { - return $this->coverageData; - } - - /** - * Returns the test data of this node. - * - * @return array - */ - public function getTestData() - { - return $this->testData; - } - - /** - * Returns the classes of this node. - * - * @return array - */ - public function getClasses() - { - return $this->classes; - } - - /** - * Returns the traits of this node. - * - * @return array - */ - public function getTraits() - { - return $this->traits; - } - - /** - * Returns the functions of this node. - * - * @return array - */ - public function getFunctions() - { - return $this->functions; - } - - /** - * Returns the LOC/CLOC/NCLOC of this node. - * - * @return array - */ - public function getLinesOfCode() - { - return $this->linesOfCode; - } - - /** - * Returns the number of executable lines. - * - * @return integer - */ - public function getNumExecutableLines() - { - return $this->numExecutableLines; - } - - /** - * Returns the number of executed lines. - * - * @return integer - */ - public function getNumExecutedLines() - { - return $this->numExecutedLines; - } - - /** - * Returns the number of classes. - * - * @return integer - */ - public function getNumClasses() - { - return count($this->classes); - } - - /** - * Returns the number of tested classes. - * - * @return integer - */ - public function getNumTestedClasses() - { - return $this->numTestedClasses; - } - - /** - * Returns the number of traits. - * - * @return integer - */ - public function getNumTraits() - { - return count($this->traits); - } - - /** - * Returns the number of tested traits. - * - * @return integer - */ - public function getNumTestedTraits() - { - return $this->numTestedTraits; - } - - /** - * Returns the number of methods. - * - * @return integer - */ - public function getNumMethods() - { - if ($this->numMethods === NULL) { - $this->numMethods = 0; - - foreach ($this->classes as $class) { - foreach ($class['methods'] as $method) { - if ($method['executableLines'] > 0) { - $this->numMethods++; - } - } - } - - foreach ($this->traits as $trait) { - foreach ($trait['methods'] as $method) { - if ($method['executableLines'] > 0) { - $this->numMethods++; - } - } - } - } - - return $this->numMethods; - } - - /** - * Returns the number of tested methods. - * - * @return integer - */ - public function getNumTestedMethods() - { - if ($this->numTestedMethods === NULL) { - $this->numTestedMethods = 0; - - foreach ($this->classes as $class) { - foreach ($class['methods'] as $method) { - if ($method['executableLines'] > 0 && - $method['coverage'] == 100) { - $this->numTestedMethods++; - } - } - } - - foreach ($this->traits as $trait) { - foreach ($trait['methods'] as $method) { - if ($method['executableLines'] > 0 && - $method['coverage'] == 100) { - $this->numTestedMethods++; - } - } - } - } - - return $this->numTestedMethods; - } - - /** - * Returns the number of functions. - * - * @return integer - */ - public function getNumFunctions() - { - return count($this->functions); - } - - /** - * Returns the number of tested functions. - * - * @return integer - */ - public function getNumTestedFunctions() - { - if ($this->numTestedFunctions === NULL) { - $this->numTestedFunctions = 0; - - foreach ($this->functions as $function) { - if ($function['executableLines'] > 0 && - $function['coverage'] == 100) { - $this->numTestedFunctions++; - } - } - } - - return $this->numTestedFunctions; - } - - /** - * Calculates coverage statistics for the file. - */ - protected function calculateStatistics() - { - if ($this->cacheTokens) { - $tokens = PHP_Token_Stream_CachingFactory::get($this->getPath()); - } else { - $tokens = new PHP_Token_Stream($this->getPath()); - } - - $this->processClasses($tokens); - $this->processTraits($tokens); - $this->processFunctions($tokens); - $this->linesOfCode = $tokens->getLinesOfCode(); - unset($tokens); - - for ($lineNumber = 1; $lineNumber <= $this->linesOfCode['loc']; $lineNumber++) { - if (isset($this->startLines[$lineNumber])) { - // Start line of a class. - if (isset($this->startLines[$lineNumber]['className'])) { - $currentClass = &$this->startLines[$lineNumber]; - } - - // Start line of a trait. - else if (isset($this->startLines[$lineNumber]['traitName'])) { - $currentTrait = &$this->startLines[$lineNumber]; - } - - // Start line of a method. - else if (isset($this->startLines[$lineNumber]['methodName'])) { - $currentMethod = &$this->startLines[$lineNumber]; - } - - // Start line of a function. - else if (isset($this->startLines[$lineNumber]['functionName'])) { - $currentFunction = &$this->startLines[$lineNumber]; - } - } - - if (isset($this->coverageData[$lineNumber]) && - $this->coverageData[$lineNumber] !== NULL) { - if (isset($currentClass)) { - $currentClass['executableLines']++; - } - - if (isset($currentTrait)) { - $currentTrait['executableLines']++; - } - - if (isset($currentMethod)) { - $currentMethod['executableLines']++; - } - - if (isset($currentFunction)) { - $currentFunction['executableLines']++; - } - - $this->numExecutableLines++; - - if (count($this->coverageData[$lineNumber]) > 0) { - if (isset($currentClass)) { - $currentClass['executedLines']++; - } - - if (isset($currentTrait)) { - $currentTrait['executedLines']++; - } - - if (isset($currentMethod)) { - $currentMethod['executedLines']++; - } - - if (isset($currentFunction)) { - $currentFunction['executedLines']++; - } - - $this->numExecutedLines++; - } - } - - if (isset($this->endLines[$lineNumber])) { - // End line of a class. - if (isset($this->endLines[$lineNumber]['className'])) { - unset($currentClass); - } - - // End line of a trait. - else if (isset($this->endLines[$lineNumber]['traitName'])) { - unset($currentTrait); - } - - // End line of a method. - else if (isset($this->endLines[$lineNumber]['methodName'])) { - unset($currentMethod); - } - - // End line of a function. - else if (isset($this->endLines[$lineNumber]['functionName'])) { - unset($currentFunction); - } - } - } - - foreach ($this->traits as &$trait) { - foreach ($trait['methods'] as &$method) { - if ($method['executableLines'] > 0) { - $method['coverage'] = ($method['executedLines'] / - $method['executableLines']) * 100; - } else { - $method['coverage'] = 100; - } - - $method['crap'] = $this->crap( - $method['ccn'], $method['coverage'] - ); - - $trait['ccn'] += $method['ccn']; - } - - if ($trait['executableLines'] > 0) { - $trait['coverage'] = ($trait['executedLines'] / - $trait['executableLines']) * 100; - } else { - $trait['coverage'] = 100; - } - - if ($trait['coverage'] == 100) { - $this->numTestedClasses++; - } - - $trait['crap'] = $this->crap( - $trait['ccn'], $trait['coverage'] - ); - } - - foreach ($this->classes as &$class) { - foreach ($class['methods'] as &$method) { - if ($method['executableLines'] > 0) { - $method['coverage'] = ($method['executedLines'] / - $method['executableLines']) * 100; - } else { - $method['coverage'] = 100; - } - - $method['crap'] = $this->crap( - $method['ccn'], $method['coverage'] - ); - - $class['ccn'] += $method['ccn']; - } - - if ($class['executableLines'] > 0) { - $class['coverage'] = ($class['executedLines'] / - $class['executableLines']) * 100; - } else { - $class['coverage'] = 100; - } - - if ($class['coverage'] == 100) { - $this->numTestedClasses++; - } - - $class['crap'] = $this->crap( - $class['ccn'], $class['coverage'] - ); - } - } - - /** - * @param PHP_Token_Stream $tokens - */ - protected function processClasses(PHP_Token_Stream $tokens) - { - $classes = $tokens->getClasses(); - unset($tokens); - - $link = $this->getId() . '.html#'; - - foreach ($classes as $className => $class) { - $this->classes[$className] = array( - 'className' => $className, - 'methods' => array(), - 'startLine' => $class['startLine'], - 'executableLines' => 0, - 'executedLines' => 0, - 'ccn' => 0, - 'coverage' => 0, - 'crap' => 0, - 'package' => $class['package'], - 'link' => $link . $class['startLine'] - ); - - $this->startLines[$class['startLine']] = &$this->classes[$className]; - $this->endLines[$class['endLine']] = &$this->classes[$className]; - - foreach ($class['methods'] as $methodName => $method) { - $this->classes[$className]['methods'][$methodName] = array( - 'methodName' => $methodName, - 'signature' => $method['signature'], - 'startLine' => $method['startLine'], - 'endLine' => $method['endLine'], - 'executableLines' => 0, - 'executedLines' => 0, - 'ccn' => $method['ccn'], - 'coverage' => 0, - 'crap' => 0, - 'link' => $link . $method['startLine'] - ); - - $this->startLines[$method['startLine']] = &$this->classes[$className]['methods'][$methodName]; - $this->endLines[$method['endLine']] = &$this->classes[$className]['methods'][$methodName]; - } - } - } - - /** - * @param PHP_Token_Stream $tokens - */ - protected function processTraits(PHP_Token_Stream $tokens) - { - $traits = $tokens->getTraits(); - unset($tokens); - - $link = $this->getId() . '.html#'; - - foreach ($traits as $traitName => $trait) { - $this->traits[$traitName] = array( - 'traitName' => $traitName, - 'methods' => array(), - 'startLine' => $trait['startLine'], - 'executableLines' => 0, - 'executedLines' => 0, - 'ccn' => 0, - 'coverage' => 0, - 'crap' => 0, - 'package' => $trait['package'], - 'link' => $link . $trait['startLine'] - ); - - $this->startLines[$trait['startLine']] = &$this->traits[$traitName]; - $this->endLines[$trait['endLine']] = &$this->traits[$traitName]; - - foreach ($trait['methods'] as $methodName => $method) { - $this->traits[$traitName]['methods'][$methodName] = array( - 'methodName' => $methodName, - 'signature' => $method['signature'], - 'startLine' => $method['startLine'], - 'endLine' => $method['endLine'], - 'executableLines' => 0, - 'executedLines' => 0, - 'ccn' => $method['ccn'], - 'coverage' => 0, - 'crap' => 0, - 'link' => $link . $method['startLine'] - ); - - $this->startLines[$method['startLine']] = &$this->traits[$traitName]['methods'][$methodName]; - $this->endLines[$method['endLine']] = &$this->traits[$traitName]['methods'][$methodName]; - } - } - } - - /** - * @param PHP_Token_Stream $tokens - */ - protected function processFunctions(PHP_Token_Stream $tokens) - { - $functions = $tokens->getFunctions(); - unset($tokens); - - $link = $this->getId() . '.html#'; - - foreach ($functions as $functionName => $function) { - $this->functions[$functionName] = array( - 'functionName' => $functionName, - 'signature' => $function['signature'], - 'startLine' => $function['startLine'], - 'executableLines' => 0, - 'executedLines' => 0, - 'ccn' => $function['ccn'], - 'coverage' => 0, - 'crap' => 0, - 'link' => $link . $function['startLine'] - ); - - $this->startLines[$function['startLine']] = &$this->functions[$functionName]; - $this->endLines[$function['endLine']] = &$this->functions[$functionName]; - } - } - - /** - * Calculates the Change Risk Anti-Patterns (CRAP) index for a unit of code - * based on its cyclomatic complexity and percentage of code coverage. - * - * @param integer $ccn - * @param float $coverage - * @return string - * @since Method available since Release 1.2.0 - */ - protected function crap($ccn, $coverage) - { - if ($coverage == 0) { - return (string)pow($ccn, 2) + $ccn; - } - - if ($coverage >= 95) { - return (string)$ccn; - } - - return sprintf( - '%01.2F', pow($ccn, 2) * pow(1 - $coverage/100, 3) + $ccn - ); - } + /** + * @var array + */ + protected $coverageData; + + /** + * @var array + */ + protected $testData; + + /** + * @var integer + */ + protected $numExecutableLines = 0; + + /** + * @var integer + */ + protected $numExecutedLines = 0; + + /** + * @var array + */ + protected $classes = array(); + + /** + * @var array + */ + protected $traits = array(); + + /** + * @var array + */ + protected $functions = array(); + + /** + * @var array + */ + protected $linesOfCode = array(); + + /** + * @var integer + */ + protected $numTestedTraits = 0; + + /** + * @var integer + */ + protected $numTestedClasses = 0; + + /** + * @var integer + */ + protected $numMethods = NULL; + + /** + * @var integer + */ + protected $numTestedMethods = NULL; + + /** + * @var integer + */ + protected $numTestedFunctions = NULL; + + /** + * @var array + */ + protected $startLines = array(); + + /** + * @var array + */ + protected $endLines = array(); + + /** + * @var boolean + */ + protected $cacheTokens; + + /** + * Constructor. + * + * @param string $name + * @param PHP_CodeCoverage_Report_Node $parent + * @param array $coverageData + * @param array $testData + * @param boolean $cacheTokens + * @throws PHP_CodeCoverage_Exception + */ + public function __construct($name, PHP_CodeCoverage_Report_Node $parent, array $coverageData, array $testData, $cacheTokens) + { + if (!is_bool($cacheTokens)) { + throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory( + 1, 'boolean' + ); + } + + parent::__construct($name, $parent); + + $this->coverageData = $coverageData; + $this->testData = $testData; + $this->cacheTokens = $cacheTokens; + + $this->calculateStatistics(); + } + + /** + * Returns the number of files in/under this node. + * + * @return integer + */ + public function count() + { + return 1; + } + + /** + * Returns the code coverage data of this node. + * + * @return array + */ + public function getCoverageData() + { + return $this->coverageData; + } + + /** + * Returns the test data of this node. + * + * @return array + */ + public function getTestData() + { + return $this->testData; + } + + /** + * Returns the classes of this node. + * + * @return array + */ + public function getClasses() + { + return $this->classes; + } + + /** + * Returns the traits of this node. + * + * @return array + */ + public function getTraits() + { + return $this->traits; + } + + /** + * Returns the functions of this node. + * + * @return array + */ + public function getFunctions() + { + return $this->functions; + } + + /** + * Returns the LOC/CLOC/NCLOC of this node. + * + * @return array + */ + public function getLinesOfCode() + { + return $this->linesOfCode; + } + + /** + * Returns the number of executable lines. + * + * @return integer + */ + public function getNumExecutableLines() + { + return $this->numExecutableLines; + } + + /** + * Returns the number of executed lines. + * + * @return integer + */ + public function getNumExecutedLines() + { + return $this->numExecutedLines; + } + + /** + * Returns the number of classes. + * + * @return integer + */ + public function getNumClasses() + { + return count($this->classes); + } + + /** + * Returns the number of tested classes. + * + * @return integer + */ + public function getNumTestedClasses() + { + return $this->numTestedClasses; + } + + /** + * Returns the number of traits. + * + * @return integer + */ + public function getNumTraits() + { + return count($this->traits); + } + + /** + * Returns the number of tested traits. + * + * @return integer + */ + public function getNumTestedTraits() + { + return $this->numTestedTraits; + } + + /** + * Returns the number of methods. + * + * @return integer + */ + public function getNumMethods() + { + if ($this->numMethods === NULL) { + $this->numMethods = 0; + + foreach ($this->classes as $class) { + foreach ($class['methods'] as $method) { + if ($method['executableLines'] > 0) { + $this->numMethods++; + } + } + } + + foreach ($this->traits as $trait) { + foreach ($trait['methods'] as $method) { + if ($method['executableLines'] > 0) { + $this->numMethods++; + } + } + } + } + + return $this->numMethods; + } + + /** + * Returns the number of tested methods. + * + * @return integer + */ + public function getNumTestedMethods() + { + if ($this->numTestedMethods === NULL) { + $this->numTestedMethods = 0; + + foreach ($this->classes as $class) { + foreach ($class['methods'] as $method) { + if ($method['executableLines'] > 0 && + $method['coverage'] == 100) { + $this->numTestedMethods++; + } + } + } + + foreach ($this->traits as $trait) { + foreach ($trait['methods'] as $method) { + if ($method['executableLines'] > 0 && + $method['coverage'] == 100) { + $this->numTestedMethods++; + } + } + } + } + + return $this->numTestedMethods; + } + + /** + * Returns the number of functions. + * + * @return integer + */ + public function getNumFunctions() + { + return count($this->functions); + } + + /** + * Returns the number of tested functions. + * + * @return integer + */ + public function getNumTestedFunctions() + { + if ($this->numTestedFunctions === NULL) { + $this->numTestedFunctions = 0; + + foreach ($this->functions as $function) { + if ($function['executableLines'] > 0 && + $function['coverage'] == 100) { + $this->numTestedFunctions++; + } + } + } + + return $this->numTestedFunctions; + } + + /** + * Calculates coverage statistics for the file. + */ + protected function calculateStatistics() + { + if ($this->cacheTokens) { + $tokens = PHP_Token_Stream_CachingFactory::get($this->getPath()); + } else { + $tokens = new PHP_Token_Stream($this->getPath()); + } + + $this->processClasses($tokens); + $this->processTraits($tokens); + $this->processFunctions($tokens); + $this->linesOfCode = $tokens->getLinesOfCode(); + unset($tokens); + + for ($lineNumber = 1; $lineNumber <= $this->linesOfCode['loc']; $lineNumber++) { + if (isset($this->startLines[$lineNumber])) { + // Start line of a class. + if (isset($this->startLines[$lineNumber]['className'])) { + $currentClass = &$this->startLines[$lineNumber]; + } + + // Start line of a trait. + else if (isset($this->startLines[$lineNumber]['traitName'])) { + $currentTrait = &$this->startLines[$lineNumber]; + } + + // Start line of a method. + else if (isset($this->startLines[$lineNumber]['methodName'])) { + $currentMethod = &$this->startLines[$lineNumber]; + } + + // Start line of a function. + else if (isset($this->startLines[$lineNumber]['functionName'])) { + $currentFunction = &$this->startLines[$lineNumber]; + } + } + + if (isset($this->coverageData[$lineNumber]) && + $this->coverageData[$lineNumber] !== NULL) { + if (isset($currentClass)) { + $currentClass['executableLines']++; + } + + if (isset($currentTrait)) { + $currentTrait['executableLines']++; + } + + if (isset($currentMethod)) { + $currentMethod['executableLines']++; + } + + if (isset($currentFunction)) { + $currentFunction['executableLines']++; + } + + $this->numExecutableLines++; + + if (count($this->coverageData[$lineNumber]) > 0) { + if (isset($currentClass)) { + $currentClass['executedLines']++; + } + + if (isset($currentTrait)) { + $currentTrait['executedLines']++; + } + + if (isset($currentMethod)) { + $currentMethod['executedLines']++; + } + + if (isset($currentFunction)) { + $currentFunction['executedLines']++; + } + + $this->numExecutedLines++; + } + } + + if (isset($this->endLines[$lineNumber])) { + // End line of a class. + if (isset($this->endLines[$lineNumber]['className'])) { + unset($currentClass); + } + + // End line of a trait. + else if (isset($this->endLines[$lineNumber]['traitName'])) { + unset($currentTrait); + } + + // End line of a method. + else if (isset($this->endLines[$lineNumber]['methodName'])) { + unset($currentMethod); + } + + // End line of a function. + else if (isset($this->endLines[$lineNumber]['functionName'])) { + unset($currentFunction); + } + } + } + + foreach ($this->traits as &$trait) { + foreach ($trait['methods'] as &$method) { + if ($method['executableLines'] > 0) { + $method['coverage'] = ($method['executedLines'] / + $method['executableLines']) * 100; + } else { + $method['coverage'] = 100; + } + + $method['crap'] = $this->crap( + $method['ccn'], $method['coverage'] + ); + + $trait['ccn'] += $method['ccn']; + } + + if ($trait['executableLines'] > 0) { + $trait['coverage'] = ($trait['executedLines'] / + $trait['executableLines']) * 100; + } else { + $trait['coverage'] = 100; + } + + if ($trait['coverage'] == 100) { + $this->numTestedClasses++; + } + + $trait['crap'] = $this->crap( + $trait['ccn'], $trait['coverage'] + ); + } + + foreach ($this->classes as &$class) { + foreach ($class['methods'] as &$method) { + if ($method['executableLines'] > 0) { + $method['coverage'] = ($method['executedLines'] / + $method['executableLines']) * 100; + } else { + $method['coverage'] = 100; + } + + $method['crap'] = $this->crap( + $method['ccn'], $method['coverage'] + ); + + $class['ccn'] += $method['ccn']; + } + + if ($class['executableLines'] > 0) { + $class['coverage'] = ($class['executedLines'] / + $class['executableLines']) * 100; + } else { + $class['coverage'] = 100; + } + + if ($class['coverage'] == 100) { + $this->numTestedClasses++; + } + + $class['crap'] = $this->crap( + $class['ccn'], $class['coverage'] + ); + } + } + + /** + * @param PHP_Token_Stream $tokens + */ + protected function processClasses(PHP_Token_Stream $tokens) + { + $classes = $tokens->getClasses(); + unset($tokens); + + $link = $this->getId() . '.html#'; + + foreach ($classes as $className => $class) { + $this->classes[$className] = array( + 'className' => $className, + 'methods' => array(), + 'startLine' => $class['startLine'], + 'executableLines' => 0, + 'executedLines' => 0, + 'ccn' => 0, + 'coverage' => 0, + 'crap' => 0, + 'package' => $class['package'], + 'link' => $link . $class['startLine'] + ); + + $this->startLines[$class['startLine']] = &$this->classes[$className]; + $this->endLines[$class['endLine']] = &$this->classes[$className]; + + foreach ($class['methods'] as $methodName => $method) { + $this->classes[$className]['methods'][$methodName] = array( + 'methodName' => $methodName, + 'signature' => $method['signature'], + 'startLine' => $method['startLine'], + 'endLine' => $method['endLine'], + 'executableLines' => 0, + 'executedLines' => 0, + 'ccn' => $method['ccn'], + 'coverage' => 0, + 'crap' => 0, + 'link' => $link . $method['startLine'] + ); + + $this->startLines[$method['startLine']] = &$this->classes[$className]['methods'][$methodName]; + $this->endLines[$method['endLine']] = &$this->classes[$className]['methods'][$methodName]; + } + } + } + + /** + * @param PHP_Token_Stream $tokens + */ + protected function processTraits(PHP_Token_Stream $tokens) + { + $traits = $tokens->getTraits(); + unset($tokens); + + $link = $this->getId() . '.html#'; + + foreach ($traits as $traitName => $trait) { + $this->traits[$traitName] = array( + 'traitName' => $traitName, + 'methods' => array(), + 'startLine' => $trait['startLine'], + 'executableLines' => 0, + 'executedLines' => 0, + 'ccn' => 0, + 'coverage' => 0, + 'crap' => 0, + 'package' => $trait['package'], + 'link' => $link . $trait['startLine'] + ); + + $this->startLines[$trait['startLine']] = &$this->traits[$traitName]; + $this->endLines[$trait['endLine']] = &$this->traits[$traitName]; + + foreach ($trait['methods'] as $methodName => $method) { + $this->traits[$traitName]['methods'][$methodName] = array( + 'methodName' => $methodName, + 'signature' => $method['signature'], + 'startLine' => $method['startLine'], + 'endLine' => $method['endLine'], + 'executableLines' => 0, + 'executedLines' => 0, + 'ccn' => $method['ccn'], + 'coverage' => 0, + 'crap' => 0, + 'link' => $link . $method['startLine'] + ); + + $this->startLines[$method['startLine']] = &$this->traits[$traitName]['methods'][$methodName]; + $this->endLines[$method['endLine']] = &$this->traits[$traitName]['methods'][$methodName]; + } + } + } + + /** + * @param PHP_Token_Stream $tokens + */ + protected function processFunctions(PHP_Token_Stream $tokens) + { + $functions = $tokens->getFunctions(); + unset($tokens); + + $link = $this->getId() . '.html#'; + + foreach ($functions as $functionName => $function) { + $this->functions[$functionName] = array( + 'functionName' => $functionName, + 'signature' => $function['signature'], + 'startLine' => $function['startLine'], + 'executableLines' => 0, + 'executedLines' => 0, + 'ccn' => $function['ccn'], + 'coverage' => 0, + 'crap' => 0, + 'link' => $link . $function['startLine'] + ); + + $this->startLines[$function['startLine']] = &$this->functions[$functionName]; + $this->endLines[$function['endLine']] = &$this->functions[$functionName]; + } + } + + /** + * Calculates the Change Risk Anti-Patterns (CRAP) index for a unit of code + * based on its cyclomatic complexity and percentage of code coverage. + * + * @param integer $ccn + * @param float $coverage + * @return string + * @since Method available since Release 1.2.0 + */ + protected function crap($ccn, $coverage) + { + if ($coverage == 0) { + return (string)pow($ccn, 2) + $ccn; + } + + if ($coverage >= 95) { + return (string)$ccn; + } + + return sprintf( + '%01.2F', pow($ccn, 2) * pow(1 - $coverage/100, 3) + $ccn + ); + } } diff --git a/PHP/CodeCoverage/Report/Node/Iterator.php b/PHP/CodeCoverage/Report/Node/Iterator.php index e8e97403a..ce64b0798 100644 --- a/PHP/CodeCoverage/Report/Node/Iterator.php +++ b/PHP/CodeCoverage/Report/Node/Iterator.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,115 +34,115 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.1.0 */ /** * Recursive iterator for PHP_CodeCoverage_Report_Node object graphs. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.1.0 */ class PHP_CodeCoverage_Report_Node_Iterator implements RecursiveIterator { - /** - * @var integer - */ - protected $position; + /** + * @var integer + */ + protected $position; - /** - * @var PHP_CodeCoverage_Report_Node[] - */ - protected $nodes; + /** + * @var PHP_CodeCoverage_Report_Node[] + */ + protected $nodes; - /** - * Constructor. - * - * @param PHP_CodeCoverage_Report_Node_Directory $node - */ - public function __construct(PHP_CodeCoverage_Report_Node_Directory $node) - { - $this->nodes = $node->getChildNodes(); - } + /** + * Constructor. + * + * @param PHP_CodeCoverage_Report_Node_Directory $node + */ + public function __construct(PHP_CodeCoverage_Report_Node_Directory $node) + { + $this->nodes = $node->getChildNodes(); + } - /** - * Rewinds the Iterator to the first element. - * - */ - public function rewind() - { - $this->position = 0; - } + /** + * Rewinds the Iterator to the first element. + * + */ + public function rewind() + { + $this->position = 0; + } - /** - * Checks if there is a current element after calls to rewind() or next(). - * - * @return boolean - */ - public function valid() - { - return $this->position < count($this->nodes); - } + /** + * Checks if there is a current element after calls to rewind() or next(). + * + * @return boolean + */ + public function valid() + { + return $this->position < count($this->nodes); + } - /** - * Returns the key of the current element. - * - * @return integer - */ - public function key() - { - return $this->position; - } + /** + * Returns the key of the current element. + * + * @return integer + */ + public function key() + { + return $this->position; + } - /** - * Returns the current element. - * - * @return PHPUnit_Framework_Test - */ - public function current() - { - return $this->valid() ? $this->nodes[$this->position] : NULL; - } + /** + * Returns the current element. + * + * @return PHPUnit_Framework_Test + */ + public function current() + { + return $this->valid() ? $this->nodes[$this->position] : NULL; + } - /** - * Moves forward to next element. - * - */ - public function next() - { - $this->position++; - } + /** + * Moves forward to next element. + * + */ + public function next() + { + $this->position++; + } - /** - * Returns the sub iterator for the current element. - * - * @return PHP_CodeCoverage_Report_Node_Iterator - */ - public function getChildren() - { - return new PHP_CodeCoverage_Report_Node_Iterator( - $this->nodes[$this->position] - ); - } + /** + * Returns the sub iterator for the current element. + * + * @return PHP_CodeCoverage_Report_Node_Iterator + */ + public function getChildren() + { + return new PHP_CodeCoverage_Report_Node_Iterator( + $this->nodes[$this->position] + ); + } - /** - * Checks whether the current element has children. - * - * @return boolean - */ - public function hasChildren() - { - return $this->nodes[$this->position] instanceof PHP_CodeCoverage_Report_Node_Directory; - } + /** + * Checks whether the current element has children. + * + * @return boolean + */ + public function hasChildren() + { + return $this->nodes[$this->position] instanceof PHP_CodeCoverage_Report_Node_Directory; + } } diff --git a/PHP/CodeCoverage/Report/PHP.php b/PHP/CodeCoverage/Report/PHP.php index c3482b5af..7990892ba 100644 --- a/PHP/CodeCoverage/Report/PHP.php +++ b/PHP/CodeCoverage/Report/PHP.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,41 +34,41 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.1.0 */ /** * Uses serialize() to write a PHP_CodeCoverage object to a file. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.1.0 */ class PHP_CodeCoverage_Report_PHP { - /** - * @param PHP_CodeCoverage $coverage - * @param string $target - * @return string - */ - public function process(PHP_CodeCoverage $coverage, $target = NULL) - { - $coverage = serialize($coverage); + /** + * @param PHP_CodeCoverage $coverage + * @param string $target + * @return string + */ + public function process(PHP_CodeCoverage $coverage, $target = NULL) + { + $coverage = serialize($coverage); - if ($target !== NULL) { - return file_put_contents($target, $coverage); - } else { - return $coverage; - } - } + if ($target !== NULL) { + return file_put_contents($target, $coverage); + } else { + return $coverage; + } + } } diff --git a/PHP/CodeCoverage/Report/Text.php b/PHP/CodeCoverage/Report/Text.php index 9c855bbe8..b4a9d87e3 100644 --- a/PHP/CodeCoverage/Report/Text.php +++ b/PHP/CodeCoverage/Report/Text.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,13 +34,13 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.1.0 */ /** @@ -48,236 +48,236 @@ * * The output gets put into a text file our written to the CLI. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.1.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.1.0 */ class PHP_CodeCoverage_Report_Text { - protected $outputStream; - protected $lowUpperBound; - protected $highLowerBound; - protected $showUncoveredFiles; - protected $showOnlySummary; - - protected $colors = array( - 'green' => "\x1b[30;42m", - 'yellow' => "\x1b[30;43m", - 'red' => "\x1b[37;41m", - 'header' => "\x1b[47;40m", - 'reset' => "\x1b[0m", - 'eol' => "\x1b[2K", - ); - - public function __construct(PHPUnit_Util_Printer $outputStream, $lowUpperBound, $highLowerBound, $showUncoveredFiles, $showOnlySummary) - { - $this->outputStream = $outputStream; - $this->lowUpperBound = $lowUpperBound; - $this->highLowerBound = $highLowerBound; - $this->showUncoveredFiles = $showUncoveredFiles; - $this->showOnlySummary = $showOnlySummary; - } - - /** - * @param PHP_CodeCoverage $coverage - * @param bool $showColors - * @return string - */ - public function process(PHP_CodeCoverage $coverage, $showColors = FALSE) - { - $output = ''; - $report = $coverage->getReport(); - unset($coverage); - - $colors = array( - 'header' => '', - 'classes' => '', - 'methods' => '', - 'lines' => '', - 'reset' => '', - 'eol' => '' - ); - - if ($showColors) { - $colors['classes'] = $this->getCoverageColor( - $report->getNumTestedClassesAndTraits(), - $report->getNumClassesAndTraits() - ); - $colors['methods'] = $this->getCoverageColor( - $report->getNumTestedMethods(), - $report->getNumMethods() - ); - $colors['lines'] = $this->getCoverageColor( - $report->getNumExecutedLines(), - $report->getNumExecutableLines() - ); - $colors['reset'] = $this->colors['reset']; - $colors['header'] = $this->colors['header']; - $colors['eol'] = $this->colors['eol']; - } - - $output .= PHP_EOL . PHP_EOL . - $colors['header'] . 'Code Coverage Report '; - - if ($this->showOnlySummary) { - $output .= 'Summary: ' . PHP_EOL; - } else { - $output .= PHP_EOL . - date(' Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . - PHP_EOL . PHP_EOL . - ' Summary: '; - } - - $output .= PHP_EOL . $colors['reset'] - . $colors['classes'] . $colors['eol'] . ' Classes: ' . PHP_CodeCoverage_Util::percent($report->getNumTestedClassesAndTraits(), $report->getNumClassesAndTraits(), TRUE) - . ' (' . $report->getNumTestedClassesAndTraits() . '/' . $report->getNumClassesAndTraits() . ')' . PHP_EOL . $colors ['eol'] - . $colors['methods'] . $colors['eol'] . ' Methods: ' . PHP_CodeCoverage_Util::percent($report->getNumTestedMethods(), $report->getNumMethods(), TRUE) - . ' (' . $report->getNumTestedMethods() . '/' . $report->getNumMethods() . ')' . PHP_EOL . $colors ['eol'] - . $colors['lines'] . $colors['eol'] . ' Lines: ' . PHP_CodeCoverage_Util::percent($report->getNumExecutedLines(), $report->getNumExecutableLines(), TRUE) - . ' (' . $report->getNumExecutedLines() . '/' . $report->getNumExecutableLines() . ')' . PHP_EOL . $colors['reset'] . $colors ['eol']; - - if ($this->showOnlySummary) { - return $this->outputStream->write($output . PHP_EOL); - } - - $classCoverage = array(); - - foreach ($report as $item) { - if (!$item instanceof PHP_CodeCoverage_Report_Node_File) { - continue; - } - - $classes = $item->getClassesAndTraits(); - $coverage = $item->getCoverageData(); - $lines = array(); - - foreach ($classes as $className => $class) { - $classStatements = 0; - $coveredClassStatements = 0; - $coveredMethods = 0; - - foreach ($class['methods'] as $method) { - $methodCount = 0; - $methodLines = 0; - $methodLinesCovered = 0; - - for ($i = $method['startLine']; - $i <= $method['endLine']; - $i++) { - $add = TRUE; - $count = 0; - - if (isset($coverage[$i])) { - if ($coverage[$i] !== NULL) { - $classStatements++; - $methodLines++; - } else { - $add = FALSE; - } - - $count = count($coverage[$i]); - - if ($count > 0) { - $coveredClassStatements++; - $methodLinesCovered++; - } - } else { - $add = FALSE; - } - - $methodCount = max($methodCount, $count); - - if ($add) { - $lines[$i] = array( - 'count' => $count, 'type' => 'stmt' - ); - } - } - - if ($methodCount > 0) { - $coveredMethods++; - } - - } - - if (!empty($class['package']['namespace'])) { - $namespace = '\\' . $class['package']['namespace'] . '::'; - } - - else if (!empty($class['package']['fullPackage'])) { - $namespace = '@' . $class['package']['fullPackage'] . '::'; - } - - else { - $namespace = ''; - } - - $classCoverage[$namespace . $className] = array( - 'namespace' => $namespace, - 'className ' => $className, - 'methodsCovered' => $coveredMethods, - 'methodCount' => count($class['methods']), - 'statementsCovered' => $coveredClassStatements, - 'statementCount' => $classStatements, - ); - } - } - - ksort($classCoverage); - - $methodColor = ''; - $linesColor = ''; - $resetColor = ''; - - foreach ($classCoverage as $fullQualifiedPath => $classInfo) { - if ($classInfo['statementsCovered'] != 0 || - $this->showUncoveredFiles) { - - if ($showColors) { - $methodColor = $this->getCoverageColor($classInfo['methodsCovered'], $classInfo['methodCount']); - $linesColor = $this->getCoverageColor($classInfo['statementsCovered'], $classInfo['statementCount']); - $resetColor = $colors['reset']; - } - - $output .= PHP_EOL . $fullQualifiedPath . PHP_EOL - . ' ' . $methodColor . 'Methods: ' . $this->printCoverageCounts($classInfo['methodsCovered'], $classInfo['methodCount'], 2) . $resetColor . ' ' - . ' ' . $linesColor . 'Lines: ' . $this->printCoverageCounts($classInfo['statementsCovered'], $classInfo['statementCount'], 3) . $resetColor - ; - } - } - - $this->outputStream->write($output . PHP_EOL); - } - - protected function getCoverageColor($numberOfCoveredElements, $totalNumberOfElements) - { - $coverage = PHP_CodeCoverage_Util::percent( - $numberOfCoveredElements, $totalNumberOfElements - ); - - if ($coverage > $this->highLowerBound) { - return $this->colors['green']; - } - - else if ($coverage > $this->lowUpperBound) { - return $this->colors['yellow']; - } - - return $this->colors['red']; - } - - protected function printCoverageCounts($numberOfCoveredElements, $totalNumberOfElements, $presicion) - { - $format = '%' . $presicion . 's'; - - return PHP_CodeCoverage_Util::percent( - $numberOfCoveredElements, $totalNumberOfElements, TRUE, TRUE - ) . - ' (' . sprintf($format, $numberOfCoveredElements) . '/' . - sprintf($format, $totalNumberOfElements) . ')'; - } + protected $outputStream; + protected $lowUpperBound; + protected $highLowerBound; + protected $showUncoveredFiles; + protected $showOnlySummary; + + protected $colors = array( + 'green' => "\x1b[30;42m", + 'yellow' => "\x1b[30;43m", + 'red' => "\x1b[37;41m", + 'header' => "\x1b[47;40m", + 'reset' => "\x1b[0m", + 'eol' => "\x1b[2K", + ); + + public function __construct(PHPUnit_Util_Printer $outputStream, $lowUpperBound, $highLowerBound, $showUncoveredFiles, $showOnlySummary) + { + $this->outputStream = $outputStream; + $this->lowUpperBound = $lowUpperBound; + $this->highLowerBound = $highLowerBound; + $this->showUncoveredFiles = $showUncoveredFiles; + $this->showOnlySummary = $showOnlySummary; + } + + /** + * @param PHP_CodeCoverage $coverage + * @param bool $showColors + * @return string + */ + public function process(PHP_CodeCoverage $coverage, $showColors = FALSE) + { + $output = ''; + $report = $coverage->getReport(); + unset($coverage); + + $colors = array( + 'header' => '', + 'classes' => '', + 'methods' => '', + 'lines' => '', + 'reset' => '', + 'eol' => '' + ); + + if ($showColors) { + $colors['classes'] = $this->getCoverageColor( + $report->getNumTestedClassesAndTraits(), + $report->getNumClassesAndTraits() + ); + $colors['methods'] = $this->getCoverageColor( + $report->getNumTestedMethods(), + $report->getNumMethods() + ); + $colors['lines'] = $this->getCoverageColor( + $report->getNumExecutedLines(), + $report->getNumExecutableLines() + ); + $colors['reset'] = $this->colors['reset']; + $colors['header'] = $this->colors['header']; + $colors['eol'] = $this->colors['eol']; + } + + $output .= PHP_EOL . PHP_EOL . + $colors['header'] . 'Code Coverage Report '; + + if ($this->showOnlySummary) { + $output .= 'Summary: ' . PHP_EOL; + } else { + $output .= PHP_EOL . + date(' Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . + PHP_EOL . PHP_EOL . + ' Summary: '; + } + + $output .= PHP_EOL . $colors['reset'] + . $colors['classes'] . $colors['eol'] . ' Classes: ' . PHP_CodeCoverage_Util::percent($report->getNumTestedClassesAndTraits(), $report->getNumClassesAndTraits(), TRUE) + . ' (' . $report->getNumTestedClassesAndTraits() . '/' . $report->getNumClassesAndTraits() . ')' . PHP_EOL . $colors ['eol'] + . $colors['methods'] . $colors['eol'] . ' Methods: ' . PHP_CodeCoverage_Util::percent($report->getNumTestedMethods(), $report->getNumMethods(), TRUE) + . ' (' . $report->getNumTestedMethods() . '/' . $report->getNumMethods() . ')' . PHP_EOL . $colors ['eol'] + . $colors['lines'] . $colors['eol'] . ' Lines: ' . PHP_CodeCoverage_Util::percent($report->getNumExecutedLines(), $report->getNumExecutableLines(), TRUE) + . ' (' . $report->getNumExecutedLines() . '/' . $report->getNumExecutableLines() . ')' . PHP_EOL . $colors['reset'] . $colors ['eol']; + + if ($this->showOnlySummary) { + return $this->outputStream->write($output . PHP_EOL); + } + + $classCoverage = array(); + + foreach ($report as $item) { + if (!$item instanceof PHP_CodeCoverage_Report_Node_File) { + continue; + } + + $classes = $item->getClassesAndTraits(); + $coverage = $item->getCoverageData(); + $lines = array(); + + foreach ($classes as $className => $class) { + $classStatements = 0; + $coveredClassStatements = 0; + $coveredMethods = 0; + + foreach ($class['methods'] as $method) { + $methodCount = 0; + $methodLines = 0; + $methodLinesCovered = 0; + + for ($i = $method['startLine']; + $i <= $method['endLine']; + $i++) { + $add = TRUE; + $count = 0; + + if (isset($coverage[$i])) { + if ($coverage[$i] !== NULL) { + $classStatements++; + $methodLines++; + } else { + $add = FALSE; + } + + $count = count($coverage[$i]); + + if ($count > 0) { + $coveredClassStatements++; + $methodLinesCovered++; + } + } else { + $add = FALSE; + } + + $methodCount = max($methodCount, $count); + + if ($add) { + $lines[$i] = array( + 'count' => $count, 'type' => 'stmt' + ); + } + } + + if ($methodCount > 0) { + $coveredMethods++; + } + + } + + if (!empty($class['package']['namespace'])) { + $namespace = '\\' . $class['package']['namespace'] . '::'; + } + + else if (!empty($class['package']['fullPackage'])) { + $namespace = '@' . $class['package']['fullPackage'] . '::'; + } + + else { + $namespace = ''; + } + + $classCoverage[$namespace . $className] = array( + 'namespace' => $namespace, + 'className ' => $className, + 'methodsCovered' => $coveredMethods, + 'methodCount' => count($class['methods']), + 'statementsCovered' => $coveredClassStatements, + 'statementCount' => $classStatements, + ); + } + } + + ksort($classCoverage); + + $methodColor = ''; + $linesColor = ''; + $resetColor = ''; + + foreach ($classCoverage as $fullQualifiedPath => $classInfo) { + if ($classInfo['statementsCovered'] != 0 || + $this->showUncoveredFiles) { + + if ($showColors) { + $methodColor = $this->getCoverageColor($classInfo['methodsCovered'], $classInfo['methodCount']); + $linesColor = $this->getCoverageColor($classInfo['statementsCovered'], $classInfo['statementCount']); + $resetColor = $colors['reset']; + } + + $output .= PHP_EOL . $fullQualifiedPath . PHP_EOL + . ' ' . $methodColor . 'Methods: ' . $this->printCoverageCounts($classInfo['methodsCovered'], $classInfo['methodCount'], 2) . $resetColor . ' ' + . ' ' . $linesColor . 'Lines: ' . $this->printCoverageCounts($classInfo['statementsCovered'], $classInfo['statementCount'], 3) . $resetColor + ; + } + } + + $this->outputStream->write($output . PHP_EOL); + } + + protected function getCoverageColor($numberOfCoveredElements, $totalNumberOfElements) + { + $coverage = PHP_CodeCoverage_Util::percent( + $numberOfCoveredElements, $totalNumberOfElements + ); + + if ($coverage > $this->highLowerBound) { + return $this->colors['green']; + } + + else if ($coverage > $this->lowUpperBound) { + return $this->colors['yellow']; + } + + return $this->colors['red']; + } + + protected function printCoverageCounts($numberOfCoveredElements, $totalNumberOfElements, $presicion) + { + $format = '%' . $presicion . 's'; + + return PHP_CodeCoverage_Util::percent( + $numberOfCoveredElements, $totalNumberOfElements, TRUE, TRUE + ) . + ' (' . sprintf($format, $numberOfCoveredElements) . '/' . + sprintf($format, $totalNumberOfElements) . ')'; + } } diff --git a/PHP/CodeCoverage/Util.php b/PHP/CodeCoverage/Util.php index 4e1897475..36766527e 100644 --- a/PHP/CodeCoverage/Util.php +++ b/PHP/CodeCoverage/Util.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,53 +34,53 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.0.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.0.0 */ /** * Utility methods. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.0.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.0.0 */ class PHP_CodeCoverage_Util { - /** - * @param float $a - * @param float $b - * @return float ($a / $b) * 100 - */ - public static function percent($a, $b, $asString = FALSE, $fixedWidth = FALSE) - { - if ($asString && $b == 0) { - return ''; - } + /** + * @param float $a + * @param float $b + * @return float ($a / $b) * 100 + */ + public static function percent($a, $b, $asString = FALSE, $fixedWidth = FALSE) + { + if ($asString && $b == 0) { + return ''; + } - if ($b > 0) { - $percent = ($a / $b) * 100; - } else { - $percent = 100; - } + if ($b > 0) { + $percent = ($a / $b) * 100; + } else { + $percent = 100; + } - if ($asString) { - if ($fixedWidth) { - return sprintf('%6.2F%%', $percent); - } + if ($asString) { + if ($fixedWidth) { + return sprintf('%6.2F%%', $percent); + } - return sprintf('%01.2F%%', $percent); - } else { - return $percent; - } - } + return sprintf('%01.2F%%', $percent); + } else { + return $percent; + } + } } diff --git a/PHP/CodeCoverage/Util/InvalidArgumentHelper.php b/PHP/CodeCoverage/Util/InvalidArgumentHelper.php index e76f90fb1..0abcfe29b 100644 --- a/PHP/CodeCoverage/Util/InvalidArgumentHelper.php +++ b/PHP/CodeCoverage/Util/InvalidArgumentHelper.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,47 +34,47 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.2.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.2.0 */ /** * Factory for PHP_CodeCoverage_Exception objects that are used to describe * invalid arguments passed to a function or method. * - * @category PHP - * @package CodeCoverage - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.2.0 + * @category PHP + * @package CodeCoverage + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.2.0 */ class PHP_CodeCoverage_Util_InvalidArgumentHelper { - /** - * @param integer $argument - * @param string $type - * @param mixed $value - */ - public static function factory($argument, $type, $value = NULL) - { - $stack = debug_backtrace(FALSE); + /** + * @param integer $argument + * @param string $type + * @param mixed $value + */ + public static function factory($argument, $type, $value = NULL) + { + $stack = debug_backtrace(FALSE); - return new PHP_CodeCoverage_Exception( - sprintf( - 'Argument #%d%sof %s::%s() must be a %s', - $argument, - $value !== NULL ? ' (' . gettype($value) . '#' . $value . ')' : ' (No Value) ', - $stack[1]['class'], - $stack[1]['function'], - $type - ) - ); - } + return new PHP_CodeCoverage_Exception( + sprintf( + 'Argument #%d%sof %s::%s() must be a %s', + $argument, + $value !== NULL ? ' (' . gettype($value) . '#' . $value . ')' : ' (No Value) ', + $stack[1]['class'], + $stack[1]['function'], + $type + ) + ); + } } diff --git a/README.markdown b/README.markdown index fa1cdb94d..7644aecda 100644 --- a/README.markdown +++ b/README.markdown @@ -18,26 +18,26 @@ Depending on your OS distribution and/or your PHP environment, you may need to i The following two commands (which you may have to run as `root`) are all that is required to install PHP_CodeCoverage using the PEAR Installer: - pear config-set auto_discover 1 - pear install pear.phpunit.de/PHP_CodeCoverage + pear config-set auto_discover 1 + pear install pear.phpunit.de/PHP_CodeCoverage After the installation you can find the PHP_CodeCoverage source files inside your local PEAR directory; the path is usually `/usr/lib/php/PHP/CodeCoverage`. Using the PHP_CodeCoverage API ------------------------------ - start(''); + $coverage = new PHP_CodeCoverage; + $coverage->start(''); - // ... + // ... - $coverage->stop(); + $coverage->stop(); - $writer = new PHP_CodeCoverage_Report_Clover; - $writer->process($coverage, '/tmp/clover.xml'); + $writer = new PHP_CodeCoverage_Report_Clover; + $writer->process($coverage, '/tmp/clover.xml'); - $writer = new PHP_CodeCoverage_Report_HTML; - $writer->process($coverage, '/tmp/code-coverage-report'); + $writer = new PHP_CodeCoverage_Report_HTML; + $writer->process($coverage, '/tmp/code-coverage-report'); diff --git a/Tests/PHP/CodeCoverage/FilterTest.php b/Tests/PHP/CodeCoverage/FilterTest.php index f90e518f1..e1a23b7d0 100644 --- a/Tests/PHP/CodeCoverage/FilterTest.php +++ b/Tests/PHP/CodeCoverage/FilterTest.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,265 +34,265 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage + * @category PHP + * @package CodeCoverage * @subpackage Tests - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.0.0 + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.0.0 */ if (!defined('TEST_FILES_PATH')) { - define( - 'TEST_FILES_PATH', - dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . - '_files' . DIRECTORY_SEPARATOR - ); + define( + 'TEST_FILES_PATH', + dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . + '_files' . DIRECTORY_SEPARATOR + ); } /** * Tests for the PHP_CodeCoverage_Filter class. * - * @category PHP - * @package CodeCoverage + * @category PHP + * @package CodeCoverage * @subpackage Tests - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.0.0 + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.0.0 */ class PHP_CodeCoverage_FilterTest extends PHPUnit_Framework_TestCase { - protected $filter; - protected $files; - - protected function setUp() - { - $this->filter = unserialize('O:23:"PHP_CodeCoverage_Filter":0:{}'); - - $this->files = array( - TEST_FILES_PATH . 'BankAccount.php', - TEST_FILES_PATH . 'BankAccountTest.php', - TEST_FILES_PATH . 'CoverageClassExtendedTest.php', - TEST_FILES_PATH . 'CoverageClassTest.php', - TEST_FILES_PATH . 'CoverageFunctionTest.php', - TEST_FILES_PATH . 'CoverageMethodOneLineAnnotationTest.php', - TEST_FILES_PATH . 'CoverageMethodTest.php', - TEST_FILES_PATH . 'CoverageNoneTest.php', - TEST_FILES_PATH . 'CoverageNotPrivateTest.php', - TEST_FILES_PATH . 'CoverageNotProtectedTest.php', - TEST_FILES_PATH . 'CoverageNotPublicTest.php', - TEST_FILES_PATH . 'CoverageNothingTest.php', - TEST_FILES_PATH . 'CoveragePrivateTest.php', - TEST_FILES_PATH . 'CoverageProtectedTest.php', - TEST_FILES_PATH . 'CoveragePublicTest.php', - TEST_FILES_PATH . 'CoverageTwoDefaultClassAnnotations.php', - TEST_FILES_PATH . 'CoveredClass.php', - TEST_FILES_PATH . 'CoveredFunction.php', - TEST_FILES_PATH . 'NamespaceCoverageClassExtendedTest.php', - TEST_FILES_PATH . 'NamespaceCoverageClassTest.php', - TEST_FILES_PATH . 'NamespaceCoverageCoversClassPublicTest.php', - TEST_FILES_PATH . 'NamespaceCoverageCoversClassTest.php', - TEST_FILES_PATH . 'NamespaceCoverageMethodTest.php', - TEST_FILES_PATH . 'NamespaceCoverageNotPrivateTest.php', - TEST_FILES_PATH . 'NamespaceCoverageNotProtectedTest.php', - TEST_FILES_PATH . 'NamespaceCoverageNotPublicTest.php', - TEST_FILES_PATH . 'NamespaceCoveragePrivateTest.php', - TEST_FILES_PATH . 'NamespaceCoverageProtectedTest.php', - TEST_FILES_PATH . 'NamespaceCoveragePublicTest.php', - TEST_FILES_PATH . 'NamespaceCoveredClass.php', - TEST_FILES_PATH . 'NotExistingCoveredElementTest.php', - TEST_FILES_PATH . 'source_with_ignore.php', - TEST_FILES_PATH . 'source_with_namespace.php', - TEST_FILES_PATH . 'source_with_oneline_annotations.php', - TEST_FILES_PATH . 'source_without_ignore.php', - TEST_FILES_PATH . 'source_without_namespace.php' - ); - } - - /** - * @covers PHP_CodeCoverage_Filter::addFileToBlacklist - * @covers PHP_CodeCoverage_Filter::getBlacklist - */ - public function testAddingAFileToTheBlacklistWorks() - { - $this->filter->addFileToBlacklist($this->files[0]); - - $this->assertEquals( - array($this->files[0]), $this->filter->getBlacklist() - ); - } - - /** - * @covers PHP_CodeCoverage_Filter::removeFileFromBlacklist - * @covers PHP_CodeCoverage_Filter::getBlacklist - */ - public function testRemovingAFileFromTheBlacklistWorks() - { - $this->filter->addFileToBlacklist($this->files[0]); - $this->filter->removeFileFromBlacklist($this->files[0]); - - $this->assertEquals(array(), $this->filter->getBlacklist()); - } - - /** - * @covers PHP_CodeCoverage_Filter::addDirectoryToBlacklist - * @covers PHP_CodeCoverage_Filter::getBlacklist - * @depends testAddingAFileToTheBlacklistWorks - */ - public function testAddingADirectoryToTheBlacklistWorks() - { - $this->filter->addDirectoryToBlacklist(TEST_FILES_PATH); - - $blacklist = $this->filter->getBlacklist(); - sort($blacklist); - - $this->assertEquals($this->files, $blacklist); - } - - /** - * @covers PHP_CodeCoverage_Filter::addFilesToBlacklist - * @covers PHP_CodeCoverage_Filter::getBlacklist - */ - public function testAddingFilesToTheBlacklistWorks() - { - $facade = new File_Iterator_Facade; - $files = $facade->getFilesAsArray( - TEST_FILES_PATH, $suffixes = '.php' - ); - - $this->filter->addFilesToBlacklist($files); - - $blacklist = $this->filter->getBlacklist(); - sort($blacklist); - - $this->assertEquals($this->files, $blacklist); - } - - /** - * @covers PHP_CodeCoverage_Filter::removeDirectoryFromBlacklist - * @covers PHP_CodeCoverage_Filter::getBlacklist - * @depends testAddingADirectoryToTheBlacklistWorks - */ - public function testRemovingADirectoryFromTheBlacklistWorks() - { - $this->filter->addDirectoryToBlacklist(TEST_FILES_PATH); - $this->filter->removeDirectoryFromBlacklist(TEST_FILES_PATH); - - $this->assertEquals(array(), $this->filter->getBlacklist()); - } - - /** - * @covers PHP_CodeCoverage_Filter::addFileToWhitelist - * @covers PHP_CodeCoverage_Filter::getWhitelist - */ - public function testAddingAFileToTheWhitelistWorks() - { - $this->filter->addFileToWhitelist($this->files[0]); - - $this->assertEquals( - array($this->files[0]), $this->filter->getWhitelist() - ); - } - - /** - * @covers PHP_CodeCoverage_Filter::removeFileFromWhitelist - * @covers PHP_CodeCoverage_Filter::getWhitelist - */ - public function testRemovingAFileFromTheWhitelistWorks() - { - $this->filter->addFileToWhitelist($this->files[0]); - $this->filter->removeFileFromWhitelist($this->files[0]); - - $this->assertEquals(array(), $this->filter->getWhitelist()); - } - - /** - * @covers PHP_CodeCoverage_Filter::addDirectoryToWhitelist - * @covers PHP_CodeCoverage_Filter::getWhitelist - * @depends testAddingAFileToTheWhitelistWorks - */ - public function testAddingADirectoryToTheWhitelistWorks() - { - $this->filter->addDirectoryToWhitelist(TEST_FILES_PATH); - - $whitelist = $this->filter->getWhitelist(); - sort($whitelist); - - $this->assertEquals($this->files, $whitelist); - } - - /** - * @covers PHP_CodeCoverage_Filter::addFilesToWhitelist - * @covers PHP_CodeCoverage_Filter::getBlacklist - */ - public function testAddingFilesToTheWhitelistWorks() - { - $facade = new File_Iterator_Facade; - $files = $facade->getFilesAsArray( - TEST_FILES_PATH, $suffixes = '.php' - ); - - $this->filter->addFilesToWhitelist($files); - - $whitelist = $this->filter->getWhitelist(); - sort($whitelist); - - $this->assertEquals($this->files, $whitelist); - } - - /** - * @covers PHP_CodeCoverage_Filter::removeDirectoryFromWhitelist - * @covers PHP_CodeCoverage_Filter::getWhitelist - * @depends testAddingADirectoryToTheWhitelistWorks - */ - public function testRemovingADirectoryFromTheWhitelistWorks() - { - $this->filter->addDirectoryToWhitelist(TEST_FILES_PATH); - $this->filter->removeDirectoryFromWhitelist(TEST_FILES_PATH); - - $this->assertEquals(array(), $this->filter->getWhitelist()); - } - - /** - * @covers PHP_CodeCoverage_Filter::isFile - */ - public function testIsFile() - { - $this->assertFalse($this->filter->isFile('eval()\'d code')); - $this->assertFalse($this->filter->isFile('runtime-created function')); - $this->assertFalse($this->filter->isFile('assert code')); - $this->assertFalse($this->filter->isFile('regexp code')); - $this->assertTrue($this->filter->isFile('filename')); - } - - /** - * @covers PHP_CodeCoverage_Filter::isFiltered - */ - public function testBlacklistedFileIsFiltered() - { - $this->filter->addFileToBlacklist($this->files[0]); - $this->assertTrue($this->filter->isFiltered($this->files[0])); - } - - /** - * @covers PHP_CodeCoverage_Filter::isFiltered - */ - public function testWhitelistedFileIsNotFiltered() - { - $this->filter->addFileToWhitelist($this->files[0]); - $this->assertFalse($this->filter->isFiltered($this->files[0])); - } - - /** - * @covers PHP_CodeCoverage_Filter::isFiltered - */ - public function testNotWhitelistedFileIsFiltered() - { - $this->filter->addFileToWhitelist($this->files[0]); - $this->assertTrue($this->filter->isFiltered($this->files[1])); - } + protected $filter; + protected $files; + + protected function setUp() + { + $this->filter = unserialize('O:23:"PHP_CodeCoverage_Filter":0:{}'); + + $this->files = array( + TEST_FILES_PATH . 'BankAccount.php', + TEST_FILES_PATH . 'BankAccountTest.php', + TEST_FILES_PATH . 'CoverageClassExtendedTest.php', + TEST_FILES_PATH . 'CoverageClassTest.php', + TEST_FILES_PATH . 'CoverageFunctionTest.php', + TEST_FILES_PATH . 'CoverageMethodOneLineAnnotationTest.php', + TEST_FILES_PATH . 'CoverageMethodTest.php', + TEST_FILES_PATH . 'CoverageNoneTest.php', + TEST_FILES_PATH . 'CoverageNotPrivateTest.php', + TEST_FILES_PATH . 'CoverageNotProtectedTest.php', + TEST_FILES_PATH . 'CoverageNotPublicTest.php', + TEST_FILES_PATH . 'CoverageNothingTest.php', + TEST_FILES_PATH . 'CoveragePrivateTest.php', + TEST_FILES_PATH . 'CoverageProtectedTest.php', + TEST_FILES_PATH . 'CoveragePublicTest.php', + TEST_FILES_PATH . 'CoverageTwoDefaultClassAnnotations.php', + TEST_FILES_PATH . 'CoveredClass.php', + TEST_FILES_PATH . 'CoveredFunction.php', + TEST_FILES_PATH . 'NamespaceCoverageClassExtendedTest.php', + TEST_FILES_PATH . 'NamespaceCoverageClassTest.php', + TEST_FILES_PATH . 'NamespaceCoverageCoversClassPublicTest.php', + TEST_FILES_PATH . 'NamespaceCoverageCoversClassTest.php', + TEST_FILES_PATH . 'NamespaceCoverageMethodTest.php', + TEST_FILES_PATH . 'NamespaceCoverageNotPrivateTest.php', + TEST_FILES_PATH . 'NamespaceCoverageNotProtectedTest.php', + TEST_FILES_PATH . 'NamespaceCoverageNotPublicTest.php', + TEST_FILES_PATH . 'NamespaceCoveragePrivateTest.php', + TEST_FILES_PATH . 'NamespaceCoverageProtectedTest.php', + TEST_FILES_PATH . 'NamespaceCoveragePublicTest.php', + TEST_FILES_PATH . 'NamespaceCoveredClass.php', + TEST_FILES_PATH . 'NotExistingCoveredElementTest.php', + TEST_FILES_PATH . 'source_with_ignore.php', + TEST_FILES_PATH . 'source_with_namespace.php', + TEST_FILES_PATH . 'source_with_oneline_annotations.php', + TEST_FILES_PATH . 'source_without_ignore.php', + TEST_FILES_PATH . 'source_without_namespace.php' + ); + } + + /** + * @covers PHP_CodeCoverage_Filter::addFileToBlacklist + * @covers PHP_CodeCoverage_Filter::getBlacklist + */ + public function testAddingAFileToTheBlacklistWorks() + { + $this->filter->addFileToBlacklist($this->files[0]); + + $this->assertEquals( + array($this->files[0]), $this->filter->getBlacklist() + ); + } + + /** + * @covers PHP_CodeCoverage_Filter::removeFileFromBlacklist + * @covers PHP_CodeCoverage_Filter::getBlacklist + */ + public function testRemovingAFileFromTheBlacklistWorks() + { + $this->filter->addFileToBlacklist($this->files[0]); + $this->filter->removeFileFromBlacklist($this->files[0]); + + $this->assertEquals(array(), $this->filter->getBlacklist()); + } + + /** + * @covers PHP_CodeCoverage_Filter::addDirectoryToBlacklist + * @covers PHP_CodeCoverage_Filter::getBlacklist + * @depends testAddingAFileToTheBlacklistWorks + */ + public function testAddingADirectoryToTheBlacklistWorks() + { + $this->filter->addDirectoryToBlacklist(TEST_FILES_PATH); + + $blacklist = $this->filter->getBlacklist(); + sort($blacklist); + + $this->assertEquals($this->files, $blacklist); + } + + /** + * @covers PHP_CodeCoverage_Filter::addFilesToBlacklist + * @covers PHP_CodeCoverage_Filter::getBlacklist + */ + public function testAddingFilesToTheBlacklistWorks() + { + $facade = new File_Iterator_Facade; + $files = $facade->getFilesAsArray( + TEST_FILES_PATH, $suffixes = '.php' + ); + + $this->filter->addFilesToBlacklist($files); + + $blacklist = $this->filter->getBlacklist(); + sort($blacklist); + + $this->assertEquals($this->files, $blacklist); + } + + /** + * @covers PHP_CodeCoverage_Filter::removeDirectoryFromBlacklist + * @covers PHP_CodeCoverage_Filter::getBlacklist + * @depends testAddingADirectoryToTheBlacklistWorks + */ + public function testRemovingADirectoryFromTheBlacklistWorks() + { + $this->filter->addDirectoryToBlacklist(TEST_FILES_PATH); + $this->filter->removeDirectoryFromBlacklist(TEST_FILES_PATH); + + $this->assertEquals(array(), $this->filter->getBlacklist()); + } + + /** + * @covers PHP_CodeCoverage_Filter::addFileToWhitelist + * @covers PHP_CodeCoverage_Filter::getWhitelist + */ + public function testAddingAFileToTheWhitelistWorks() + { + $this->filter->addFileToWhitelist($this->files[0]); + + $this->assertEquals( + array($this->files[0]), $this->filter->getWhitelist() + ); + } + + /** + * @covers PHP_CodeCoverage_Filter::removeFileFromWhitelist + * @covers PHP_CodeCoverage_Filter::getWhitelist + */ + public function testRemovingAFileFromTheWhitelistWorks() + { + $this->filter->addFileToWhitelist($this->files[0]); + $this->filter->removeFileFromWhitelist($this->files[0]); + + $this->assertEquals(array(), $this->filter->getWhitelist()); + } + + /** + * @covers PHP_CodeCoverage_Filter::addDirectoryToWhitelist + * @covers PHP_CodeCoverage_Filter::getWhitelist + * @depends testAddingAFileToTheWhitelistWorks + */ + public function testAddingADirectoryToTheWhitelistWorks() + { + $this->filter->addDirectoryToWhitelist(TEST_FILES_PATH); + + $whitelist = $this->filter->getWhitelist(); + sort($whitelist); + + $this->assertEquals($this->files, $whitelist); + } + + /** + * @covers PHP_CodeCoverage_Filter::addFilesToWhitelist + * @covers PHP_CodeCoverage_Filter::getBlacklist + */ + public function testAddingFilesToTheWhitelistWorks() + { + $facade = new File_Iterator_Facade; + $files = $facade->getFilesAsArray( + TEST_FILES_PATH, $suffixes = '.php' + ); + + $this->filter->addFilesToWhitelist($files); + + $whitelist = $this->filter->getWhitelist(); + sort($whitelist); + + $this->assertEquals($this->files, $whitelist); + } + + /** + * @covers PHP_CodeCoverage_Filter::removeDirectoryFromWhitelist + * @covers PHP_CodeCoverage_Filter::getWhitelist + * @depends testAddingADirectoryToTheWhitelistWorks + */ + public function testRemovingADirectoryFromTheWhitelistWorks() + { + $this->filter->addDirectoryToWhitelist(TEST_FILES_PATH); + $this->filter->removeDirectoryFromWhitelist(TEST_FILES_PATH); + + $this->assertEquals(array(), $this->filter->getWhitelist()); + } + + /** + * @covers PHP_CodeCoverage_Filter::isFile + */ + public function testIsFile() + { + $this->assertFalse($this->filter->isFile('eval()\'d code')); + $this->assertFalse($this->filter->isFile('runtime-created function')); + $this->assertFalse($this->filter->isFile('assert code')); + $this->assertFalse($this->filter->isFile('regexp code')); + $this->assertTrue($this->filter->isFile('filename')); + } + + /** + * @covers PHP_CodeCoverage_Filter::isFiltered + */ + public function testBlacklistedFileIsFiltered() + { + $this->filter->addFileToBlacklist($this->files[0]); + $this->assertTrue($this->filter->isFiltered($this->files[0])); + } + + /** + * @covers PHP_CodeCoverage_Filter::isFiltered + */ + public function testWhitelistedFileIsNotFiltered() + { + $this->filter->addFileToWhitelist($this->files[0]); + $this->assertFalse($this->filter->isFiltered($this->files[0])); + } + + /** + * @covers PHP_CodeCoverage_Filter::isFiltered + */ + public function testNotWhitelistedFileIsFiltered() + { + $this->filter->addFileToWhitelist($this->files[0]); + $this->assertTrue($this->filter->isFiltered($this->files[1])); + } } diff --git a/Tests/PHP/CodeCoverage/Report/CloverTest.php b/Tests/PHP/CodeCoverage/Report/CloverTest.php index 1008ebced..c90049380 100644 --- a/Tests/PHP/CodeCoverage/Report/CloverTest.php +++ b/Tests/PHP/CodeCoverage/Report/CloverTest.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,22 +34,22 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage + * @category PHP + * @package CodeCoverage * @subpackage Tests - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.0.0 + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.0.0 */ if (!defined('TEST_FILES_PATH')) { - define( - 'TEST_FILES_PATH', - dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . - '_files' . DIRECTORY_SEPARATOR - ); + define( + 'TEST_FILES_PATH', + dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . + '_files' . DIRECTORY_SEPARATOR + ); } require_once TEST_FILES_PATH . '../TestCase.php'; @@ -57,40 +57,40 @@ /** * Tests for the PHP_CodeCoverage_Report_Clover class. * - * @category PHP - * @package CodeCoverage + * @category PHP + * @package CodeCoverage * @subpackage Tests - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.0.0 + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.0.0 */ class PHP_CodeCoverage_Report_CloverTest extends PHP_CodeCoverage_TestCase { - /** - * @covers PHP_CodeCoverage_Report_Clover - */ - public function testCloverForBankAccountTest() - { - $clover = new PHP_CodeCoverage_Report_Clover; + /** + * @covers PHP_CodeCoverage_Report_Clover + */ + public function testCloverForBankAccountTest() + { + $clover = new PHP_CodeCoverage_Report_Clover; - $this->assertStringMatchesFormatFile( - TEST_FILES_PATH . 'BankAccount-clover.xml', - $clover->process($this->getCoverageForBankAccount(), NULL, 'BankAccount') - ); - } + $this->assertStringMatchesFormatFile( + TEST_FILES_PATH . 'BankAccount-clover.xml', + $clover->process($this->getCoverageForBankAccount(), NULL, 'BankAccount') + ); + } - /** - * @covers PHP_CodeCoverage_Report_Clover - */ - public function testCloverForFileWithIgnoredLines() - { - $clover = new PHP_CodeCoverage_Report_Clover; + /** + * @covers PHP_CodeCoverage_Report_Clover + */ + public function testCloverForFileWithIgnoredLines() + { + $clover = new PHP_CodeCoverage_Report_Clover; - $this->assertStringMatchesFormatFile( - TEST_FILES_PATH . 'ignored-lines-clover.xml', - $clover->process($this->getCoverageForFileWithIgnoredLines()) - ); - } + $this->assertStringMatchesFormatFile( + TEST_FILES_PATH . 'ignored-lines-clover.xml', + $clover->process($this->getCoverageForFileWithIgnoredLines()) + ); + } } diff --git a/Tests/PHP/CodeCoverage/Report/FactoryTest.php b/Tests/PHP/CodeCoverage/Report/FactoryTest.php index 4ff2c09a5..8a65c8632 100644 --- a/Tests/PHP/CodeCoverage/Report/FactoryTest.php +++ b/Tests/PHP/CodeCoverage/Report/FactoryTest.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,22 +34,22 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage + * @category PHP + * @package CodeCoverage * @subpackage Tests - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.1.0 + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.1.0 */ if (!defined('TEST_FILES_PATH')) { - define( - 'TEST_FILES_PATH', - dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . - '_files' . DIRECTORY_SEPARATOR - ); + define( + 'TEST_FILES_PATH', + dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . + '_files' . DIRECTORY_SEPARATOR + ); } require_once TEST_FILES_PATH . '../TestCase.php'; @@ -57,207 +57,207 @@ /** * Tests for the PHP_CodeCoverage_Report_Factory class. * - * @category PHP - * @package CodeCoverage + * @category PHP + * @package CodeCoverage * @subpackage Tests - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.1.0 + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.1.0 */ class PHP_CodeCoverage_Report_FactoryTest extends PHP_CodeCoverage_TestCase { - protected $factory; + protected $factory; - protected function setUp() - { - $this->factory = new PHP_CodeCoverage_Report_Factory; - } + protected function setUp() + { + $this->factory = new PHP_CodeCoverage_Report_Factory; + } - public function testSomething() - { - $root = $this->getCoverageForBankAccount()->getReport(); + public function testSomething() + { + $root = $this->getCoverageForBankAccount()->getReport(); - $expectedPath = rtrim(TEST_FILES_PATH, DIRECTORY_SEPARATOR); - $this->assertEquals($expectedPath, $root->getName()); - $this->assertEquals($expectedPath, $root->getPath()); - $this->assertEquals(10, $root->getNumExecutableLines()); - $this->assertEquals(5, $root->getNumExecutedLines()); - $this->assertEquals(1, $root->getNumClasses()); - $this->assertEquals(0, $root->getNumTestedClasses()); - $this->assertEquals(4, $root->getNumMethods()); - $this->assertEquals(3, $root->getNumTestedMethods()); - $this->assertEquals('0.00%', $root->getTestedClassesPercent()); - $this->assertEquals('75.00%', $root->getTestedMethodsPercent()); - $this->assertEquals('50.00%', $root->getLineExecutedPercent()); - $this->assertEquals(0, $root->getNumFunctions()); - $this->assertEquals(0, $root->getNumTestedFunctions()); - $this->assertNull($root->getParent()); - $this->assertEquals(array(), $root->getDirectories()); - #$this->assertEquals(array(), $root->getFiles()); - #$this->assertEquals(array(), $root->getChildNodes()); + $expectedPath = rtrim(TEST_FILES_PATH, DIRECTORY_SEPARATOR); + $this->assertEquals($expectedPath, $root->getName()); + $this->assertEquals($expectedPath, $root->getPath()); + $this->assertEquals(10, $root->getNumExecutableLines()); + $this->assertEquals(5, $root->getNumExecutedLines()); + $this->assertEquals(1, $root->getNumClasses()); + $this->assertEquals(0, $root->getNumTestedClasses()); + $this->assertEquals(4, $root->getNumMethods()); + $this->assertEquals(3, $root->getNumTestedMethods()); + $this->assertEquals('0.00%', $root->getTestedClassesPercent()); + $this->assertEquals('75.00%', $root->getTestedMethodsPercent()); + $this->assertEquals('50.00%', $root->getLineExecutedPercent()); + $this->assertEquals(0, $root->getNumFunctions()); + $this->assertEquals(0, $root->getNumTestedFunctions()); + $this->assertNull($root->getParent()); + $this->assertEquals(array(), $root->getDirectories()); + #$this->assertEquals(array(), $root->getFiles()); + #$this->assertEquals(array(), $root->getChildNodes()); - $this->assertEquals( - array( - 'BankAccount' => array( - 'methods' => array( - 'getBalance' => array( - 'signature' => 'getBalance()', - 'startLine' => 6, - 'endLine' => 9, - 'executableLines' => 1, - 'executedLines' => 1, - 'ccn' => 1, - 'coverage' => 100, - 'crap' => '1', - 'link' => 'BankAccount.php.html#6', - 'methodName' => 'getBalance' - ), - 'setBalance' => array( - 'signature' => 'setBalance($balance)', - 'startLine' => 11, - 'endLine' => 18, - 'executableLines' => 5, - 'executedLines' => 0, - 'ccn' => 2, - 'coverage' => 0, - 'crap' => 6, - 'link' => 'BankAccount.php.html#11', - 'methodName' => 'setBalance' - ), - 'depositMoney' => array( - 'signature' => 'depositMoney($balance)', - 'startLine' => 20, - 'endLine' => 25, - 'executableLines' => 2, - 'executedLines' => 2, - 'ccn' => 1, - 'coverage' => 100, - 'crap' => '1', - 'link' => 'BankAccount.php.html#20', - 'methodName' => 'depositMoney' - ), - 'withdrawMoney' => array( - 'signature' => 'withdrawMoney($balance)', - 'startLine' => 27, - 'endLine' => 32, - 'executableLines' => 2, - 'executedLines' => 2, - 'ccn' => 1, - 'coverage' => 100, - 'crap' => '1', - 'link' => 'BankAccount.php.html#27', - 'methodName' => 'withdrawMoney' - ), - ), - 'startLine' => 2, - 'executableLines' => 10, - 'executedLines' => 5, - 'ccn' => 5, - 'coverage' => 50, - 'crap' => '8.12', - 'package' => array( - 'namespace' => '', - 'fullPackage' => '', - 'category' => '', - 'package' => '', - 'subpackage' => '' - ), - 'link' => 'BankAccount.php.html#2', - 'className' => 'BankAccount' - ) - ), - $root->getClasses() - ); + $this->assertEquals( + array( + 'BankAccount' => array( + 'methods' => array( + 'getBalance' => array( + 'signature' => 'getBalance()', + 'startLine' => 6, + 'endLine' => 9, + 'executableLines' => 1, + 'executedLines' => 1, + 'ccn' => 1, + 'coverage' => 100, + 'crap' => '1', + 'link' => 'BankAccount.php.html#6', + 'methodName' => 'getBalance' + ), + 'setBalance' => array( + 'signature' => 'setBalance($balance)', + 'startLine' => 11, + 'endLine' => 18, + 'executableLines' => 5, + 'executedLines' => 0, + 'ccn' => 2, + 'coverage' => 0, + 'crap' => 6, + 'link' => 'BankAccount.php.html#11', + 'methodName' => 'setBalance' + ), + 'depositMoney' => array( + 'signature' => 'depositMoney($balance)', + 'startLine' => 20, + 'endLine' => 25, + 'executableLines' => 2, + 'executedLines' => 2, + 'ccn' => 1, + 'coverage' => 100, + 'crap' => '1', + 'link' => 'BankAccount.php.html#20', + 'methodName' => 'depositMoney' + ), + 'withdrawMoney' => array( + 'signature' => 'withdrawMoney($balance)', + 'startLine' => 27, + 'endLine' => 32, + 'executableLines' => 2, + 'executedLines' => 2, + 'ccn' => 1, + 'coverage' => 100, + 'crap' => '1', + 'link' => 'BankAccount.php.html#27', + 'methodName' => 'withdrawMoney' + ), + ), + 'startLine' => 2, + 'executableLines' => 10, + 'executedLines' => 5, + 'ccn' => 5, + 'coverage' => 50, + 'crap' => '8.12', + 'package' => array( + 'namespace' => '', + 'fullPackage' => '', + 'category' => '', + 'package' => '', + 'subpackage' => '' + ), + 'link' => 'BankAccount.php.html#2', + 'className' => 'BankAccount' + ) + ), + $root->getClasses() + ); - $this->assertEquals(array(), $root->getFunctions()); - } + $this->assertEquals(array(), $root->getFunctions()); + } - /** - * @covers PHP_CodeCoverage_Report_Factory::buildDirectoryStructure - */ - public function testBuildDirectoryStructure() - { - $method = new ReflectionMethod( - 'PHP_CodeCoverage_Report_Factory', 'buildDirectoryStructure' - ); + /** + * @covers PHP_CodeCoverage_Report_Factory::buildDirectoryStructure + */ + public function testBuildDirectoryStructure() + { + $method = new ReflectionMethod( + 'PHP_CodeCoverage_Report_Factory', 'buildDirectoryStructure' + ); - $method->setAccessible(TRUE); + $method->setAccessible(TRUE); - $this->assertEquals( - array( - 'src' => array( - 'Money.php/f' => array(), - 'MoneyBag.php/f' => array() - ) - ), - $method->invoke( - $this->factory, - array('src/Money.php' => array(), 'src/MoneyBag.php' => array()) - ) - ); - } + $this->assertEquals( + array( + 'src' => array( + 'Money.php/f' => array(), + 'MoneyBag.php/f' => array() + ) + ), + $method->invoke( + $this->factory, + array('src/Money.php' => array(), 'src/MoneyBag.php' => array()) + ) + ); + } - /** - * @covers PHP_CodeCoverage_Report_Factory::reducePaths - * @dataProvider reducePathsProvider - */ - public function testReducePaths($reducedPaths, $commonPath, $paths) - { - $method = new ReflectionMethod( - 'PHP_CodeCoverage_Report_Factory', 'reducePaths' - ); + /** + * @covers PHP_CodeCoverage_Report_Factory::reducePaths + * @dataProvider reducePathsProvider + */ + public function testReducePaths($reducedPaths, $commonPath, $paths) + { + $method = new ReflectionMethod( + 'PHP_CodeCoverage_Report_Factory', 'reducePaths' + ); - $method->setAccessible(TRUE); + $method->setAccessible(TRUE); - $_commonPath = $method->invokeArgs($this->factory, array(&$paths)); + $_commonPath = $method->invokeArgs($this->factory, array(&$paths)); - $this->assertEquals($reducedPaths, $paths); - $this->assertEquals($commonPath, $_commonPath); - } + $this->assertEquals($reducedPaths, $paths); + $this->assertEquals($commonPath, $_commonPath); + } - public function reducePathsProvider() - { - return array( - array( - array( - 'Money.php' => array(), - 'MoneyBag.php' => array() - ), - '/home/sb/Money', - array( - '/home/sb/Money/Money.php' => array(), - '/home/sb/Money/MoneyBag.php' => array() - ) - ), - array( - array( - 'Money.php' => array() - ), - '/home/sb/Money/', - array( - '/home/sb/Money/Money.php' => array() - ) - ), - array( - array(), - '.', - array() - ), - array( - array( - 'Money.php' => array(), - 'MoneyBag.php' => array(), - 'Cash.phar/Cash.php' => array(), - ), - '/home/sb/Money', - array( - '/home/sb/Money/Money.php' => array(), - '/home/sb/Money/MoneyBag.php' => array(), - 'phar:///home/sb/Money/Cash.phar/Cash.php' => array(), - ), - ), - ); - } + public function reducePathsProvider() + { + return array( + array( + array( + 'Money.php' => array(), + 'MoneyBag.php' => array() + ), + '/home/sb/Money', + array( + '/home/sb/Money/Money.php' => array(), + '/home/sb/Money/MoneyBag.php' => array() + ) + ), + array( + array( + 'Money.php' => array() + ), + '/home/sb/Money/', + array( + '/home/sb/Money/Money.php' => array() + ) + ), + array( + array(), + '.', + array() + ), + array( + array( + 'Money.php' => array(), + 'MoneyBag.php' => array(), + 'Cash.phar/Cash.php' => array(), + ), + '/home/sb/Money', + array( + '/home/sb/Money/Money.php' => array(), + '/home/sb/Money/MoneyBag.php' => array(), + 'phar:///home/sb/Money/Cash.phar/Cash.php' => array(), + ), + ), + ); + } } diff --git a/Tests/PHP/CodeCoverage/UtilTest.php b/Tests/PHP/CodeCoverage/UtilTest.php index 85e0b4b7d..970ad7c55 100644 --- a/Tests/PHP/CodeCoverage/UtilTest.php +++ b/Tests/PHP/CodeCoverage/UtilTest.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,39 +34,39 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage + * @category PHP + * @package CodeCoverage * @subpackage Tests - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.0.0 + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.0.0 */ /** * Tests for the PHP_CodeCoverage_Util class. * - * @category PHP - * @package CodeCoverage + * @category PHP + * @package CodeCoverage * @subpackage Tests - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.0.0 + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.0.0 */ class PHP_CodeCoverage_UtilTest extends PHPUnit_Framework_TestCase { - /** - * @covers PHP_CodeCoverage_Util::percent - */ - public function testPercent() - { - $this->assertEquals(100, PHP_CodeCoverage_Util::percent(100, 0)); - $this->assertEquals(100, PHP_CodeCoverage_Util::percent(100, 100)); - $this->assertEquals( - '100.00%', PHP_CodeCoverage_Util::percent(100, 100, TRUE) - ); - } + /** + * @covers PHP_CodeCoverage_Util::percent + */ + public function testPercent() + { + $this->assertEquals(100, PHP_CodeCoverage_Util::percent(100, 0)); + $this->assertEquals(100, PHP_CodeCoverage_Util::percent(100, 100)); + $this->assertEquals( + '100.00%', PHP_CodeCoverage_Util::percent(100, 100, TRUE) + ); + } } diff --git a/Tests/PHP/CodeCoverageTest.php b/Tests/PHP/CodeCoverageTest.php index 99e2f16a8..ad096d817 100644 --- a/Tests/PHP/CodeCoverageTest.php +++ b/Tests/PHP/CodeCoverageTest.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,22 +34,22 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage + * @category PHP + * @package CodeCoverage * @subpackage Tests - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.0.0 + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.0.0 */ if (!defined('TEST_FILES_PATH')) { - define( - 'TEST_FILES_PATH', - dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . - '_files' . DIRECTORY_SEPARATOR - ); + define( + 'TEST_FILES_PATH', + dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . + '_files' . DIRECTORY_SEPARATOR + ); } require_once TEST_FILES_PATH . '../TestCase.php'; @@ -88,539 +88,539 @@ /** * Tests for the PHP_CodeCoverage class. * - * @category PHP - * @package CodeCoverage + * @category PHP + * @package CodeCoverage * @subpackage Tests - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.0.0 + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.0.0 */ class PHP_CodeCoverageTest extends PHP_CodeCoverage_TestCase { - protected $coverage; - protected $getLinesToBeCovered; - protected $getLinesToBeIgnored; - - protected function setUp() - { - $this->coverage = new PHP_CodeCoverage; - - $this->getLinesToBeCovered = new ReflectionMethod( - 'PHP_CodeCoverage', 'getLinesToBeCovered' - ); - - $this->getLinesToBeIgnored = new ReflectionMethod( - 'PHP_CodeCoverage', 'getLinesToBeIgnored' - ); - - $this->getLinesToBeCovered->setAccessible(TRUE); - $this->getLinesToBeIgnored->setAccessible(TRUE); - } - - /** - * @covers PHP_CodeCoverage::__construct - * @covers PHP_CodeCoverage::filter - */ - public function testConstructor() - { - $this->assertAttributeInstanceOf( - 'PHP_CodeCoverage_Driver_Xdebug', 'driver', $this->coverage - ); - - $this->assertAttributeInstanceOf( - 'PHP_CodeCoverage_Filter', 'filter', $this->coverage - ); - } - - /** - * @covers PHP_CodeCoverage::__construct - * @covers PHP_CodeCoverage::filter - */ - public function testConstructor2() - { - $filter = new PHP_CodeCoverage_Filter; - $coverage = new PHP_CodeCoverage(NULL, $filter); - - $this->assertAttributeInstanceOf( - 'PHP_CodeCoverage_Driver_Xdebug', 'driver', $coverage - ); - - $this->assertSame($filter, $coverage->filter()); - } - - /** - * @covers PHP_CodeCoverage::start - * @expectedException PHP_CodeCoverage_Exception - */ - public function testStartThrowsExceptionForInvalidArgument() - { - $this->coverage->start(NULL, array(), NULL); - } - - /** - * @covers PHP_CodeCoverage::stop - * @expectedException PHP_CodeCoverage_Exception - */ - public function testStopThrowsExceptionForInvalidArgument() - { - $this->coverage->stop(NULL); - } - - /** - * @covers PHP_CodeCoverage::append - * @expectedException PHP_CodeCoverage_Exception - */ - public function testAppendThrowsExceptionForInvalidArgument() - { - $this->coverage->append(array(), NULL); - } - - /** - * @covers PHP_CodeCoverage::setCacheTokens - * @expectedException PHP_CodeCoverage_Exception - */ - public function testSetCacheTokensThrowsExceptionForInvalidArgument() - { - $this->coverage->setCacheTokens(NULL); - } - - /** - * @covers PHP_CodeCoverage::setCacheTokens - */ - public function testSetCacheTokens() - { - $this->coverage->setCacheTokens(TRUE); - $this->assertAttributeEquals(TRUE, 'cacheTokens', $this->coverage); - } - - /** - * @covers PHP_CodeCoverage::setForceCoversAnnotation - * @expectedException PHP_CodeCoverage_Exception - */ - public function testSetForceCoversAnnotationThrowsExceptionForInvalidArgument() - { - $this->coverage->setForceCoversAnnotation(NULL); - } - - /** - * @covers PHP_CodeCoverage::setForceCoversAnnotation - */ - public function testSetForceCoversAnnotation() - { - $this->coverage->setForceCoversAnnotation(TRUE); - $this->assertAttributeEquals( - TRUE, 'forceCoversAnnotation', $this->coverage - ); - } - - /** - * @covers PHP_CodeCoverage::setProcessUncoveredFilesFromWhitelist - * @expectedException PHP_CodeCoverage_Exception - */ - public function testSetProcessUncoveredFilesFromWhitelistThrowsExceptionForInvalidArgument() - { - $this->coverage->setProcessUncoveredFilesFromWhitelist(NULL); - } - - /** - * @covers PHP_CodeCoverage::setProcessUncoveredFilesFromWhitelist - */ - public function testSetProcessUncoveredFilesFromWhitelist() - { - $this->coverage->setProcessUncoveredFilesFromWhitelist(TRUE); - $this->assertAttributeEquals( - TRUE, 'processUncoveredFilesFromWhitelist', $this->coverage - ); - } - - /** - * @covers PHP_CodeCoverage::setMapTestClassNameToCoveredClassName - */ - public function testSetMapTestClassNameToCoveredClassName() - { - $this->coverage->setMapTestClassNameToCoveredClassName(TRUE); - $this->assertAttributeEquals( - TRUE, 'mapTestClassNameToCoveredClassName', $this->coverage - ); - } - - /** - * @covers PHP_CodeCoverage::setMapTestClassNameToCoveredClassName - * @expectedException PHP_CodeCoverage_Exception - */ - public function testSetMapTestClassNameToCoveredClassNameThrowsExceptionForInvalidArgument() - { - $this->coverage->setMapTestClassNameToCoveredClassName(NULL); - } - - /** - * @covers PHP_CodeCoverage::clear - */ - public function testClear() - { - $this->coverage->clear(); - - $this->assertAttributeEquals(NULL, 'currentId', $this->coverage); - $this->assertAttributeEquals(array(), 'data', $this->coverage); - $this->assertAttributeEquals(array(), 'tests', $this->coverage); - } - - /** - * Add parenthesis to the covers annotation below in a couple of different ways to make sure it - * works as expected - * - * @covers PHP_CodeCoverage::start() - * @covers PHP_CodeCoverage::stop( ) - * @covers PHP_CodeCoverage::append () - * @covers PHP_CodeCoverage::applyListsFilter ( ) - * @covers PHP_CodeCoverage::initializeFilesThatAreSeenTheFirstTime - * @covers PHP_CodeCoverage::applyCoversAnnotationFilter - * @covers PHP_CodeCoverage::getTests - */ - public function testCollect() - { - $coverage = $this->getCoverageForBankAccount(); - - $this->assertEquals( - $this->getExpectedDataArrayForBankAccount(), $coverage->getData() - ); - - $this->assertEquals( - array( - 'BankAccountTest::testBalanceIsInitiallyZero' => NULL, - 'BankAccountTest::testBalanceCannotBecomeNegative' => NULL, - 'BankAccountTest::testBalanceCannotBecomeNegative2' => NULL, - 'BankAccountTest::testDepositWithdrawMoney' => NULL - ), - $coverage->getTests() - ); - } - - /** - * @covers PHP_CodeCoverage::getData - * @covers PHP_CodeCoverage::merge - */ - public function testMerge() - { - $coverage = $this->getCoverageForBankAccountForFirstTwoTests(); - $coverage->merge($this->getCoverageForBankAccountForLastTwoTests()); - - $this->assertEquals( - $this->getExpectedDataArrayForBankAccount(), $coverage->getData() - ); - } - - /** - * @covers PHP_CodeCoverage::getData - * @covers PHP_CodeCoverage::merge - */ - public function testMerge2() - { - $coverage = new PHP_CodeCoverage( - $this->getMock('PHP_CodeCoverage_Driver_Xdebug'), - new PHP_CodeCoverage_Filter - ); - - $coverage->merge($this->getCoverageForBankAccount()); - - $this->assertEquals( - $this->getExpectedDataArrayForBankAccount(), $coverage->getData() - ); - } - - /** - * @covers PHP_CodeCoverage::getLinesToBeCovered - * @covers PHP_CodeCoverage::resolveCoversToReflectionObjects - * @dataProvider getLinesToBeCoveredProvider - */ - public function testGetLinesToBeCovered($test, $lines) - { - if (strpos($test, 'Namespace') === 0) { - $expected = array( - TEST_FILES_PATH . 'NamespaceCoveredClass.php' => $lines - ); - } - - else if ($test === 'CoverageNoneTest') { - $expected = array(); - } - - else if ($test === 'CoverageNothingTest') { - $expected = false; - } - - else if ($test === 'CoverageFunctionTest') { - $expected = array( - TEST_FILES_PATH . 'CoveredFunction.php' => $lines - ); - } - - else { - $expected = array(TEST_FILES_PATH . 'CoveredClass.php' => $lines); - } - - $this->assertEquals( - $expected, - $this->getLinesToBeCovered->invoke( - $this->coverage, $test, 'testSomething' - ) - ); - } - - /** - * @covers PHP_CodeCoverage::getLinesToBeCovered - * @covers PHP_CodeCoverage::resolveCoversToReflectionObjects - * @expectedException PHP_CodeCoverage_Exception - */ - public function testGetLinesToBeCovered2() - { - $this->getLinesToBeCovered->invoke( - $this->coverage, 'NotExistingCoveredElementTest', 'testOne' - ); - } - - /** - * @covers PHP_CodeCoverage::getLinesToBeCovered - * @covers PHP_CodeCoverage::resolveCoversToReflectionObjects - * @expectedException PHP_CodeCoverage_Exception - */ - public function testGetLinesToBeCovered3() - { - $this->getLinesToBeCovered->invoke( - $this->coverage, 'NotExistingCoveredElementTest', 'testTwo' - ); - } - - /** - * @covers PHP_CodeCoverage::getLinesToBeCovered - * @covers PHP_CodeCoverage::resolveCoversToReflectionObjects - * @expectedException PHP_CodeCoverage_Exception - */ - public function testGetLinesToBeCovered4() - { - $this->getLinesToBeCovered->invoke( - $this->coverage, 'NotExistingCoveredElementTest', 'testThree' - ); - } - - /** - * @covers PHP_CodeCoverage::getLinesToBeCovered - */ - public function testGetLinesToBeCoveredSkipsNonExistantMethods() - { - $this->assertSame( - array(), - $this->getLinesToBeCovered->invoke( - $this->coverage, - 'NotExistingCoveredElementTest', - 'methodDoesNotExist' - ) - ); - } - - /** - * @covers PHP_CodeCoverage::getLinesToBeCovered - * @expectedException PHP_CodeCoverage_Exception - */ - public function testTwoCoversDefaultClassAnnoationsAreNotAllowed() - { - $this->getLinesToBeCovered->invoke( - $this->coverage, - 'CoverageTwoDefaultClassAnnotations', - 'testSomething' - ); - } - - public function getLinesToBeCoveredProvider() - { - return array( - array( - 'CoverageNoneTest', - array() - ), - array( - 'CoverageClassExtendedTest', - array_merge(range(19, 36), range(2, 17)) - ), - array( - 'CoverageClassTest', - range(19, 36) - ), - array( - 'CoverageMethodTest', - range(31, 35) - ), - array( - 'CoverageMethodOneLineAnnotationTest', - range(31, 35) - ), - array( - 'CoverageNotPrivateTest', - array_merge(range(25, 29), range(31, 35)) - ), - array( - 'CoverageNotProtectedTest', - array_merge(range(21, 23), range(31, 35)) - ), - array( - 'CoverageNotPublicTest', - array_merge(range(21, 23), range(25, 29)) - ), - array( - 'CoveragePrivateTest', - range(21, 23) - ), - array( - 'CoverageProtectedTest', - range(25, 29) - ), - array( - 'CoveragePublicTest', - range(31, 35) - ), - array( - 'CoverageFunctionTest', - range(2, 4) - ), - array( - 'NamespaceCoverageClassExtendedTest', - array_merge(range(21, 38), range(4, 19)) - ), - array( - 'NamespaceCoverageClassTest', - range(21, 38) - ), - array( - 'NamespaceCoverageMethodTest', - range(33, 37) - ), - array( - 'NamespaceCoverageNotPrivateTest', - array_merge(range(27, 31), range(33, 37)) - ), - array( - 'NamespaceCoverageNotProtectedTest', - array_merge(range(23, 25), range(33, 37)) - ), - array( - 'NamespaceCoverageNotPublicTest', - array_merge(range(23, 25), range(27, 31)) - ), - array( - 'NamespaceCoveragePrivateTest', - range(23, 25) - ), - array( - 'NamespaceCoverageProtectedTest', - range(27, 31) - ), - array( - 'NamespaceCoveragePublicTest', - range(33, 37) - ), - array( - 'NamespaceCoverageCoversClassTest', - array_merge(range(23, 25), range(27, 31), range(33, 37), range(6, 8), range(10, 13), range(15, 18)) - ), - array( - 'NamespaceCoverageCoversClassPublicTest', - range(33, 37) - ), - array( - 'CoverageNothingTest', - false - ) - ); - } - - /** - * @covers PHP_CodeCoverage::getLinesToBeIgnored - */ - public function testGetLinesToBeIgnored() - { - $this->assertEquals( - array( - 1, - 3, - 4, - 5, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 30, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39 - ), - $this->getLinesToBeIgnored->invoke( - $this->coverage, - TEST_FILES_PATH . 'source_with_ignore.php' - ) - ); - } - - /** - * @covers PHP_CodeCoverage::getLinesToBeIgnored - */ - public function testGetLinesToBeIgnored2() - { - $this->assertEquals( - array(1, 5), - $this->getLinesToBeIgnored->invoke( - $this->coverage, - TEST_FILES_PATH . 'source_without_ignore.php' - ) - ); - } - - /** - * @covers PHP_CodeCoverage::getLinesToBeIgnored - */ - public function testGetLinesToBeIgnoredOneLineAnnotations() - { - $this->assertEquals( - array( - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 13, - 14 - ), - $this->getLinesToBeIgnored->invoke( - $this->coverage, - TEST_FILES_PATH . 'source_with_oneline_annotations.php' - ) - ); - } + protected $coverage; + protected $getLinesToBeCovered; + protected $getLinesToBeIgnored; + + protected function setUp() + { + $this->coverage = new PHP_CodeCoverage; + + $this->getLinesToBeCovered = new ReflectionMethod( + 'PHP_CodeCoverage', 'getLinesToBeCovered' + ); + + $this->getLinesToBeIgnored = new ReflectionMethod( + 'PHP_CodeCoverage', 'getLinesToBeIgnored' + ); + + $this->getLinesToBeCovered->setAccessible(TRUE); + $this->getLinesToBeIgnored->setAccessible(TRUE); + } + + /** + * @covers PHP_CodeCoverage::__construct + * @covers PHP_CodeCoverage::filter + */ + public function testConstructor() + { + $this->assertAttributeInstanceOf( + 'PHP_CodeCoverage_Driver_Xdebug', 'driver', $this->coverage + ); + + $this->assertAttributeInstanceOf( + 'PHP_CodeCoverage_Filter', 'filter', $this->coverage + ); + } + + /** + * @covers PHP_CodeCoverage::__construct + * @covers PHP_CodeCoverage::filter + */ + public function testConstructor2() + { + $filter = new PHP_CodeCoverage_Filter; + $coverage = new PHP_CodeCoverage(NULL, $filter); + + $this->assertAttributeInstanceOf( + 'PHP_CodeCoverage_Driver_Xdebug', 'driver', $coverage + ); + + $this->assertSame($filter, $coverage->filter()); + } + + /** + * @covers PHP_CodeCoverage::start + * @expectedException PHP_CodeCoverage_Exception + */ + public function testStartThrowsExceptionForInvalidArgument() + { + $this->coverage->start(NULL, array(), NULL); + } + + /** + * @covers PHP_CodeCoverage::stop + * @expectedException PHP_CodeCoverage_Exception + */ + public function testStopThrowsExceptionForInvalidArgument() + { + $this->coverage->stop(NULL); + } + + /** + * @covers PHP_CodeCoverage::append + * @expectedException PHP_CodeCoverage_Exception + */ + public function testAppendThrowsExceptionForInvalidArgument() + { + $this->coverage->append(array(), NULL); + } + + /** + * @covers PHP_CodeCoverage::setCacheTokens + * @expectedException PHP_CodeCoverage_Exception + */ + public function testSetCacheTokensThrowsExceptionForInvalidArgument() + { + $this->coverage->setCacheTokens(NULL); + } + + /** + * @covers PHP_CodeCoverage::setCacheTokens + */ + public function testSetCacheTokens() + { + $this->coverage->setCacheTokens(TRUE); + $this->assertAttributeEquals(TRUE, 'cacheTokens', $this->coverage); + } + + /** + * @covers PHP_CodeCoverage::setForceCoversAnnotation + * @expectedException PHP_CodeCoverage_Exception + */ + public function testSetForceCoversAnnotationThrowsExceptionForInvalidArgument() + { + $this->coverage->setForceCoversAnnotation(NULL); + } + + /** + * @covers PHP_CodeCoverage::setForceCoversAnnotation + */ + public function testSetForceCoversAnnotation() + { + $this->coverage->setForceCoversAnnotation(TRUE); + $this->assertAttributeEquals( + TRUE, 'forceCoversAnnotation', $this->coverage + ); + } + + /** + * @covers PHP_CodeCoverage::setProcessUncoveredFilesFromWhitelist + * @expectedException PHP_CodeCoverage_Exception + */ + public function testSetProcessUncoveredFilesFromWhitelistThrowsExceptionForInvalidArgument() + { + $this->coverage->setProcessUncoveredFilesFromWhitelist(NULL); + } + + /** + * @covers PHP_CodeCoverage::setProcessUncoveredFilesFromWhitelist + */ + public function testSetProcessUncoveredFilesFromWhitelist() + { + $this->coverage->setProcessUncoveredFilesFromWhitelist(TRUE); + $this->assertAttributeEquals( + TRUE, 'processUncoveredFilesFromWhitelist', $this->coverage + ); + } + + /** + * @covers PHP_CodeCoverage::setMapTestClassNameToCoveredClassName + */ + public function testSetMapTestClassNameToCoveredClassName() + { + $this->coverage->setMapTestClassNameToCoveredClassName(TRUE); + $this->assertAttributeEquals( + TRUE, 'mapTestClassNameToCoveredClassName', $this->coverage + ); + } + + /** + * @covers PHP_CodeCoverage::setMapTestClassNameToCoveredClassName + * @expectedException PHP_CodeCoverage_Exception + */ + public function testSetMapTestClassNameToCoveredClassNameThrowsExceptionForInvalidArgument() + { + $this->coverage->setMapTestClassNameToCoveredClassName(NULL); + } + + /** + * @covers PHP_CodeCoverage::clear + */ + public function testClear() + { + $this->coverage->clear(); + + $this->assertAttributeEquals(NULL, 'currentId', $this->coverage); + $this->assertAttributeEquals(array(), 'data', $this->coverage); + $this->assertAttributeEquals(array(), 'tests', $this->coverage); + } + + /** + * Add parenthesis to the covers annotation below in a couple of different ways to make sure it + * works as expected + * + * @covers PHP_CodeCoverage::start() + * @covers PHP_CodeCoverage::stop( ) + * @covers PHP_CodeCoverage::append () + * @covers PHP_CodeCoverage::applyListsFilter ( ) + * @covers PHP_CodeCoverage::initializeFilesThatAreSeenTheFirstTime + * @covers PHP_CodeCoverage::applyCoversAnnotationFilter + * @covers PHP_CodeCoverage::getTests + */ + public function testCollect() + { + $coverage = $this->getCoverageForBankAccount(); + + $this->assertEquals( + $this->getExpectedDataArrayForBankAccount(), $coverage->getData() + ); + + $this->assertEquals( + array( + 'BankAccountTest::testBalanceIsInitiallyZero' => NULL, + 'BankAccountTest::testBalanceCannotBecomeNegative' => NULL, + 'BankAccountTest::testBalanceCannotBecomeNegative2' => NULL, + 'BankAccountTest::testDepositWithdrawMoney' => NULL + ), + $coverage->getTests() + ); + } + + /** + * @covers PHP_CodeCoverage::getData + * @covers PHP_CodeCoverage::merge + */ + public function testMerge() + { + $coverage = $this->getCoverageForBankAccountForFirstTwoTests(); + $coverage->merge($this->getCoverageForBankAccountForLastTwoTests()); + + $this->assertEquals( + $this->getExpectedDataArrayForBankAccount(), $coverage->getData() + ); + } + + /** + * @covers PHP_CodeCoverage::getData + * @covers PHP_CodeCoverage::merge + */ + public function testMerge2() + { + $coverage = new PHP_CodeCoverage( + $this->getMock('PHP_CodeCoverage_Driver_Xdebug'), + new PHP_CodeCoverage_Filter + ); + + $coverage->merge($this->getCoverageForBankAccount()); + + $this->assertEquals( + $this->getExpectedDataArrayForBankAccount(), $coverage->getData() + ); + } + + /** + * @covers PHP_CodeCoverage::getLinesToBeCovered + * @covers PHP_CodeCoverage::resolveCoversToReflectionObjects + * @dataProvider getLinesToBeCoveredProvider + */ + public function testGetLinesToBeCovered($test, $lines) + { + if (strpos($test, 'Namespace') === 0) { + $expected = array( + TEST_FILES_PATH . 'NamespaceCoveredClass.php' => $lines + ); + } + + else if ($test === 'CoverageNoneTest') { + $expected = array(); + } + + else if ($test === 'CoverageNothingTest') { + $expected = false; + } + + else if ($test === 'CoverageFunctionTest') { + $expected = array( + TEST_FILES_PATH . 'CoveredFunction.php' => $lines + ); + } + + else { + $expected = array(TEST_FILES_PATH . 'CoveredClass.php' => $lines); + } + + $this->assertEquals( + $expected, + $this->getLinesToBeCovered->invoke( + $this->coverage, $test, 'testSomething' + ) + ); + } + + /** + * @covers PHP_CodeCoverage::getLinesToBeCovered + * @covers PHP_CodeCoverage::resolveCoversToReflectionObjects + * @expectedException PHP_CodeCoverage_Exception + */ + public function testGetLinesToBeCovered2() + { + $this->getLinesToBeCovered->invoke( + $this->coverage, 'NotExistingCoveredElementTest', 'testOne' + ); + } + + /** + * @covers PHP_CodeCoverage::getLinesToBeCovered + * @covers PHP_CodeCoverage::resolveCoversToReflectionObjects + * @expectedException PHP_CodeCoverage_Exception + */ + public function testGetLinesToBeCovered3() + { + $this->getLinesToBeCovered->invoke( + $this->coverage, 'NotExistingCoveredElementTest', 'testTwo' + ); + } + + /** + * @covers PHP_CodeCoverage::getLinesToBeCovered + * @covers PHP_CodeCoverage::resolveCoversToReflectionObjects + * @expectedException PHP_CodeCoverage_Exception + */ + public function testGetLinesToBeCovered4() + { + $this->getLinesToBeCovered->invoke( + $this->coverage, 'NotExistingCoveredElementTest', 'testThree' + ); + } + + /** + * @covers PHP_CodeCoverage::getLinesToBeCovered + */ + public function testGetLinesToBeCoveredSkipsNonExistantMethods() + { + $this->assertSame( + array(), + $this->getLinesToBeCovered->invoke( + $this->coverage, + 'NotExistingCoveredElementTest', + 'methodDoesNotExist' + ) + ); + } + + /** + * @covers PHP_CodeCoverage::getLinesToBeCovered + * @expectedException PHP_CodeCoverage_Exception + */ + public function testTwoCoversDefaultClassAnnoationsAreNotAllowed() + { + $this->getLinesToBeCovered->invoke( + $this->coverage, + 'CoverageTwoDefaultClassAnnotations', + 'testSomething' + ); + } + + public function getLinesToBeCoveredProvider() + { + return array( + array( + 'CoverageNoneTest', + array() + ), + array( + 'CoverageClassExtendedTest', + array_merge(range(19, 36), range(2, 17)) + ), + array( + 'CoverageClassTest', + range(19, 36) + ), + array( + 'CoverageMethodTest', + range(31, 35) + ), + array( + 'CoverageMethodOneLineAnnotationTest', + range(31, 35) + ), + array( + 'CoverageNotPrivateTest', + array_merge(range(25, 29), range(31, 35)) + ), + array( + 'CoverageNotProtectedTest', + array_merge(range(21, 23), range(31, 35)) + ), + array( + 'CoverageNotPublicTest', + array_merge(range(21, 23), range(25, 29)) + ), + array( + 'CoveragePrivateTest', + range(21, 23) + ), + array( + 'CoverageProtectedTest', + range(25, 29) + ), + array( + 'CoveragePublicTest', + range(31, 35) + ), + array( + 'CoverageFunctionTest', + range(2, 4) + ), + array( + 'NamespaceCoverageClassExtendedTest', + array_merge(range(21, 38), range(4, 19)) + ), + array( + 'NamespaceCoverageClassTest', + range(21, 38) + ), + array( + 'NamespaceCoverageMethodTest', + range(33, 37) + ), + array( + 'NamespaceCoverageNotPrivateTest', + array_merge(range(27, 31), range(33, 37)) + ), + array( + 'NamespaceCoverageNotProtectedTest', + array_merge(range(23, 25), range(33, 37)) + ), + array( + 'NamespaceCoverageNotPublicTest', + array_merge(range(23, 25), range(27, 31)) + ), + array( + 'NamespaceCoveragePrivateTest', + range(23, 25) + ), + array( + 'NamespaceCoverageProtectedTest', + range(27, 31) + ), + array( + 'NamespaceCoveragePublicTest', + range(33, 37) + ), + array( + 'NamespaceCoverageCoversClassTest', + array_merge(range(23, 25), range(27, 31), range(33, 37), range(6, 8), range(10, 13), range(15, 18)) + ), + array( + 'NamespaceCoverageCoversClassPublicTest', + range(33, 37) + ), + array( + 'CoverageNothingTest', + false + ) + ); + } + + /** + * @covers PHP_CodeCoverage::getLinesToBeIgnored + */ + public function testGetLinesToBeIgnored() + { + $this->assertEquals( + array( + 1, + 3, + 4, + 5, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 30, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39 + ), + $this->getLinesToBeIgnored->invoke( + $this->coverage, + TEST_FILES_PATH . 'source_with_ignore.php' + ) + ); + } + + /** + * @covers PHP_CodeCoverage::getLinesToBeIgnored + */ + public function testGetLinesToBeIgnored2() + { + $this->assertEquals( + array(1, 5), + $this->getLinesToBeIgnored->invoke( + $this->coverage, + TEST_FILES_PATH . 'source_without_ignore.php' + ) + ); + } + + /** + * @covers PHP_CodeCoverage::getLinesToBeIgnored + */ + public function testGetLinesToBeIgnoredOneLineAnnotations() + { + $this->assertEquals( + array( + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 13, + 14 + ), + $this->getLinesToBeIgnored->invoke( + $this->coverage, + TEST_FILES_PATH . 'source_with_oneline_annotations.php' + ) + ); + } } diff --git a/Tests/TestCase.php b/Tests/TestCase.php index 6a04513f8..f9b8cd729 100644 --- a/Tests/TestCase.php +++ b/Tests/TestCase.php @@ -9,17 +9,17 @@ * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -34,233 +34,233 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @category PHP - * @package CodeCoverage + * @category PHP + * @package CodeCoverage * @subpackage Tests - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since File available since Release 1.0.0 + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since File available since Release 1.0.0 */ /** * Abstract base class for test case classes. * - * @category PHP - * @package CodeCoverage + * @category PHP + * @package CodeCoverage * @subpackage Tests - * @author Sebastian Bergmann - * @copyright 2009-2013 Sebastian Bergmann - * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License - * @link http://github.com/sebastianbergmann/php-code-coverage - * @since Class available since Release 1.0.0 + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://github.com/sebastianbergmann/php-code-coverage + * @since Class available since Release 1.0.0 */ abstract class PHP_CodeCoverage_TestCase extends PHPUnit_Framework_TestCase { - protected function getXdebugDataForBankAccount() - { - return array( - array( - TEST_FILES_PATH . 'BankAccount.php' => array( - 8 => 1, - 9 => -2, - 13 => -1, - 14 => -1, - 15 => -1, - 16 => -1, - 18 => -1, - 22 => -1, - 24 => -1, - 25 => -2, - 29 => -1, - 31 => -1, - 32 => -2 - ) - ), - array( - TEST_FILES_PATH . 'BankAccount.php' => array( - 8 => 1, - 13 => 1, - 16 => 1, - 29 => 1, - ) - ), - array( - TEST_FILES_PATH . 'BankAccount.php' => array( - 8 => 1, - 13 => 1, - 16 => 1, - 22 => 1, - ) - ), - array( - TEST_FILES_PATH . 'BankAccount.php' => array( - 8 => 1, - 13 => 1, - 14 => 1, - 15 => 1, - 18 => 1, - 22 => 1, - 24 => 1, - 29 => 1, - 31 => 1, - ) - ) - ); - } + protected function getXdebugDataForBankAccount() + { + return array( + array( + TEST_FILES_PATH . 'BankAccount.php' => array( + 8 => 1, + 9 => -2, + 13 => -1, + 14 => -1, + 15 => -1, + 16 => -1, + 18 => -1, + 22 => -1, + 24 => -1, + 25 => -2, + 29 => -1, + 31 => -1, + 32 => -2 + ) + ), + array( + TEST_FILES_PATH . 'BankAccount.php' => array( + 8 => 1, + 13 => 1, + 16 => 1, + 29 => 1, + ) + ), + array( + TEST_FILES_PATH . 'BankAccount.php' => array( + 8 => 1, + 13 => 1, + 16 => 1, + 22 => 1, + ) + ), + array( + TEST_FILES_PATH . 'BankAccount.php' => array( + 8 => 1, + 13 => 1, + 14 => 1, + 15 => 1, + 18 => 1, + 22 => 1, + 24 => 1, + 29 => 1, + 31 => 1, + ) + ) + ); + } - protected function getCoverageForBankAccount() - { - $data = $this->getXdebugDataForBankAccount(); + protected function getCoverageForBankAccount() + { + $data = $this->getXdebugDataForBankAccount(); - $stub = $this->getMock('PHP_CodeCoverage_Driver_Xdebug'); - $stub->expects($this->any()) - ->method('stop') - ->will($this->onConsecutiveCalls( - $data[0], $data[1], $data[2], $data[3] - )); + $stub = $this->getMock('PHP_CodeCoverage_Driver_Xdebug'); + $stub->expects($this->any()) + ->method('stop') + ->will($this->onConsecutiveCalls( + $data[0], $data[1], $data[2], $data[3] + )); - $coverage = new PHP_CodeCoverage($stub, new PHP_CodeCoverage_Filter); + $coverage = new PHP_CodeCoverage($stub, new PHP_CodeCoverage_Filter); - $coverage->start( - new BankAccountTest('testBalanceIsInitiallyZero'), TRUE - ); - $coverage->stop(); + $coverage->start( + new BankAccountTest('testBalanceIsInitiallyZero'), TRUE + ); + $coverage->stop(); - $coverage->start( - new BankAccountTest('testBalanceCannotBecomeNegative') - ); - $coverage->stop(); + $coverage->start( + new BankAccountTest('testBalanceCannotBecomeNegative') + ); + $coverage->stop(); - $coverage->start( - new BankAccountTest('testBalanceCannotBecomeNegative2') - ); - $coverage->stop(); + $coverage->start( + new BankAccountTest('testBalanceCannotBecomeNegative2') + ); + $coverage->stop(); - $coverage->start( - new BankAccountTest('testDepositWithdrawMoney') - ); - $coverage->stop(); + $coverage->start( + new BankAccountTest('testDepositWithdrawMoney') + ); + $coverage->stop(); - return $coverage; - } + return $coverage; + } - protected function getCoverageForBankAccountForFirstTwoTests() - { - $data = $this->getXdebugDataForBankAccount(); + protected function getCoverageForBankAccountForFirstTwoTests() + { + $data = $this->getXdebugDataForBankAccount(); - $stub = $this->getMock('PHP_CodeCoverage_Driver_Xdebug'); - $stub->expects($this->any()) - ->method('stop') - ->will($this->onConsecutiveCalls( - $data[0], $data[1] - )); + $stub = $this->getMock('PHP_CodeCoverage_Driver_Xdebug'); + $stub->expects($this->any()) + ->method('stop') + ->will($this->onConsecutiveCalls( + $data[0], $data[1] + )); - $coverage = new PHP_CodeCoverage($stub, new PHP_CodeCoverage_Filter); + $coverage = new PHP_CodeCoverage($stub, new PHP_CodeCoverage_Filter); - $coverage->start( - new BankAccountTest('testBalanceIsInitiallyZero'), TRUE - ); - $coverage->stop(); + $coverage->start( + new BankAccountTest('testBalanceIsInitiallyZero'), TRUE + ); + $coverage->stop(); - $coverage->start( - new BankAccountTest('testBalanceCannotBecomeNegative') - ); - $coverage->stop(); + $coverage->start( + new BankAccountTest('testBalanceCannotBecomeNegative') + ); + $coverage->stop(); - return $coverage; - } + return $coverage; + } - protected function getCoverageForBankAccountForLastTwoTests() - { - $data = $this->getXdebugDataForBankAccount(); + protected function getCoverageForBankAccountForLastTwoTests() + { + $data = $this->getXdebugDataForBankAccount(); - $stub = $this->getMock('PHP_CodeCoverage_Driver_Xdebug'); - $stub->expects($this->any()) - ->method('stop') - ->will($this->onConsecutiveCalls( - $data[2], $data[3] - )); + $stub = $this->getMock('PHP_CodeCoverage_Driver_Xdebug'); + $stub->expects($this->any()) + ->method('stop') + ->will($this->onConsecutiveCalls( + $data[2], $data[3] + )); - $coverage = new PHP_CodeCoverage($stub, new PHP_CodeCoverage_Filter); + $coverage = new PHP_CodeCoverage($stub, new PHP_CodeCoverage_Filter); - $coverage->start( - new BankAccountTest('testBalanceCannotBecomeNegative2'), TRUE - ); - $coverage->stop(); + $coverage->start( + new BankAccountTest('testBalanceCannotBecomeNegative2'), TRUE + ); + $coverage->stop(); - $coverage->start( - new BankAccountTest('testDepositWithdrawMoney') - ); - $coverage->stop(); + $coverage->start( + new BankAccountTest('testDepositWithdrawMoney') + ); + $coverage->stop(); - return $coverage; - } + return $coverage; + } - protected function getExpectedDataArrayForBankAccount() - { - return array( - TEST_FILES_PATH . 'BankAccount.php' => array( - 8 => array( - 0 => 'BankAccountTest::testBalanceIsInitiallyZero', - 1 => 'BankAccountTest::testDepositWithdrawMoney' - ), - 9 => NULL, - 13 => array(), - 14 => array(), - 15 => array(), - 16 => array(), - 18 => array(), - 22 => array( - 0 => 'BankAccountTest::testBalanceCannotBecomeNegative2', - 1 => 'BankAccountTest::testDepositWithdrawMoney' - ), - 24 => array( - 0 => 'BankAccountTest::testDepositWithdrawMoney', - ), - 25 => NULL, - 29 => array( - 0 => 'BankAccountTest::testBalanceCannotBecomeNegative', - 1 => 'BankAccountTest::testDepositWithdrawMoney' - ), - 31 => array( - 0 => 'BankAccountTest::testDepositWithdrawMoney' - ), - 32 => NULL - ) - ); - } + protected function getExpectedDataArrayForBankAccount() + { + return array( + TEST_FILES_PATH . 'BankAccount.php' => array( + 8 => array( + 0 => 'BankAccountTest::testBalanceIsInitiallyZero', + 1 => 'BankAccountTest::testDepositWithdrawMoney' + ), + 9 => NULL, + 13 => array(), + 14 => array(), + 15 => array(), + 16 => array(), + 18 => array(), + 22 => array( + 0 => 'BankAccountTest::testBalanceCannotBecomeNegative2', + 1 => 'BankAccountTest::testDepositWithdrawMoney' + ), + 24 => array( + 0 => 'BankAccountTest::testDepositWithdrawMoney', + ), + 25 => NULL, + 29 => array( + 0 => 'BankAccountTest::testBalanceCannotBecomeNegative', + 1 => 'BankAccountTest::testDepositWithdrawMoney' + ), + 31 => array( + 0 => 'BankAccountTest::testDepositWithdrawMoney' + ), + 32 => NULL + ) + ); + } - protected function getCoverageForFileWithIgnoredLines() - { - $coverage = new PHP_CodeCoverage( - $this->setUpXdebugStubForFileWithIgnoredLines(), - new PHP_CodeCoverage_Filter - ); + protected function getCoverageForFileWithIgnoredLines() + { + $coverage = new PHP_CodeCoverage( + $this->setUpXdebugStubForFileWithIgnoredLines(), + new PHP_CodeCoverage_Filter + ); - $coverage->start('FileWithIgnoredLines', TRUE); - $coverage->stop(); + $coverage->start('FileWithIgnoredLines', TRUE); + $coverage->stop(); - return $coverage; - } + return $coverage; + } - protected function setUpXdebugStubForFileWithIgnoredLines() - { - $stub = $this->getMock('PHP_CodeCoverage_Driver_Xdebug'); - $stub->expects($this->any()) - ->method('stop') - ->will($this->returnValue( - array( - TEST_FILES_PATH . 'source_with_ignore.php' => array( - 2 => 1, - 4 => -1, - 6 => -1, - 7 => 1 - ) - ) - )); + protected function setUpXdebugStubForFileWithIgnoredLines() + { + $stub = $this->getMock('PHP_CodeCoverage_Driver_Xdebug'); + $stub->expects($this->any()) + ->method('stop') + ->will($this->returnValue( + array( + TEST_FILES_PATH . 'source_with_ignore.php' => array( + 2 => 1, + 4 => -1, + 6 => -1, + 7 => 1 + ) + ) + )); - return $stub; - } + return $stub; + } } diff --git a/Tests/_files/BankAccount-clover.xml b/Tests/_files/BankAccount-clover.xml index 578a7ccc1..b0f71a841 100644 --- a/Tests/_files/BankAccount-clover.xml +++ b/Tests/_files/BankAccount-clover.xml @@ -1,26 +1,26 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/_files/BankAccount.php b/Tests/_files/BankAccount.php index 4238c1559..617b4410f 100644 --- a/Tests/_files/BankAccount.php +++ b/Tests/_files/BankAccount.php @@ -1,33 +1,33 @@ balance; - } + public function getBalance() + { + return $this->balance; + } - protected function setBalance($balance) - { - if ($balance >= 0) { - $this->balance = $balance; - } else { - throw new RuntimeException; - } - } + protected function setBalance($balance) + { + if ($balance >= 0) { + $this->balance = $balance; + } else { + throw new RuntimeException; + } + } - public function depositMoney($balance) - { - $this->setBalance($this->getBalance() + $balance); + public function depositMoney($balance) + { + $this->setBalance($this->getBalance() + $balance); - return $this->getBalance(); - } + return $this->getBalance(); + } - public function withdrawMoney($balance) - { - $this->setBalance($this->getBalance() - $balance); + public function withdrawMoney($balance) + { + $this->setBalance($this->getBalance() - $balance); - return $this->getBalance(); - } + return $this->getBalance(); + } } diff --git a/Tests/_files/BankAccountTest.php b/Tests/_files/BankAccountTest.php index 827cd2452..9d2272186 100644 --- a/Tests/_files/BankAccountTest.php +++ b/Tests/_files/BankAccountTest.php @@ -3,68 +3,68 @@ class BankAccountTest extends PHPUnit_Framework_TestCase { - protected $ba; + protected $ba; - protected function setUp() - { - $this->ba = new BankAccount; - } + protected function setUp() + { + $this->ba = new BankAccount; + } - /** - * @covers BankAccount::getBalance - */ - public function testBalanceIsInitiallyZero() - { - $this->assertEquals(0, $this->ba->getBalance()); - } + /** + * @covers BankAccount::getBalance + */ + public function testBalanceIsInitiallyZero() + { + $this->assertEquals(0, $this->ba->getBalance()); + } - /** - * @covers BankAccount::withdrawMoney - */ - public function testBalanceCannotBecomeNegative() - { - try { - $this->ba->withdrawMoney(1); - } + /** + * @covers BankAccount::withdrawMoney + */ + public function testBalanceCannotBecomeNegative() + { + try { + $this->ba->withdrawMoney(1); + } - catch (RuntimeException $e) { - $this->assertEquals(0, $this->ba->getBalance()); + catch (RuntimeException $e) { + $this->assertEquals(0, $this->ba->getBalance()); - return; - } + return; + } - $this->fail(); - } + $this->fail(); + } - /** - * @covers BankAccount::depositMoney - */ - public function testBalanceCannotBecomeNegative2() - { - try { - $this->ba->depositMoney(-1); - } + /** + * @covers BankAccount::depositMoney + */ + public function testBalanceCannotBecomeNegative2() + { + try { + $this->ba->depositMoney(-1); + } - catch (RuntimeException $e) { - $this->assertEquals(0, $this->ba->getBalance()); + catch (RuntimeException $e) { + $this->assertEquals(0, $this->ba->getBalance()); - return; - } + return; + } - $this->fail(); - } + $this->fail(); + } - /** - * @covers BankAccount::getBalance - * @covers BankAccount::depositMoney - * @covers BankAccount::withdrawMoney - */ - public function testDepositWithdrawMoney() - { - $this->assertEquals(0, $this->ba->getBalance()); - $this->ba->depositMoney(1); - $this->assertEquals(1, $this->ba->getBalance()); - $this->ba->withdrawMoney(1); - $this->assertEquals(0, $this->ba->getBalance()); - } + /** + * @covers BankAccount::getBalance + * @covers BankAccount::depositMoney + * @covers BankAccount::withdrawMoney + */ + public function testDepositWithdrawMoney() + { + $this->assertEquals(0, $this->ba->getBalance()); + $this->ba->depositMoney(1); + $this->assertEquals(1, $this->ba->getBalance()); + $this->ba->withdrawMoney(1); + $this->assertEquals(0, $this->ba->getBalance()); + } } diff --git a/Tests/_files/CoverageClassExtendedTest.php b/Tests/_files/CoverageClassExtendedTest.php index df12d3470..601015d89 100644 --- a/Tests/_files/CoverageClassExtendedTest.php +++ b/Tests/_files/CoverageClassExtendedTest.php @@ -1,12 +1,12 @@ - */ - public function testSomething() - { - $o = new CoveredClass; - $o->publicMethod(); - } + /** + * @covers CoveredClass + */ + public function testSomething() + { + $o = new CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/CoverageClassTest.php b/Tests/_files/CoverageClassTest.php index 7f569ae60..00085c8e1 100644 --- a/Tests/_files/CoverageClassTest.php +++ b/Tests/_files/CoverageClassTest.php @@ -1,12 +1,12 @@ publicMethod(); - } + /** + * @covers CoveredClass + */ + public function testSomething() + { + $o = new CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/CoverageFunctionTest.php b/Tests/_files/CoverageFunctionTest.php index c621fd210..3e4bfa36e 100644 --- a/Tests/_files/CoverageFunctionTest.php +++ b/Tests/_files/CoverageFunctionTest.php @@ -1,11 +1,11 @@ publicMethod(); - } + /** @covers CoveredClass::publicMethod */ + public function testSomething() + { + $o = new CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/CoverageMethodTest.php b/Tests/_files/CoverageMethodTest.php index 167b3db4c..16c932560 100644 --- a/Tests/_files/CoverageMethodTest.php +++ b/Tests/_files/CoverageMethodTest.php @@ -1,12 +1,12 @@ publicMethod(); - } + /** + * @covers CoveredClass::publicMethod + */ + public function testSomething() + { + $o = new CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/CoverageNoneTest.php b/Tests/_files/CoverageNoneTest.php index 0b414c2ef..9f3be8216 100644 --- a/Tests/_files/CoverageNoneTest.php +++ b/Tests/_files/CoverageNoneTest.php @@ -1,9 +1,9 @@ publicMethod(); - } + public function testSomething() + { + $o = new CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/CoverageNotPrivateTest.php b/Tests/_files/CoverageNotPrivateTest.php index 12b56e80e..31343f273 100644 --- a/Tests/_files/CoverageNotPrivateTest.php +++ b/Tests/_files/CoverageNotPrivateTest.php @@ -1,12 +1,12 @@ - */ - public function testSomething() - { - $o = new CoveredClass; - $o->publicMethod(); - } + /** + * @covers CoveredClass:: + */ + public function testSomething() + { + $o = new CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/CoverageNotProtectedTest.php b/Tests/_files/CoverageNotProtectedTest.php index c69d261de..63f4f08d5 100644 --- a/Tests/_files/CoverageNotProtectedTest.php +++ b/Tests/_files/CoverageNotProtectedTest.php @@ -1,12 +1,12 @@ - */ - public function testSomething() - { - $o = new CoveredClass; - $o->publicMethod(); - } + /** + * @covers CoveredClass:: + */ + public function testSomething() + { + $o = new CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/CoverageNotPublicTest.php b/Tests/_files/CoverageNotPublicTest.php index aebfe4bd9..da769087f 100644 --- a/Tests/_files/CoverageNotPublicTest.php +++ b/Tests/_files/CoverageNotPublicTest.php @@ -1,12 +1,12 @@ - */ - public function testSomething() - { - $o = new CoveredClass; - $o->publicMethod(); - } + /** + * @covers CoveredClass:: + */ + public function testSomething() + { + $o = new CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/CoverageNothingTest.php b/Tests/_files/CoverageNothingTest.php index 5d5680d93..8d61913df 100644 --- a/Tests/_files/CoverageNothingTest.php +++ b/Tests/_files/CoverageNothingTest.php @@ -1,13 +1,13 @@ publicMethod(); - } + /** + * @covers CoveredClass::publicMethod + * @coversNothing + */ + public function testSomething() + { + $o = new CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/CoveragePrivateTest.php b/Tests/_files/CoveragePrivateTest.php index f09560d3a..1dfad5fd9 100644 --- a/Tests/_files/CoveragePrivateTest.php +++ b/Tests/_files/CoveragePrivateTest.php @@ -1,12 +1,12 @@ - */ - public function testSomething() - { - $o = new CoveredClass; - $o->publicMethod(); - } + /** + * @covers CoveredClass:: + */ + public function testSomething() + { + $o = new CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/CoverageProtectedTest.php b/Tests/_files/CoverageProtectedTest.php index 9b3acbf6c..28fd76933 100644 --- a/Tests/_files/CoverageProtectedTest.php +++ b/Tests/_files/CoverageProtectedTest.php @@ -1,12 +1,12 @@ - */ - public function testSomething() - { - $o = new CoveredClass; - $o->publicMethod(); - } + /** + * @covers CoveredClass:: + */ + public function testSomething() + { + $o = new CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/CoveragePublicTest.php b/Tests/_files/CoveragePublicTest.php index 480a522b4..11755196d 100644 --- a/Tests/_files/CoveragePublicTest.php +++ b/Tests/_files/CoveragePublicTest.php @@ -1,12 +1,12 @@ - */ - public function testSomething() - { - $o = new CoveredClass; - $o->publicMethod(); - } + /** + * @covers CoveredClass:: + */ + public function testSomething() + { + $o = new CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/CoverageTwoDefaultClassAnnotations.php b/Tests/_files/CoverageTwoDefaultClassAnnotations.php index 7c743db92..71e859c61 100644 --- a/Tests/_files/CoverageTwoDefaultClassAnnotations.php +++ b/Tests/_files/CoverageTwoDefaultClassAnnotations.php @@ -7,13 +7,13 @@ class CoverageTwoDefaultClassAnnotations { - /** - * @covers Foo\CoveredClass:: - */ - public function testSomething() - { - $o = new Foo\CoveredClass; - $o->publicMethod(); - } + /** + * @covers Foo\CoveredClass:: + */ + public function testSomething() + { + $o = new Foo\CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/CoveredClass.php b/Tests/_files/CoveredClass.php index f382ce99b..887b4b6fc 100644 --- a/Tests/_files/CoveredClass.php +++ b/Tests/_files/CoveredClass.php @@ -1,36 +1,36 @@ privateMethod(); - } + protected function protectedMethod() + { + $this->privateMethod(); + } - public function publicMethod() - { - $this->protectedMethod(); - } + public function publicMethod() + { + $this->protectedMethod(); + } } class CoveredClass extends CoveredParentClass { - private function privateMethod() - { - } + private function privateMethod() + { + } - protected function protectedMethod() - { - parent::protectedMethod(); - $this->privateMethod(); - } + protected function protectedMethod() + { + parent::protectedMethod(); + $this->privateMethod(); + } - public function publicMethod() - { - parent::publicMethod(); - $this->protectedMethod(); - } + public function publicMethod() + { + parent::publicMethod(); + $this->protectedMethod(); + } } diff --git a/Tests/_files/NamespaceCoverageClassExtendedTest.php b/Tests/_files/NamespaceCoverageClassExtendedTest.php index d0954cba9..43f08f5f6 100644 --- a/Tests/_files/NamespaceCoverageClassExtendedTest.php +++ b/Tests/_files/NamespaceCoverageClassExtendedTest.php @@ -1,12 +1,12 @@ - */ - public function testSomething() - { - $o = new Foo\CoveredClass; - $o->publicMethod(); - } + /** + * @covers Foo\CoveredClass + */ + public function testSomething() + { + $o = new Foo\CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/NamespaceCoverageClassTest.php b/Tests/_files/NamespaceCoverageClassTest.php index 63912c089..4daf35555 100644 --- a/Tests/_files/NamespaceCoverageClassTest.php +++ b/Tests/_files/NamespaceCoverageClassTest.php @@ -1,12 +1,12 @@ publicMethod(); - } + /** + * @covers Foo\CoveredClass + */ + public function testSomething() + { + $o = new Foo\CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/NamespaceCoverageCoversClassPublicTest.php b/Tests/_files/NamespaceCoverageCoversClassPublicTest.php index d3d48efbd..8ddfb4eca 100644 --- a/Tests/_files/NamespaceCoverageCoversClassPublicTest.php +++ b/Tests/_files/NamespaceCoverageCoversClassPublicTest.php @@ -4,13 +4,13 @@ */ class NamespaceCoverageCoversClassPublicTest extends PHPUnit_Framework_TestCase { - /** - * @covers ::publicMethod - */ - public function testSomething() - { - $o = new Foo\CoveredClass; - $o->publicMethod(); - } + /** + * @covers ::publicMethod + */ + public function testSomething() + { + $o = new Foo\CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/NamespaceCoverageCoversClassTest.php b/Tests/_files/NamespaceCoverageCoversClassTest.php index 79d1010d3..647f3e9ef 100644 --- a/Tests/_files/NamespaceCoverageCoversClassTest.php +++ b/Tests/_files/NamespaceCoverageCoversClassTest.php @@ -4,18 +4,18 @@ */ class NamespaceCoverageCoversClassTest extends PHPUnit_Framework_TestCase { - /** - * @covers ::privateMethod - * @covers ::protectedMethod - * @covers ::publicMethod - * @covers \Foo\CoveredParentClass::privateMethod - * @covers \Foo\CoveredParentClass::protectedMethod - * @covers \Foo\CoveredParentClass::publicMethod - */ - public function testSomething() - { - $o = new Foo\CoveredClass; - $o->publicMethod(); - } + /** + * @covers ::privateMethod + * @covers ::protectedMethod + * @covers ::publicMethod + * @covers \Foo\CoveredParentClass::privateMethod + * @covers \Foo\CoveredParentClass::protectedMethod + * @covers \Foo\CoveredParentClass::publicMethod + */ + public function testSomething() + { + $o = new Foo\CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/NamespaceCoverageMethodTest.php b/Tests/_files/NamespaceCoverageMethodTest.php index 35dfb8b1d..71acb26d8 100644 --- a/Tests/_files/NamespaceCoverageMethodTest.php +++ b/Tests/_files/NamespaceCoverageMethodTest.php @@ -1,12 +1,12 @@ publicMethod(); - } + /** + * @covers Foo\CoveredClass::publicMethod + */ + public function testSomething() + { + $o = new Foo\CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/NamespaceCoverageNotPrivateTest.php b/Tests/_files/NamespaceCoverageNotPrivateTest.php index 552c9ec50..77d6a56d0 100644 --- a/Tests/_files/NamespaceCoverageNotPrivateTest.php +++ b/Tests/_files/NamespaceCoverageNotPrivateTest.php @@ -1,12 +1,12 @@ - */ - public function testSomething() - { - $o = new Foo\CoveredClass; - $o->publicMethod(); - } + /** + * @covers Foo\CoveredClass:: + */ + public function testSomething() + { + $o = new Foo\CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/NamespaceCoverageNotProtectedTest.php b/Tests/_files/NamespaceCoverageNotProtectedTest.php index 33fc8c72c..9c2fac777 100644 --- a/Tests/_files/NamespaceCoverageNotProtectedTest.php +++ b/Tests/_files/NamespaceCoverageNotProtectedTest.php @@ -1,12 +1,12 @@ - */ - public function testSomething() - { - $o = new Foo\CoveredClass; - $o->publicMethod(); - } + /** + * @covers Foo\CoveredClass:: + */ + public function testSomething() + { + $o = new Foo\CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/NamespaceCoverageNotPublicTest.php b/Tests/_files/NamespaceCoverageNotPublicTest.php index ccbc5009c..d9e356d8c 100644 --- a/Tests/_files/NamespaceCoverageNotPublicTest.php +++ b/Tests/_files/NamespaceCoverageNotPublicTest.php @@ -1,12 +1,12 @@ - */ - public function testSomething() - { - $o = new Foo\CoveredClass; - $o->publicMethod(); - } + /** + * @covers Foo\CoveredClass:: + */ + public function testSomething() + { + $o = new Foo\CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/NamespaceCoveragePrivateTest.php b/Tests/_files/NamespaceCoveragePrivateTest.php index cce7ba9d6..e3a58a275 100644 --- a/Tests/_files/NamespaceCoveragePrivateTest.php +++ b/Tests/_files/NamespaceCoveragePrivateTest.php @@ -1,12 +1,12 @@ - */ - public function testSomething() - { - $o = new Foo\CoveredClass; - $o->publicMethod(); - } + /** + * @covers Foo\CoveredClass:: + */ + public function testSomething() + { + $o = new Foo\CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/NamespaceCoverageProtectedTest.php b/Tests/_files/NamespaceCoverageProtectedTest.php index dbbcc1c31..896a02343 100644 --- a/Tests/_files/NamespaceCoverageProtectedTest.php +++ b/Tests/_files/NamespaceCoverageProtectedTest.php @@ -1,12 +1,12 @@ - */ - public function testSomething() - { - $o = new Foo\CoveredClass; - $o->publicMethod(); - } + /** + * @covers Foo\CoveredClass:: + */ + public function testSomething() + { + $o = new Foo\CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/NamespaceCoveragePublicTest.php b/Tests/_files/NamespaceCoveragePublicTest.php index bf1bff8c4..1e137e385 100644 --- a/Tests/_files/NamespaceCoveragePublicTest.php +++ b/Tests/_files/NamespaceCoveragePublicTest.php @@ -1,12 +1,12 @@ - */ - public function testSomething() - { - $o = new Foo\CoveredClass; - $o->publicMethod(); - } + /** + * @covers Foo\CoveredClass:: + */ + public function testSomething() + { + $o = new Foo\CoveredClass; + $o->publicMethod(); + } } diff --git a/Tests/_files/NamespaceCoveredClass.php b/Tests/_files/NamespaceCoveredClass.php index 5bd0ddfb2..f4f80be89 100644 --- a/Tests/_files/NamespaceCoveredClass.php +++ b/Tests/_files/NamespaceCoveredClass.php @@ -3,36 +3,36 @@ class CoveredParentClass { - private function privateMethod() - { - } + private function privateMethod() + { + } - protected function protectedMethod() - { - $this->privateMethod(); - } + protected function protectedMethod() + { + $this->privateMethod(); + } - public function publicMethod() - { - $this->protectedMethod(); - } + public function publicMethod() + { + $this->protectedMethod(); + } } class CoveredClass extends CoveredParentClass { - private function privateMethod() - { - } + private function privateMethod() + { + } - protected function protectedMethod() - { - parent::protectedMethod(); - $this->privateMethod(); - } + protected function protectedMethod() + { + parent::protectedMethod(); + $this->privateMethod(); + } - public function publicMethod() - { - parent::publicMethod(); - $this->protectedMethod(); - } + public function publicMethod() + { + parent::publicMethod(); + $this->protectedMethod(); + } } diff --git a/Tests/_files/NotExistingCoveredElementTest.php b/Tests/_files/NotExistingCoveredElementTest.php index be07ef45e..2fa9e0ad1 100644 --- a/Tests/_files/NotExistingCoveredElementTest.php +++ b/Tests/_files/NotExistingCoveredElementTest.php @@ -1,24 +1,24 @@ - */ - public function testThree() - { - } + /** + * @covers NotExistingClass:: + */ + public function testThree() + { + } } diff --git a/Tests/_files/ignored-lines-clover.xml b/Tests/_files/ignored-lines-clover.xml index 4da74483c..6a67482ab 100644 --- a/Tests/_files/ignored-lines-clover.xml +++ b/Tests/_files/ignored-lines-clover.xml @@ -1,19 +1,19 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/Tests/_files/source_with_ignore.php b/Tests/_files/source_with_ignore.php index 51a9268e9..5821f22a4 100644 --- a/Tests/_files/source_with_ignore.php +++ b/Tests/_files/source_with_ignore.php @@ -1,8 +1,8 @@ + depends="prepare,lint,phploc,pdepend,phpmd-ci,phpcs-ci,phpcpd,phpunit,phpcb"/> + depends="prepare,lint,tools-parallel,phpunit,phpcb"/> - - - - - - - - - + description="Run tools in parallel"> + + + + + + + + + - - - - - + + + + + - - - - - + description="Prepare for build"> + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - + + + + + - - - - - - + description="Calculate software metrics using PHP_Depend"> + + + + + + - - - - - + description="Perform project mess detection using PHPMD"> + + + + + - - - - - - - + description="Perform project mess detection using PHPMD"> + + + + + + + - - - - - - - + description="Find coding standard violations using PHP_CodeSniffer"> + + + + + + + - - - - - - - - - + description="Find coding standard violations using PHP_CodeSniffer"> + + + + + + + + + - - - - - + + + + + - - - - - + + + + + - + - - - - - - - - + description="Aggregate tool output with PHP_CodeBrowser"> + + + + + + + + diff --git a/build/PHPCS/Sniffs/ControlStructures/ControlSignatureSniff.php b/build/PHPCS/Sniffs/ControlStructures/ControlSignatureSniff.php index bf9d520d3..bdf6af0f6 100644 --- a/build/PHPCS/Sniffs/ControlStructures/ControlSignatureSniff.php +++ b/build/PHPCS/Sniffs/ControlStructures/ControlSignatureSniff.php @@ -1,22 +1,22 @@ getTokens(); + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); - if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE || - $tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { + if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE || + $tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { - $phpcsFile->addError( - 'Concatenation operator must be surrounded by whitespace', - $stackPtr - ); - } - } + $phpcsFile->addError( + 'Concatenation operator must be surrounded by whitespace', + $stackPtr + ); + } + } } diff --git a/build/phpmd.xml b/build/phpmd.xml index 23ecb8b0b..a911cd907 100644 --- a/build/phpmd.xml +++ b/build/phpmd.xml @@ -1,27 +1,27 @@ - Sebastian Bergmann's ruleset + xmlns="http://pmd.sf.net/ruleset/1.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0%20http://pmd.sf.net/ruleset_xml_schema.xsd" + xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"> + Sebastian Bergmann's ruleset - - - - - - + + + + + + - - - + + + - + - - - - + + + + diff --git a/build/travis-ci.xml b/build/travis-ci.xml index 51d344695..8ec92a26c 100644 --- a/build/travis-ci.xml +++ b/build/travis-ci.xml @@ -1,24 +1,24 @@ - - - ../Tests/PHP - - + backupStaticAttributes="false" + colors="true"> + + + ../Tests/PHP + + - - - + + + - - - ../PHP - - ../PHP/CodeCoverage/Autoload.php - - - + + + ../PHP + + ../PHP/CodeCoverage/Autoload.php + + + diff --git a/composer.json b/composer.json index 582c8c6f4..a064f3fe9 100644 --- a/composer.json +++ b/composer.json @@ -1,47 +1,47 @@ { - "name": "phpunit/php-code-coverage", - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "type": "library", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "license": "BSD-3-Clause", - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "irc": "irc://irc.freenode.net/phpunit" - }, - "require": { - "php": ">=5.4.7", - "phpunit/php-file-iterator": ">=1.3.0", - "phpunit/php-token-stream": ">=1.1.3", - "phpunit/php-text-template": ">=1.1.1", - "sebastian/version": ">=1.0.0" - }, - "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.2.1" - }, - "autoload": { - "classmap": [ - "PHP/" - ] - }, - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "include-path": [ - "" - ] + "name": "phpunit/php-code-coverage", + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "type": "library", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "irc": "irc://irc.freenode.net/phpunit" + }, + "require": { + "php": ">=5.4.7", + "phpunit/php-file-iterator": ">=1.3.0", + "phpunit/php-token-stream": ">=1.1.3", + "phpunit/php-text-template": ">=1.1.1", + "sebastian/version": ">=1.0.0" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.2.1" + }, + "autoload": { + "classmap": [ + "PHP/" + ] + }, + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "include-path": [ + "" + ] } diff --git a/package.xml b/package.xml index b653d426d..d8ff58b1c 100644 --- a/package.xml +++ b/package.xml @@ -1,142 +1,142 @@ + xmlns="http://pear.php.net/dtd/package-2.0" + xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0+http://pear.php.net/dtd/tasks-1.0.xsd+http://pear.php.net/dtd/package-2.0+http://pear.php.net/dtd/package-2.0.xsd"> PHP_CodeCoverage pear.phpunit.de Library that provides collection, processing, and rendering functionality for PHP code coverage information. Library that provides collection, processing, and rendering functionality for PHP code coverage information. - Sebastian Bergmann - sb - sb@sebastian-bergmann.de - yes + Sebastian Bergmann + sb + sb@sebastian-bergmann.de + yes 2013-MM-DD - 1.3.0 - 1.3.0 + 1.3.0 + 1.3.0 - devel - devel + devel + devel The BSD 3-Clause License http://github.com/sebastianbergmann/php-code-coverage/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - 5.4.7 - - - 1.9.4 - - - File_Iterator - pear.phpunit.de - 1.3.0 - - - PHP_TokenStream - pear.phpunit.de - 1.1.3 - - - Text_Template - pear.phpunit.de - 1.1.1 - - - Version - pear.phpunit.de - 1.0.0 - - - - - dom - - - xdebug - 2.2.1 - - + + + 5.4.7 + + + 1.9.4 + + + File_Iterator + pear.phpunit.de + 1.3.0 + + + PHP_TokenStream + pear.phpunit.de + 1.1.3 + + + Text_Template + pear.phpunit.de + 1.1.1 + + + Version + pear.phpunit.de + 1.0.0 + + + + + dom + + + xdebug + 2.2.1 + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 67360e53b..e58a0fed3 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,28 +1,28 @@ - - - Tests/PHP - - + backupStaticAttributes="false" + bootstrap="PHP/CodeCoverage/Autoload.php"> + + + Tests/PHP + + - - - - - + + + + + - - - PHP - - PHP/CodeCoverage/Autoload.php - - - + + + PHP + + PHP/CodeCoverage/Autoload.php + + + diff --git a/scripts/auto_prepend.php b/scripts/auto_prepend.php index 7a8887a5b..3853c9668 100644 --- a/scripts/auto_prepend.php +++ b/scripts/auto_prepend.php @@ -2,7 +2,7 @@ require_once 'PHP/CodeCoverage/Autoload.php'; $coverage = new PHP_CodeCoverage; -$filter = $coverage->filter(); +$filter = $coverage->filter(); $filter->addFileToBlacklist(__FILE__); $filter->addFileToBlacklist(dirname(__FILE__) . '/auto_append.php');
    {name}{methods_bar}
    {methods_tested_percent}
    {methods_number}
    {crap}{lines_bar}
    {lines_executed_percent}
    {lines_number}
    {name}{methods_bar}
    {methods_tested_percent}
    {methods_number}
    {crap}{lines_bar}
    {lines_executed_percent}
    {lines_number}