Skip to content

Commit

Permalink
Merge branch 'fix/#110-setIgnoreNotImportedAnnotations-fails-on-alrea…
Browse files Browse the repository at this point in the history
…dy-autoloaded-classes'
  • Loading branch information
Ocramius committed Dec 30, 2016
2 parents a0adee8 + d4bdb84 commit 0d9fb6d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/Common/Annotations/DocParser.php
Expand Up @@ -742,7 +742,7 @@ private function Annotation()

// verify that the class is really meant to be an annotation and not just any ordinary class
if (self::$annotationMetadata[$name]['is_annotation'] === false) {
if (isset($this->ignoredAnnotationNames[$originalName])) {
if ($this->ignoreNotImportedAnnotations || isset($this->ignoredAnnotationNames[$originalName])) {
return false;
}

Expand Down
9 changes: 9 additions & 0 deletions tests/Doctrine/Tests/Common/Annotations/DocParserTest.php
Expand Up @@ -1049,6 +1049,15 @@ public function testNotAnAnnotationClassIsIgnoredWithoutWarning()
$this->assertEquals(0, count($result));
}

public function testNotAnAnnotationClassIsIgnoredWithoutWarningWithoutCheating()
{
$parser = new DocParser();
$parser->setIgnoreNotImportedAnnotations(true);
$result = $parser->parse('@PHPUnit_Framework_TestCase');

$this->assertEmpty($result);
}

/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage Expected PlainValue, got ''' at position 10.
Expand Down
Expand Up @@ -61,11 +61,24 @@ public function testClassWithInvalidAnnotationTargetAtMethodDocBlock()
}

/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* Contrary to the behavior of the default annotation reader, we do just ignore
* these in the simple annotation reader (so, no expected exception here).
*/
public function testErrorWhenInvalidAnnotationIsUsed()
{
parent::testErrorWhenInvalidAnnotationIsUsed();
}

/**
* The SimpleAnnotationReader doens't include the @IgnoreAnnotation in the results.
*/
public function testInvalidAnnotationUsageButIgnoredClass()
{
parent::testInvalidAnnotationUsageButIgnoredClass();
$reader = $this->getReader();
$ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\InvalidAnnotationUsageButIgnoredClass');
$annots = $reader->getClassAnnotations($ref);

$this->assertCount(1, $annots);
}

public function testIncludeIgnoreAnnotation()
Expand Down

0 comments on commit 0d9fb6d

Please sign in to comment.