Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setIgnoreNotImportedAnnotations(true) doesn't work on already autoloaded classes #110

Merged
merged 2 commits into from Dec 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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->assertEquals(0, count($result));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertCount

}

/**
* @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->assertEquals(1, count($annots));
}

public function testIncludeIgnoreAnnotation()
Expand Down