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

[wip] Support for ORM 3 #753

Open
wants to merge 6 commits into
base: 6.2.x
Choose a base branch
from
Open
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
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,24 @@
"require": {
"php": "~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0",
"ext-json": "*",
"doctrine/dbal": "^2.13.7 || ^3.3.2",
"doctrine/dbal": "^2.13.7 || ^3.3.2 || ~4.0.0",
"doctrine/doctrine-laminas-hydrator": "^3.0.0",
"doctrine/doctrine-module": "^5.3.0 || ^6.0.2",
"doctrine/event-manager": "^1.1.1",
"doctrine/orm": "^2.11.1",
"doctrine/event-manager": "^1.1.1 || ^2.0.0",
"doctrine/orm": "^3.0.0",
"doctrine/persistence": "^2.3.0 || ^3.0.0",
"laminas/laminas-eventmanager": "^3.4.0",
"laminas/laminas-modulemanager": "^2.11.0",
"laminas/laminas-mvc": "^3.3.2",
"laminas/laminas-paginator": "^2.12.2",
"laminas/laminas-servicemanager": "^3.17.0",
"laminas/laminas-stdlib": "^3.7.1",
"psr/container": "^1.1.2",
"symfony/console": "^5.4.3 || ^6.0.3"
"psr/container": "^1.1.2 || ^2.0.0",
"symfony/console": "^5.4.3 || ^6.0.3 || ^7.0.0"
},
"require-dev": {
"doctrine/annotations": "^1.13.2",
"doctrine/coding-standard": "^9.0.0",
"doctrine/annotations": "^2.0",
"doctrine/coding-standard": "^12.0.0",
"doctrine/data-fixtures": "^1.5.2",
"doctrine/migrations": "^3.4.1",
"laminas/laminas-cache-storage-adapter-filesystem": "^2.0",
Expand All @@ -80,7 +80,7 @@
"ocramius/proxy-manager": "^2.2.0",
"phpstan/phpstan": "^1.4.6",
"phpstan/phpstan-phpunit": "^1.0.0",
"phpunit/phpunit": "^9.5.13",
"phpunit/phpunit": "^10.0.0",
"squizlabs/php_codesniffer": "^3.6.2",
"vimeo/psalm": "^5.4.0"
},
Expand Down
60 changes: 60 additions & 0 deletions tests/Assets/Entity/Auth.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

declare(strict_types=1);

namespace DoctrineORMModuleTest\Assets\Entity;

use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
#[ORM\Table(name: 'doctrine_orm_module_auth')]
class Auth
{
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private int $id;

#[ORM\Column(type: 'string', nullable: true)]
private string $username;

#[ORM\Column(type: 'string', nullable: true)]
private string $password;

public function getId(): int|null
{
return $this->id;
}

public function setPassword(string $password): self
{
$this->password = $password;

return $this;
}

public function getPassword(): string|null
{
return $this->password;
}

public function setUsername(string $username): self
{
$this->username = $username;

return $this;
}

public function getUsername(): string|null
{
return $this->username;
}

/**
* Used for testing DoctrineEntity form element
*/
public function __toString(): string
{
return (string) $this->username;
}
}
27 changes: 16 additions & 11 deletions tests/Assets/Entity/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,30 @@

namespace DoctrineORMModuleTest\Assets\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
* @ORM\Table(name="doctrine_orm_module_category")
*/
#[ORM\Entity]
#[ORM\Table(name: 'doctrine_orm_module_category')]
class Category
{
/**
* @ORM\Id
* @ORM\Column(type="integer");
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected int $id;

/** @ORM\Column(type="string", nullable=true) */
#[ORM\Column(type: 'string', nullable: true)]
protected string $name;

public function getId(): ?int
#[ORM\ManyToMany(targetEntity: Product::class, mappedBy: 'categories')]
private ArrayCollection $products;

public function __construct()
{
$this->products = new ArrayCollection();
}

public function getId(): int|null
{
return $this->id;
}
Expand Down
21 changes: 9 additions & 12 deletions tests/Assets/Entity/City.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,23 @@

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
* @ORM\Table(name="doctrine_orm_module_city")
*/
#[ORM\Entity]
#[ORM\Table(name: 'doctrine_orm_module_city')]
class City
{
/**
* @ORM\Id
* @ORM\Column(type="integer");
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected int $id;

/** @ORM\Column(type="string", nullable=true) */
#[ORM\Column(type: 'string', nullable: true)]
protected string $name;

/** @ORM\OneToOne(targetEntity="Country") */
#[ORM\OneToOne(targetEntity: Country::class, inversedBy: 'city')]
#[ORM\JoinColumn(name: 'country_id', referencedColumnName: 'id', unique: true)]
protected Country $country;

public function getId(): ?int
public function getId(): int|null
{
return $this->id;
}
Expand Down
21 changes: 10 additions & 11 deletions tests/Assets/Entity/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,22 @@

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
* @ORM\Table(name="doctrine_orm_module_country")
*/
#[ORM\Entity]
#[ORM\Table(name: 'doctrine_orm_module_country')]
class Country
{
/**
* @ORM\Id
* @ORM\Column(type="integer");
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected int $id;

/** @ORM\Column(type="string", nullable=true) */
#[ORM\Column(type: 'string', nullable: true)]
protected string $name;

public function getId(): ?int
#[ORM\OneToOne(targetEntity: City::class, mappedBy: 'country')]
private City $city;

public function getId(): int|null
{
return $this->id;
}
Expand Down
22 changes: 10 additions & 12 deletions tests/Assets/Entity/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,28 @@
use DateTime;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
* @ORM\Table(name="doctrine_orm_module_date")
*/
#[ORM\Entity]
#[ORM\Table(name: 'doctrine_orm_module_date')]
class Date
{
/**
* @ORM\Id
* @ORM\Column(type="integer");
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected int $id;

/** @ORM\Column(type="date", nullable=true) */
#[ORM\Column(type: 'date', nullable: true)]
protected DateTime $date;

public function getId(): ?int
public function getId(): int|null
{
return $this->id;
}

public function setDate(DateTime $date): void
public function setDate(DateTime $date): self
{
$this->date = $date;

return $this;
}

public function getDate(): DateTime
Expand Down
Loading
Loading