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

Add missing imports of annotations. #7907

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Mapping/AssociationOverride.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

namespace Doctrine\ORM\Mapping;

use Doctrine\Common\Annotations\Annotation\Enum;

/**
* This annotation is used to override association mapping of property for an entity relationship.
*
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Mapping/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

namespace Doctrine\ORM\Mapping;

use Doctrine\Common\Annotations\Annotation\Enum;

/**
* Caching to an entity or a collection.
*
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

namespace Doctrine\ORM\Mapping;

use Doctrine\Common\Annotations\Annotation\Enum;

/**
* @Annotation
* @Target("CLASS")
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Mapping/GeneratedValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

namespace Doctrine\ORM\Mapping;

use Doctrine\Common\Annotations\Annotation\Enum;

/**
* @Annotation
* @Target("PROPERTY")
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Mapping/InheritanceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

namespace Doctrine\ORM\Mapping;

use Doctrine\Common\Annotations\Annotation\Enum;

/**
* @Annotation
* @Target("CLASS")
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Mapping/ManyToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

namespace Doctrine\ORM\Mapping;

use Doctrine\Common\Annotations\Annotation\Enum;

/**
* @Annotation
* @Target("PROPERTY")
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Mapping/ManyToOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

namespace Doctrine\ORM\Mapping;

use Doctrine\Common\Annotations\Annotation\Enum;

/**
* @Annotation
* @Target("PROPERTY")
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Mapping/OneToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

namespace Doctrine\ORM\Mapping;

use Doctrine\Common\Annotations\Annotation\Enum;

/**
* @Annotation
* @Target("PROPERTY")
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Mapping/OneToOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

namespace Doctrine\ORM\Mapping;

use Doctrine\Common\Annotations\Annotation\Enum;

/**
* @Annotation
* @Target("PROPERTY")
Expand Down
77 changes: 77 additions & 0 deletions tests/Doctrine/Tests/ORM/Mapping/ImportsAnnotationsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

namespace Doctrine\Tests\ORM\Mapping;

use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\ORM\Mapping\AssociationOverride;
use Doctrine\ORM\Mapping\Cache;
use Doctrine\ORM\Mapping\ChangeTrackingPolicy;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\InheritanceType;
use Doctrine\ORM\Mapping\ManyToMany;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\ORM\Mapping\OneToOne;
use Doctrine\Tests\OrmTestCase;
use ReflectionClass;

class ImportsAnnotationsTest extends OrmTestCase
{
/**
* @var AnnotationReader
*/
private $annotationReader;

/**
* {@inheritDoc}
*/
protected function setUp()
{
// If using non-default annotation reader, everything working.
//$this->annotationReader = $this->createAnnotationDriver()->getReader();

// ... but if use a default annotation reader is there a problem.
$this->annotationReader = new AnnotationReader();
}

/**
* If exception was thrown so is there a error during parsing something with class.
*
* @dataProvider dataProviderReflectionClass
*
* @param ReflectionClass $reflectionClass
*
* @return void
*/
public function testClassShouldValidImportedAnnotations($reflectionClass)
{
$this->assertIsArray($this->annotationReader->getClassAnnotations($reflectionClass));

foreach ($reflectionClass->getMethods() as $reflectionMethod) {
$this->assertIsArray($this->annotationReader->getMethodAnnotations($reflectionMethod));
}

foreach ($reflectionClass->getProperties() as $reflectionProperty) {
$this->assertIsArray($this->annotationReader->getPropertyAnnotations($reflectionProperty));
}
}

/**
* @throws \ReflectionException
* @return ReflectionClass[]
*/
public function dataProviderReflectionClass()
{
return [
[new ReflectionClass(AssociationOverride::class)],
[new ReflectionClass(Cache::class)],
[new ReflectionClass(ChangeTrackingPolicy::class)],
[new ReflectionClass(GeneratedValue::class)],
[new ReflectionClass(InheritanceType::class)],
[new ReflectionClass(ManyToMany::class)],
[new ReflectionClass(ManyToOne::class)],
[new ReflectionClass(OneToMany::class)],
[new ReflectionClass(OneToOne::class)],
];
}
}