Skip to content

Commit

Permalink
Remove usage of ORM's annotation driver
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Mar 8, 2024
1 parent e01cf5e commit dfd5870
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 124 deletions.
10 changes: 2 additions & 8 deletions tests/Common/DataFixtures/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

use function method_exists;

use const PHP_VERSION_ID;

/**
* Base test class
*/
Expand All @@ -26,12 +24,8 @@ abstract class BaseTestCase extends TestCase
protected function getMockSqliteEntityManager(string $fixtureSet = 'TestEntity'): EntityManager
{
$dbParams = ['driver' => 'sqlite3', 'memory' => true];
if (PHP_VERSION_ID >= 80100) {
$config = ORMSetup::createAttributeMetadataConfiguration([__DIR__ . '/' . $fixtureSet], true);
$config->setLazyGhostObjectEnabled(true);
} else {
$config = ORMSetup::createAnnotationMetadataConfiguration([__DIR__ . '/' . $fixtureSet], true);
}
$config = ORMSetup::createAttributeMetadataConfiguration([__DIR__ . '/' . $fixtureSet], true);

Check failure on line 27 in tests/Common/DataFixtures/BaseTestCase.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.3)

Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space
$config->setLazyGhostObjectEnabled(true);

$connection = DriverManager::getConnection($dbParams, $config);
$platform = $connection->getDatabasePlatform();
Expand Down
9 changes: 0 additions & 9 deletions tests/Common/DataFixtures/TestEntity/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,13 @@

use Doctrine\ORM\Mapping as ORM;

/** @ORM\Entity() */
#[ORM\Entity]
class Group
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
*/
#[ORM\Column]
#[ORM\Id]
private int|null $id = null;

/**
* @ORM\Column(length=32)
* @ORM\Id
*/
#[ORM\Column(length: 32)]
#[ORM\Id]
private string|null $code = null;
Expand Down
12 changes: 0 additions & 12 deletions tests/Common/DataFixtures/TestEntity/GroupWithSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,14 @@

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity()
* @ORM\Table(name="group",schema="test_schema")
*/
#[ORM\Entity]
#[ORM\Table(name: 'group', schema: 'test_schema')]
class GroupWithSchema
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
*/
#[ORM\Column]
#[ORM\Id]
private int|null $id = null;

/**
* @ORM\Column(length=32)
* @ORM\Id
*/
#[ORM\Column(length: 32)]
#[ORM\Id]
private string|null $code = null;
Expand Down
6 changes: 0 additions & 6 deletions tests/Common/DataFixtures/TestEntity/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,13 @@
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Tests\Common\DataFixtures\TestValueObjects\Uuid;

/** @ORM\Entity */
#[ORM\Entity]
class Link
{
/**
* @ORM\Id
* @ORM\Column(type="uuid")
*/
#[ORM\Id]
#[ORM\Column(type: 'uuid')]
private Uuid $id;

/** @ORM\Column(length=150) */
#[ORM\Column(length: 150)]
private string|null $url = null;

Expand Down
17 changes: 0 additions & 17 deletions tests/Common/DataFixtures/TestEntity/Quoted.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,18 @@
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
* @ORM\Table("`SELECT`")
*/
#[ORM\Entity]
#[ORM\Table(name: '`SELECT`')]
class Quoted
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
#[ORM\Column]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
private int|null $id = null;

/** @ORM\Column(length=50, name="select") */
#[ORM\Column(length: 50, name: '`SELECT`')]
private string|null $select = null;

/**
* @ORM\ManyToMany(targetEntity=Quoted::class)
* @ORM\JoinTable(name="`INSERT`",
* joinColumns={@ORM\JoinColumn(name="`SELECT`", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="`UPDATE`", referencedColumnName="id")}
* )
*/
#[ORM\ManyToMany(targetEntity: self::class)]
#[ORM\JoinTable(name: '`INSERT`')]
#[ORM\JoinColumn(name: '`SELECT`', referencedColumnName: 'id')]
Expand Down
7 changes: 0 additions & 7 deletions tests/Common/DataFixtures/TestEntity/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,14 @@

use Doctrine\ORM\Mapping as ORM;

/** @ORM\Entity */
#[ORM\Entity]
class Role
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
#[ORM\Column]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
private int|null $id = null;

/** @ORM\Column(length=50) */
#[ORM\Column(length: 50)]
private string|null $name = null;

Expand Down
28 changes: 2 additions & 26 deletions tests/Common/DataFixtures/TestEntity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,58 +10,34 @@

use function md5;

/** @ORM\Entity */
#[ORM\Entity]
class User
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
*/
#[ORM\Column]
#[ORM\Id]
private int|null $id = null;

/**
* @ORM\Column(length=32)
* @ORM\Id
*/
#[ORM\Column(length: 32)]
#[ORM\Id]
private string|null $code = null;

/** @ORM\Column(length=32) */
#[ORM\Column(length: 32)]
private string|null $password = null;

/** @ORM\Column(length=255) */
#[ORM\Column(length: 255)]
private string|null $email = null;

/** @ORM\ManyToOne(targetEntity=Role::class, cascade={"persist"}) */
#[ORM\ManyToOne(cascade: ['persist'])]
private Role|null $role = null;

/**
* @ORM\ManyToMany(targetEntity=User::class, inversedBy="authors")
* @ORM\JoinTable(name="author_reader", schema="readers",
* joinColumns={@ORM\JoinColumn(name="author_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="reader_id", referencedColumnName="id")}
* )
*
* @var Collection<int, User>
*/
/** @var Collection<int, User> */
#[ORM\ManyToMany(targetEntity: self::class, inversedBy: 'authors')]
#[ORM\JoinTable(name: 'author_reader', schema: 'readers')]
#[ORM\JoinColumn(name: 'author_id', referencedColumnName: 'id')]
#[ORM\InverseJoinColumn(name: 'reader_id', referencedColumnName: 'id')]
private Collection $readers;

/**
* @ORM\ManyToMany(targetEntity=User::class, mappedBy="readers")
*
* @var Collection<int, User>
*/
/** @var Collection<int, User> */
#[ORM\ManyToMany(targetEntity: self::class, mappedBy: 'readers')]
private Collection $authors;

Expand Down
31 changes: 2 additions & 29 deletions tests/Common/DataFixtures/TestEntity/UserWithSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,62 +10,35 @@

use function md5;

/**
* @ORM\Entity
* @ORM\Table(name="user",schema="test_schema")
*/
#[ORM\Entity]
#[ORM\Table(name: 'user', schema: 'test_schema')]
class UserWithSchema
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
*/
#[ORM\Column]
#[ORM\Id]
private int|null $id = null;

/**
* @ORM\Column(length=32)
* @ORM\Id
*/
#[ORM\Column(length: 32)]
#[ORM\Id]
private string|null $code = null;

/** @ORM\Column(length=32) */
#[ORM\Column(length: 32)]
private string|null $password = null;

/** @ORM\Column(length=255) */
#[ORM\Column(length: 255)]
private string|null $email = null;

/** @ORM\ManyToOne(targetEntity=Role::class, cascade={"persist"}) */
#[ORM\ManyToOne(cascade: ['persist'])]
private Role|null $role = null;

/**
* @ORM\ManyToMany(targetEntity=UserWithSchema::class, inversedBy="authors")
* @ORM\JoinTable(name="author_reader", schema="readers",
* joinColumns={@ORM\JoinColumn(name="author_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="reader_id", referencedColumnName="id")}
* )
*
* @var Collection<int, self>
*/
/** @var Collection<int, self> */
#[ORM\ManyToMany(targetEntity: self::class, inversedBy: 'authors')]
#[ORM\JoinTable(name: 'author_reader', schema: 'readers')]
#[ORM\JoinColumn(name: 'author_id', referencedColumnName: 'id')]
#[ORM\InverseJoinColumn(name: 'reader_id', referencedColumnName: 'id')]
private Collection $readers;

/**
* @ORM\ManyToMany(targetEntity=UserWithSchema::class, mappedBy="readers")
*
* @var Collection<int, self>
*/
/** @var Collection<int, self> */
#[ORM\ManyToMany(targetEntity: self::class, mappedBy: 'readers')]
private Collection $authors;

Expand Down
5 changes: 0 additions & 5 deletions tests/Common/DataFixtures/TestPurgeEntity/ExcludedEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@

use Doctrine\ORM\Mapping as ORM;

/** @ORM\Entity */
#[ORM\Entity]
class ExcludedEntity
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
*/
#[ORM\Column]
#[ORM\Id]
private int|null $id = null;
Expand Down
5 changes: 0 additions & 5 deletions tests/Common/DataFixtures/TestPurgeEntity/IncludedEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@

use Doctrine\ORM\Mapping as ORM;

/** @ORM\Entity */
#[ORM\Entity]
class IncludedEntity
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
*/
#[ORM\Column]
#[ORM\Id]
private int|null $id = null;
Expand Down

0 comments on commit dfd5870

Please sign in to comment.