diff --git a/composer.json b/composer.json index 50ac8a82..e1005f58 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "doctrine/orm": "^2.15" }, "require-dev": { - "doctrine/annotations": "^1.14", + "doctrine/annotations": "^1.14 || ^2", "doctrine/coding-standard": "^9.0.2 || ^12.0", "nesbot/carbon": "*", "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", diff --git a/tests/Entities/Blank.php b/tests/Entities/Blank.php index 4963e9e0..abb8e8b6 100644 --- a/tests/Entities/Blank.php +++ b/tests/Entities/Blank.php @@ -2,13 +2,15 @@ namespace DoctrineExtensions\Tests\Entities; -/** @Entity */ +use Doctrine\ORM\Mapping as ORM; + +/** @ORM\Entity */ class Blank { /** - * @Id - * @Column(type="string") - * @GeneratedValue + * @ORM\Id + * @ORM\Column(type="string") + * @ORM\GeneratedValue */ public $id; } diff --git a/tests/Entities/BlogPost.php b/tests/Entities/BlogPost.php index ca1c372d..b33c83b2 100644 --- a/tests/Entities/BlogPost.php +++ b/tests/Entities/BlogPost.php @@ -2,22 +2,24 @@ namespace DoctrineExtensions\Tests\Entities; -/** @Entity */ +use Doctrine\ORM\Mapping as ORM; + +/** @ORM\Entity */ class BlogPost { /** - * @Id - * @Column(type="string") - * @GeneratedValue + * @ORM\Id + * @ORM\Column(type="string") + * @ORM\GeneratedValue */ public $id; - /** @Column(type="DateTime") */ + /** @ORM\Column(type="DateTime") */ public $created; - /** @Column(type="decimal", precision=12, scale=8) */ + /** @ORM\Column(type="decimal", precision=12, scale=8) */ public $longitude; - /** @Column(type="decimal", precision=12, scale=8) */ + /** @ORM\Column(type="decimal", precision=12, scale=8) */ public $latitude; } diff --git a/tests/Entities/CarbonDate.php b/tests/Entities/CarbonDate.php index 375b479d..49e1f231 100644 --- a/tests/Entities/CarbonDate.php +++ b/tests/Entities/CarbonDate.php @@ -2,39 +2,38 @@ namespace DoctrineExtensions\Tests\Entities; -/** - * @Entity - * @Table - */ +use Doctrine\ORM\Mapping as ORM; + +/** @ORM\Entity */ class CarbonDate { /** - * @Id - * @Column(type="integer") + * @ORM\Id + * @ORM\Column(type="integer") */ public $id; - /** @Column(type="CarbonDate", nullable=true) */ + /** @ORM\Column(type="CarbonDate", nullable=true) */ public $date; - /** @Column(type="CarbonDateTime", nullable=true) */ + /** @ORM\Column(type="CarbonDateTime", nullable=true) */ public $datetime; - /** @Column(type="CarbonDateTimeTz", nullable=true) */ + /** @ORM\Column(type="CarbonDateTimeTz", nullable=true) */ public $datetimeTz; - /** @Column(type="CarbonTime", nullable=true) */ + /** @ORM\Column(type="CarbonTime", nullable=true) */ public $time; - /** @Column(type="CarbonImmutableDate", nullable=true) */ + /** @ORM\Column(type="CarbonImmutableDate", nullable=true) */ public $dateImmutable; - /** @Column(type="CarbonImmutableDateTime", nullable=true) */ + /** @ORM\Column(type="CarbonImmutableDateTime", nullable=true) */ public $datetimeImmutable; - /** @Column(type="CarbonImmutableDateTimeTz", nullable=true) */ + /** @ORM\Column(type="CarbonImmutableDateTimeTz", nullable=true) */ public $datetimeTzImmutable; - /** @Column(type="CarbonImmutableTime", nullable=true) */ + /** @ORM\Column(type="CarbonImmutableTime", nullable=true) */ public $timeImmutable; } diff --git a/tests/Entities/Date.php b/tests/Entities/Date.php index 904fe987..7217d305 100644 --- a/tests/Entities/Date.php +++ b/tests/Entities/Date.php @@ -2,16 +2,18 @@ namespace DoctrineExtensions\Tests\Entities; -/** @Entity */ +use Doctrine\ORM\Mapping as ORM; + +/** @ORM\Entity */ class Date { /** - * @Id - * @Column(type="string") - * @GeneratedValue + * @ORM\Id + * @ORM\Column(type="string") + * @ORM\GeneratedValue */ public $id; - /** @Column(type="datetime") */ + /** @ORM\Column(type="datetime") */ public $created; } diff --git a/tests/Entities/Product.php b/tests/Entities/Product.php index 772251b0..41b1cc5a 100644 --- a/tests/Entities/Product.php +++ b/tests/Entities/Product.php @@ -2,25 +2,27 @@ namespace DoctrineExtensions\Tests\Entities; -/** @Entity */ +use Doctrine\ORM\Mapping as ORM; + +/** @ORM\Entity */ class Product { /** - * @Id - * @Column(type="string") - * @GeneratedValue + * @ORM\Id + * @ORM\Column(type="string") + * @ORM\GeneratedValue */ public $id; - /** @Column(type="string") */ + /** @ORM\Column(type="string") */ public $name; - /** @Column(type="DateTime") */ + /** @ORM\Column(type="DateTime") */ public $created; - /** @Column(type="decimal", precision=10, scale=2) */ + /** @ORM\Column(type="decimal", precision=10, scale=2) */ public $price; - /** @Column(type="decimal", precision=5, scale=2) */ + /** @ORM\Column(type="decimal", precision=5, scale=2) */ public $weight; } diff --git a/tests/Entities/Set.php b/tests/Entities/Set.php index 810fc2f8..9f6de54a 100644 --- a/tests/Entities/Set.php +++ b/tests/Entities/Set.php @@ -2,16 +2,18 @@ namespace DoctrineExtensions\Tests\Entities; -/** @Entity */ +use Doctrine\ORM\Mapping as ORM; + +/** @ORM\Entity */ class Set { /** - * @Id - * @Column(type="string") - * @GeneratedValue + * @ORM\Id + * @ORM\Column(type="string") + * @ORM\GeneratedValue */ public $id; - /** @Column(type="String") */ + /** @ORM\Column(type="String") */ public $set; } diff --git a/tests/Entities/ZendDate.php b/tests/Entities/ZendDate.php index 576698d5..413e1123 100644 --- a/tests/Entities/ZendDate.php +++ b/tests/Entities/ZendDate.php @@ -2,19 +2,18 @@ namespace DoctrineExtensions\Tests\Entities; -/** - * @Entity - * @Table - */ +use Doctrine\ORM\Mapping as ORM; + +/** @ORM\Entity */ class ZendDate { /** - * @Id - * @Column(type="integer") + * @ORM\Id + * @ORM\Column(type="integer") */ public $id; - /** @Column(type="ZendDate") */ + /** @ORM\Column(type="ZendDate") */ public $date; public function __construct($id, $date) diff --git a/tests/Query/DbTestCase.php b/tests/Query/DbTestCase.php index 796cae0f..b4c43f0a 100644 --- a/tests/Query/DbTestCase.php +++ b/tests/Query/DbTestCase.php @@ -2,8 +2,10 @@ namespace DoctrineExtensions\Tests\Query; +use Doctrine\DBAL\DriverManager; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManager; +use Doctrine\ORM\ORMSetup; use PHPUnit\Framework\TestCase; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -23,8 +25,11 @@ public function setUp(): void $this->configuration->setProxyDir(__DIR__ . '/Proxies'); $this->configuration->setProxyNamespace('DoctrineExtensions\Tests\Proxies'); $this->configuration->setAutoGenerateProxyClasses(true); - $this->configuration->setMetadataDriverImpl($this->configuration->newDefaultAnnotationDriver(__DIR__ . '/../Entities')); - $this->entityManager = EntityManager::create(['driver' => 'pdo_sqlite', 'memory' => true], $this->configuration); + $this->configuration->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver([__DIR__ . '/../Entities'])); + $this->entityManager = new EntityManager( + DriverManager::getConnection(['driver' => 'pdo_sqlite', 'memory' => true], $this->configuration), + $this->configuration + ); } public function assertDqlProducesSql($actualDql, $expectedSql, $params = []): void diff --git a/tests/Types/CarbonDateTest.php b/tests/Types/CarbonDateTest.php index ab26a855..15bf8499 100755 --- a/tests/Types/CarbonDateTest.php +++ b/tests/Types/CarbonDateTest.php @@ -4,10 +4,12 @@ use Carbon\Carbon; use Carbon\CarbonImmutable; +use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManager; +use Doctrine\ORM\ORMSetup; use Doctrine\ORM\Tools\SchemaTool; use DoctrineExtensions\Tests\Entities\CarbonDate as Entity; use PHPUnit\Framework\TestCase; @@ -44,13 +46,13 @@ public function setUp(): void $config->setProxyDir(__DIR__ . '/Proxies'); $config->setProxyNamespace('DoctrineExtensions\Tests\PHPUnit\Proxies'); $config->setAutoGenerateProxyClasses(true); - $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(__DIR__ . '/../../Entities')); + $config->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver([__DIR__ . '/../../Entities'])); - $this->em = EntityManager::create( - [ + $this->em = new EntityManager( + DriverManager::getConnection([ 'driver' => 'pdo_sqlite', 'memory' => true, - ], + ], $config), $config ); diff --git a/tests/Types/ZendDateTest.php b/tests/Types/ZendDateTest.php index 0ca900aa..f84c00e5 100755 --- a/tests/Types/ZendDateTest.php +++ b/tests/Types/ZendDateTest.php @@ -2,10 +2,12 @@ namespace DoctrineExtensions\Tests\Types; +use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManager; +use Doctrine\ORM\ORMSetup; use Doctrine\ORM\Tools\SchemaTool; use DoctrineExtensions\Tests\Entities\ZendDate; use PHPUnit\Framework\TestCase; @@ -39,13 +41,13 @@ public function setUp(): void $config->setProxyDir(__DIR__ . '/Proxies'); $config->setProxyNamespace('DoctrineExtensions\Tests\PHPUnit\Proxies'); $config->setAutoGenerateProxyClasses(true); - $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(__DIR__ . '/../../Entities')); + $config->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver([__DIR__ . '/../../Entities'])); - $this->em = EntityManager::create( - [ + $this->em = new EntityManager( + DriverManager::getConnection([ 'driver' => 'pdo_sqlite', 'memory' => true, - ], + ], $config), $config );