diff --git a/.gitignore b/.gitignore
index b386531f0..4486ead43 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@ build/logs
build/pdepend
cache.properties
phpunit.xml
+/tests/_files/tmp
/vendor
/composer.lock
/composer.phar
diff --git a/src/CodeCoverage/Report/Text.php b/src/CodeCoverage/Report/Text.php
index 174546fd8..d37a6d77c 100644
--- a/src/CodeCoverage/Report/Text.php
+++ b/src/CodeCoverage/Report/Text.php
@@ -223,9 +223,9 @@ protected function getCoverageColor($numberOfCoveredElements, $totalNumberOfElem
return $this->colors['red'];
}
- protected function printCoverageCounts($numberOfCoveredElements, $totalNumberOfElements, $presicion)
+ protected function printCoverageCounts($numberOfCoveredElements, $totalNumberOfElements, $precision)
{
- $format = '%' . $presicion . 's';
+ $format = '%' . $precision . 's';
return PHP_CodeCoverage_Util::percent(
$numberOfCoveredElements,
diff --git a/tests/PHP/CodeCoverage/FilterTest.php b/tests/PHP/CodeCoverage/FilterTest.php
index c0e59e0ba..f39b95cdf 100644
--- a/tests/PHP/CodeCoverage/FilterTest.php
+++ b/tests/PHP/CodeCoverage/FilterTest.php
@@ -8,13 +8,7 @@
* file that was distributed with this source code.
*/
-if (!defined('TEST_FILES_PATH')) {
- define(
- 'TEST_FILES_PATH',
- dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR .
- '_files' . DIRECTORY_SEPARATOR
- );
-}
+require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestCase.php';
/**
* Tests for the PHP_CodeCoverage_Filter class.
diff --git a/tests/PHP/CodeCoverage/Report/CloverTest.php b/tests/PHP/CodeCoverage/Report/CloverTest.php
index 8d860bd2d..1b2174ee9 100644
--- a/tests/PHP/CodeCoverage/Report/CloverTest.php
+++ b/tests/PHP/CodeCoverage/Report/CloverTest.php
@@ -8,15 +8,7 @@
* file that was distributed with this source code.
*/
-if (!defined('TEST_FILES_PATH')) {
- define(
- 'TEST_FILES_PATH',
- dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR .
- '_files' . DIRECTORY_SEPARATOR
- );
-}
-
-require_once TEST_FILES_PATH . '../TestCase.php';
+require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestCase.php';
/**
* Tests for the PHP_CodeCoverage_Report_Clover class.
diff --git a/tests/PHP/CodeCoverage/Report/Crap4jTest.php b/tests/PHP/CodeCoverage/Report/Crap4jTest.php
new file mode 100644
index 000000000..2822aaea5
--- /dev/null
+++ b/tests/PHP/CodeCoverage/Report/Crap4jTest.php
@@ -0,0 +1,58 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestCase.php';
+
+/**
+ * Tests for the PHP_CodeCoverage_Report_Crap4j class.
+ *
+ * @since Class available since Release 3.0.2
+ */
+class PHP_CodeCoverage_Report_Crap4jTest extends PHP_CodeCoverage_TestCase
+{
+ /**
+ * @covers PHP_CodeCoverage_Report_Crap4j
+ */
+ public function testForBankAccountTest()
+ {
+ $crap4j = new PHP_CodeCoverage_Report_Crap4j;
+
+ $this->assertStringMatchesFormatFile(
+ TEST_FILES_PATH . 'BankAccount-crap4j.xml',
+ $crap4j->process($this->getCoverageForBankAccount(), null, 'BankAccount')
+ );
+ }
+
+ /**
+ * @covers PHP_CodeCoverage_Report_Crap4j
+ */
+ public function testForFileWithIgnoredLines()
+ {
+ $crap4j = new PHP_CodeCoverage_Report_Crap4j;
+
+ $this->assertStringMatchesFormatFile(
+ TEST_FILES_PATH . 'ignored-lines-crap4j.xml',
+ $crap4j->process($this->getCoverageForFileWithIgnoredLines(), null, 'CoverageForFileWithIgnoredLines')
+ );
+ }
+
+ /**
+ * @covers PHP_CodeCoverage_Report_Crap4j
+ */
+ public function testForClassWithAnonymousFunction()
+ {
+ $crap4j = new PHP_CodeCoverage_Report_Crap4j;
+
+ $this->assertStringMatchesFormatFile(
+ TEST_FILES_PATH . 'class-with-anonymous-function-crap4j.xml',
+ $crap4j->process($this->getCoverageForClassWithAnonymousFunction(), null, 'CoverageForClassWithAnonymousFunction')
+ );
+ }
+}
diff --git a/tests/PHP/CodeCoverage/Report/FactoryTest.php b/tests/PHP/CodeCoverage/Report/FactoryTest.php
index 4c15f5c72..43616095d 100644
--- a/tests/PHP/CodeCoverage/Report/FactoryTest.php
+++ b/tests/PHP/CodeCoverage/Report/FactoryTest.php
@@ -8,15 +8,7 @@
* file that was distributed with this source code.
*/
-if (!defined('TEST_FILES_PATH')) {
- define(
- 'TEST_FILES_PATH',
- dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR .
- '_files' . DIRECTORY_SEPARATOR
- );
-}
-
-require_once TEST_FILES_PATH . '../TestCase.php';
+require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestCase.php';
/**
* Tests for the PHP_CodeCoverage_Report_Factory class.
diff --git a/tests/PHP/CodeCoverage/Report/HTMLTest.php b/tests/PHP/CodeCoverage/Report/HTMLTest.php
new file mode 100644
index 000000000..a58dcddd2
--- /dev/null
+++ b/tests/PHP/CodeCoverage/Report/HTMLTest.php
@@ -0,0 +1,112 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestCase.php';
+
+/**
+ * Tests for the PHP_CodeCoverage_Report_HTML class.
+ *
+ * @since Class available since Release 3.0.2
+ */
+class PHP_CodeCoverage_Report_HTMLTest extends PHP_CodeCoverage_TestCase
+{
+ static private $TEST_REPORT_PATH_SOURCE;
+
+ public static function setUpBeforeClass()
+ {
+ parent::setUpBeforeClass();
+
+ self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH . 'Report' . DIRECTORY_SEPARATOR . 'HTML';
+ }
+
+ protected function tearDown()
+ {
+ parent::tearDown();
+
+ $tmpFilesIterator = new RecursiveIteratorIterator(
+ new RecursiveDirectoryIterator(self::$TEST_TMP_PATH, RecursiveDirectoryIterator::SKIP_DOTS),
+ RecursiveIteratorIterator::CHILD_FIRST
+ );
+ foreach ($tmpFilesIterator as $path => $fileInfo) {
+ /* @var SplFileInfo $fileInfo */
+ $pathname = $fileInfo->getPathname();
+ $fileInfo->isDir() ? rmdir($pathname) : unlink($pathname);
+ }
+ }
+
+ /**
+ * @covers PHP_CodeCoverage_Report_HTML
+ */
+ public function testForBankAccountTest()
+ {
+ $expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForBankAccount';
+
+ $report = new PHP_CodeCoverage_Report_HTML;
+ $report->process($this->getCoverageForBankAccount(), self::$TEST_TMP_PATH);
+
+ $this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
+ }
+
+ /**
+ * @covers PHP_CodeCoverage_Report_HTML
+ */
+ public function testForFileWithIgnoredLines()
+ {
+ $expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForFileWithIgnoredLines';
+
+ $report = new PHP_CodeCoverage_Report_HTML;
+ $report->process($this->getCoverageForFileWithIgnoredLines(), self::$TEST_TMP_PATH);
+
+ $this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
+ }
+
+ /**
+ * @covers PHP_CodeCoverage_Report_HTML
+ */
+ public function testForClassWithAnonymousFunction()
+ {
+ $expectedFilesPath =
+ self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction';
+
+ $report = new PHP_CodeCoverage_Report_HTML;
+ $report->process($this->getCoverageForClassWithAnonymousFunction(), self::$TEST_TMP_PATH);
+
+ $this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
+ }
+
+ /**
+ * @param string $expectedFilesPath
+ * @param string $actualFilesPath
+ */
+ protected function assertFilesEquals($expectedFilesPath, $actualFilesPath)
+ {
+ $expectedFilesIterator = new FilesystemIterator($expectedFilesPath);
+ $actualFilesIterator = new RegexIterator(new FilesystemIterator($actualFilesPath), '/.html/');
+
+ $this->assertEquals(
+ iterator_count($expectedFilesIterator),
+ iterator_count($actualFilesIterator),
+ 'Generated files and expected files not match'
+ );
+ foreach ($expectedFilesIterator as $path => $fileInfo) {
+ /* @var SplFileInfo $fileInfo */
+ $filename = $fileInfo->getFilename();
+
+ $actualFile = $actualFilesPath . DIRECTORY_SEPARATOR . $filename;
+
+ $this->assertFileExists($actualFile);
+ $this->assertStringMatchesFormatFile(
+ $fileInfo->getPathname(),
+ str_replace(PHP_EOL, "\n", file_get_contents($actualFile)),
+ "${filename} not match"
+ );
+ }
+ }
+}
diff --git a/tests/PHP/CodeCoverage/Report/TextTest.php b/tests/PHP/CodeCoverage/Report/TextTest.php
new file mode 100644
index 000000000..18e4125d8
--- /dev/null
+++ b/tests/PHP/CodeCoverage/Report/TextTest.php
@@ -0,0 +1,58 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestCase.php';
+
+/**
+ * Tests for the PHP_CodeCoverage_Report_Text class.
+ *
+ * @since Class available since Release 3.0.2
+ */
+class PHP_CodeCoverage_Report_TextTest extends PHP_CodeCoverage_TestCase
+{
+ /**
+ * @covers PHP_CodeCoverage_Report_Text
+ */
+ public function testTextForBankAccountTest()
+ {
+ $text = new PHP_CodeCoverage_Report_Text(50, 90, false, false);
+
+ $this->assertStringMatchesFormatFile(
+ TEST_FILES_PATH . 'BankAccount-text.txt',
+ str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForBankAccount()))
+ );
+ }
+
+ /**
+ * @covers PHP_CodeCoverage_Report_Text
+ */
+ public function testTextForFileWithIgnoredLines()
+ {
+ $text = new PHP_CodeCoverage_Report_Text(50, 90, false, false);
+
+ $this->assertStringMatchesFormatFile(
+ TEST_FILES_PATH . 'ignored-lines-text.txt',
+ str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForFileWithIgnoredLines()))
+ );
+ }
+
+ /**
+ * @covers PHP_CodeCoverage_Report_Text
+ */
+ public function testTextForClassWithAnonymousFunction()
+ {
+ $text = new PHP_CodeCoverage_Report_Text(50, 90, false, false);
+
+ $this->assertStringMatchesFormatFile(
+ TEST_FILES_PATH . 'class-with-anonymous-function-text.txt',
+ str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForClassWithAnonymousFunction()))
+ );
+ }
+}
diff --git a/tests/PHP/CodeCoverage/Report/XMLTest.php b/tests/PHP/CodeCoverage/Report/XMLTest.php
new file mode 100644
index 000000000..f35ef74bd
--- /dev/null
+++ b/tests/PHP/CodeCoverage/Report/XMLTest.php
@@ -0,0 +1,108 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestCase.php';
+
+/**
+ * Tests for the PHP_CodeCoverage_Report_XML class.
+ *
+ * @since Class available since Release 3.0.2
+ */
+class PHP_CodeCoverage_Report_XMLTest extends PHP_CodeCoverage_TestCase
+{
+ static private $TEST_REPORT_PATH_SOURCE;
+
+ public static function setUpBeforeClass()
+ {
+ parent::setUpBeforeClass();
+
+ self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH . 'Report' . DIRECTORY_SEPARATOR . 'XML';
+ }
+
+ protected function tearDown()
+ {
+ parent::tearDown();
+
+ $tmpFilesIterator = new FilesystemIterator(self::$TEST_TMP_PATH);
+ foreach ($tmpFilesIterator as $path => $fileInfo) {
+ /* @var SplFileInfo $fileInfo */
+ unlink($fileInfo->getPathname());
+ }
+ }
+
+ /**
+ * @covers PHP_CodeCoverage_Report_XML
+ */
+ public function testForBankAccountTest()
+ {
+ $expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForBankAccount';
+
+ $xml = new PHP_CodeCoverage_Report_XML;
+ $xml->process($this->getCoverageForBankAccount(), self::$TEST_TMP_PATH);
+
+ $this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
+ }
+
+ /**
+ * @covers PHP_CodeCoverage_Report_XML
+ */
+ public function testForFileWithIgnoredLines()
+ {
+ $expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForFileWithIgnoredLines';
+
+ $xml = new PHP_CodeCoverage_Report_XML;
+ $xml->process($this->getCoverageForFileWithIgnoredLines(), self::$TEST_TMP_PATH);
+
+ $this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
+ }
+
+ /**
+ * @covers PHP_CodeCoverage_Report_XML
+ */
+ public function testForClassWithAnonymousFunction()
+ {
+ $expectedFilesPath =
+ self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction';
+
+ $xml = new PHP_CodeCoverage_Report_XML;
+ $xml->process($this->getCoverageForClassWithAnonymousFunction(), self::$TEST_TMP_PATH);
+
+ $this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
+ }
+
+ /**
+ * @param string $expectedFilesPath
+ * @param string $actualFilesPath
+ */
+ protected function assertFilesEquals($expectedFilesPath, $actualFilesPath)
+ {
+ $expectedFilesIterator = new FilesystemIterator($expectedFilesPath);
+ $actualFilesIterator = new FilesystemIterator($actualFilesPath);
+
+ $this->assertEquals(
+ iterator_count($expectedFilesIterator),
+ iterator_count($actualFilesIterator),
+ 'Generated files and expected files not match'
+ );
+ foreach ($expectedFilesIterator as $path => $fileInfo) {
+ /* @var SplFileInfo $fileInfo */
+ $filename = $fileInfo->getFilename();
+
+ $actualFile = $actualFilesPath . DIRECTORY_SEPARATOR . $filename;
+
+ $this->assertFileExists($actualFile);
+ $this->assertStringMatchesFormatFile(
+ $fileInfo->getPathname(),
+ file_get_contents($actualFile),
+ "${filename} not match"
+ );
+ }
+ }
+}
diff --git a/tests/PHP/CodeCoverage/UtilTest.php b/tests/PHP/CodeCoverage/UtilTest.php
index 0b4caea97..1cd8c20b8 100644
--- a/tests/PHP/CodeCoverage/UtilTest.php
+++ b/tests/PHP/CodeCoverage/UtilTest.php
@@ -8,6 +8,8 @@
* file that was distributed with this source code.
*/
+require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestCase.php';
+
/**
* Tests for the PHP_CodeCoverage_Util class.
*
diff --git a/tests/PHP/CodeCoverageTest.php b/tests/PHP/CodeCoverageTest.php
index d6c8aa40c..b1d43f7d9 100644
--- a/tests/PHP/CodeCoverageTest.php
+++ b/tests/PHP/CodeCoverageTest.php
@@ -8,17 +8,7 @@
* file that was distributed with this source code.
*/
-if (!defined('TEST_FILES_PATH')) {
- define(
- 'TEST_FILES_PATH',
- dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR .
- '_files' . DIRECTORY_SEPARATOR
- );
-}
-
-require_once TEST_FILES_PATH . '../TestCase.php';
-require_once TEST_FILES_PATH . 'BankAccount.php';
-require_once TEST_FILES_PATH . 'BankAccountTest.php';
+require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'TestCase.php';
/**
* Tests for the PHP_CodeCoverage class.
diff --git a/tests/TestCase.php b/tests/TestCase.php
index 01b0a5714..d03585cef 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -8,6 +8,10 @@
* file that was distributed with this source code.
*/
+if (!defined('TEST_FILES_PATH')) {
+ define('TEST_FILES_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR);
+}
+
/**
* Abstract base class for test case classes.
*
@@ -15,6 +19,13 @@
*/
abstract class PHP_CodeCoverage_TestCase extends PHPUnit_Framework_TestCase
{
+ static protected $TEST_TMP_PATH;
+
+ public static function setUpBeforeClass()
+ {
+ self::$TEST_TMP_PATH = TEST_FILES_PATH . 'tmp';
+ }
+
protected function getXdebugDataForBankAccount()
{
return [
@@ -70,6 +81,7 @@ protected function getXdebugDataForBankAccount()
protected function getCoverageForBankAccount()
{
$data = $this->getXdebugDataForBankAccount();
+ require_once TEST_FILES_PATH . 'BankAccountTest.php';
$stub = $this->getMock('PHP_CodeCoverage_Driver_Xdebug');
$stub->expects($this->any())
diff --git a/tests/_files/BankAccount-crap4j.xml b/tests/_files/BankAccount-crap4j.xml
new file mode 100644
index 000000000..f2f56eabb
--- /dev/null
+++ b/tests/_files/BankAccount-crap4j.xml
@@ -0,0 +1,59 @@
+
+
| + | Code Coverage |
+ |||||||||
| + | Classes and Traits |
+ Functions and Methods |
+ Lines |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 75.00% |
+ 3 / 4 |
+ CRAP | +
+
+
+ |
+ 50.00% |
+ 5 / 10 |
+
| BankAccount | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 75.00% |
+ 3 / 4 |
+ 8.12 | +
+
+
+ |
+ 50.00% |
+ 5 / 10 |
+
| getBalance | +
+
+
+ |
+ 100.00% |
+ 1 / 1 |
+ 1 | +
+
+
+ |
+ 100.00% |
+ 1 / 1 |
+ |||
| setBalance | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 6 | +
+
+
+ |
+ 0.00% |
+ 0 / 5 |
+ |||
| depositMoney | +
+
+
+ |
+ 100.00% |
+ 1 / 1 |
+ 1 | +
+
+
+ |
+ 100.00% |
+ 2 / 2 |
+ |||
| withdrawMoney | +
+
+
+ |
+ 100.00% |
+ 1 / 1 |
+ 1 | +
+
+
+ |
+ 100.00% |
+ 2 / 2 |
+ |||
| <?php | |
| class BankAccount | |
| { | |
| protected $balance = 0; | |
| public function getBalance() | |
| { | |
| return $this->balance; | |
| } | |
| protected function setBalance($balance) | |
| { | |
| if ($balance >= 0) { | |
| $this->balance = $balance; | |
| } else { | |
| throw new RuntimeException; | |
| } | |
| } | |
| public function depositMoney($balance) | |
| { | |
| $this->setBalance($this->getBalance() + $balance); | |
| return $this->getBalance(); | |
| } | |
| public function withdrawMoney($balance) | |
| { | |
| $this->setBalance($this->getBalance() - $balance); | |
| return $this->getBalance(); | |
| } | |
| } |
| Class | +Coverage | +
|---|---|
| BankAccount | 50% |
| Class | +CRAP | +
|---|---|
| BankAccount | 8 |
| Method | +Coverage | +
|---|---|
| setBalance | 0% |
| Method | +CRAP | +
|---|---|
| setBalance | 6 |
| + | Code Coverage |
+ ||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ ||||||
| Total | +
+
+
+ |
+ 50.00% |
+ 5 / 10 |
+
+
+
+ |
+ 75.00% |
+ 3 / 4 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| BankAccount.php | +
+
+
+ |
+ 50.00% |
+ 5 / 10 |
+
+
+
+ |
+ 75.00% |
+ 3 / 4 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| Class | +Coverage | +
|---|---|
| CoveredClassWithAnonymousFunctionInStaticMethod | 87% |
| Class | +CRAP | +
|---|
| Method | +Coverage | +
|---|---|
| runAnonymous | 66% |
| Method | +CRAP | +
|---|
| + | Code Coverage |
+ ||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ ||||||
| Total | +
+
+
+ |
+ 87.50% |
+ 7 / 8 |
+
+
+
+ |
+ 50.00% |
+ 1 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| source_with_class_and_anonymous_function.php | +
+
+
+ |
+ 87.50% |
+ 7 / 8 |
+
+
+
+ |
+ 50.00% |
+ 1 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| + | Code Coverage |
+ |||||||||
| + | Classes and Traits |
+ Functions and Methods |
+ Lines |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 50.00% |
+ 1 / 2 |
+ CRAP | +
+
+
+ |
+ 87.50% |
+ 7 / 8 |
+
| CoveredClassWithAnonymousFunctionInStaticMethod | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 50.00% |
+ 1 / 2 |
+ 2.01 | +
+
+
+ |
+ 87.50% |
+ 7 / 8 |
+
| runAnonymous | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 1.04 | +
+
+
+ |
+ 66.67% |
+ 2 / 3 |
+ |||
| anonymous function | +
+
+
+ |
+ 100.00% |
+ 1 / 1 |
+ 1 | +
+
+
+ |
+ 100.00% |
+ 2 / 2 |
+ |||
| <?php | |
| class CoveredClassWithAnonymousFunctionInStaticMethod | |
| { | |
| public static function runAnonymous() | |
| { | |
| $filter = ['abc124', 'abc123', '123']; | |
| array_walk( | |
| $filter, | |
| function (&$val, $key) { | |
| $val = preg_replace('|[^0-9]|', '', $val); | |
| } | |
| ); | |
| // Should be covered | |
| $extravar = true; | |
| } | |
| } |
| Class | +Coverage | +
|---|
| Class | +CRAP | +
|---|
| Method | +Coverage | +
|---|
| Method | +CRAP | +
|---|
| + | Code Coverage |
+ ||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ ||||||
| Total | +
+
+
+ |
+ 50.00% |
+ 1 / 2 |
+
+
+
+ |
+ 100.00% |
+ 0 / 0 |
+
+
+
+ |
+ 100.00% |
+ 2 / 2 |
+
| source_with_ignore.php | +
+
+
+ |
+ 50.00% |
+ 1 / 2 |
+
+
+
+ |
+ 100.00% |
+ 0 / 0 |
+
+
+
+ |
+ 100.00% |
+ 2 / 2 |
+
| + | Code Coverage |
+ |||||||||
| + | Classes and Traits |
+ Functions and Methods |
+ Lines |
+ |||||||
| Total | +
+
+
+ |
+ 100.00% |
+ 2 / 2 |
+
+
+
+ |
+ 100.00% |
+ 0 / 0 |
+ CRAP | +
+
+
+ |
+ 50.00% |
+ 1 / 2 |
+
| baz | +
+
+
+ |
+ 100.00% |
+ 1 / 1 |
+ 0 | +
+
+
+ |
+ 100.00% |
+ 0 / 0 |
+ |||
| Foo | +
+
+
+ |
+ 100.00% |
+ 1 / 1 |
+
+
+
+ |
+ 100.00% |
+ 1 / 1 |
+ 1 | +
+
+
+ |
+ 100.00% |
+ 0 / 0 |
+
| bar | +
+
+
+ |
+ 100.00% |
+ 1 / 1 |
+ 1 | +
+
+
+ |
+ 100.00% |
+ 0 / 0 |
+ |||
| Bar | +
+
+
+ |
+ 100.00% |
+ 1 / 1 |
+
+
+
+ |
+ 100.00% |
+ 1 / 1 |
+ 1 | +
+
+
+ |
+ 100.00% |
+ 0 / 0 |
+
| foo | +
+
+
+ |
+ 100.00% |
+ 1 / 1 |
+ 1 | +
+
+
+ |
+ 100.00% |
+ 0 / 0 |
+ |||
| <?php | |
| if ($neverHappens) { | |
| // @codeCoverageIgnoreStart | |
| print '*'; | |
| // @codeCoverageIgnoreEnd | |
| } | |
| /** | |
| * @codeCoverageIgnore | |
| */ | |
| class Foo | |
| { | |
| public function bar() | |
| { | |
| } | |
| } | |
| class Bar | |
| { | |
| /** | |
| * @codeCoverageIgnore | |
| */ | |
| public function foo() | |
| { | |
| } | |
| } | |
| function baz() | |
| { | |
| print '*'; // @codeCoverageIgnore | |
| } | |
| interface Bor | |
| { | |
| public function foo(); | |
| } |