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

Run tests with Doctrine Annotations 2 #428

Merged
merged 1 commit into from
Feb 5, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 6 additions & 4 deletions tests/Entities/Blank.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
16 changes: 9 additions & 7 deletions tests/Entities/BlogPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
27 changes: 13 additions & 14 deletions tests/Entities/CarbonDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
12 changes: 7 additions & 5 deletions tests/Entities/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
18 changes: 10 additions & 8 deletions tests/Entities/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
12 changes: 7 additions & 5 deletions tests/Entities/Set.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
13 changes: 6 additions & 7 deletions tests/Entities/ZendDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions tests/Query/DbTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down
10 changes: 6 additions & 4 deletions tests/Types/CarbonDateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
);

Expand Down
10 changes: 6 additions & 4 deletions tests/Types/ZendDateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
);

Expand Down
Loading