Skip to content

Commit

Permalink
Adapted #123 for one line annotations. Hopefully
Browse files Browse the repository at this point in the history
  • Loading branch information
edorian committed Oct 4, 2012
1 parent e0abfbc commit 45c5be8
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion PHP/CodeCoverage/Util.php
Expand Up @@ -122,7 +122,7 @@ public static function getLinesToBeIgnored($filename, $cacheTokens = TRUE)

// Workaround for the fact the DOC_COMMENT token does
// not include the final \n character in its text.
if (trim($lines[$i-1]) == '*/') {
if (substr(trim($lines[$i-1]), -2) == '*/') {
self::$ignoredLines[$filename][$i] = TRUE;
}
}
Expand Down
1 change: 1 addition & 0 deletions Tests/PHP/CodeCoverage/FilterTest.php
Expand Up @@ -107,6 +107,7 @@ protected function setUp()
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'
);
Expand Down
25 changes: 25 additions & 0 deletions Tests/PHP/CodeCoverage/UtilTest.php
Expand Up @@ -155,6 +155,31 @@ public function testGetLinesToBeIgnored2()
);
}

/**
* @covers PHP_CodeCoverage_Util::getLinesToBeIgnored
*/
public function testGetLinesToBeIgnoredOneLineAnnotations()
{
$this->assertEquals(
array(
1 => TRUE,
2 => TRUE,
7 => TRUE,
3 => TRUE,
4 => TRUE,
5 => TRUE,
6 => TRUE,
8 => TRUE,
9 => TRUE,
13 => TRUE,
),
PHP_CodeCoverage_Util::getLinesToBeIgnored(
TEST_FILES_PATH . 'source_with_oneline_annotations.php'
)
);
}


/**
* @covers PHP_CodeCoverage_Util::percent
*/
Expand Down
13 changes: 13 additions & 0 deletions Tests/_files/source_with_oneline_annotations.php
@@ -0,0 +1,13 @@
<?php

/** Docblock */
interface {
public function bar();
}

class Foo
{
public function bar()
{
}
}

0 comments on commit 45c5be8

Please sign in to comment.