Skip to content

Run the ORM tests using an attribute driver when able #1517

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

Merged
merged 1 commit into from
Oct 17, 2023
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
3 changes: 3 additions & 0 deletions tests/Fixtures/Doctrine/Embeddable/BlogPostSeo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@

namespace JMS\Serializer\Tests\Fixtures\Doctrine\Embeddable;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Embeddable()
*/
#[ORM\Embeddable]
class BlogPostSeo
{
/**
* @ORM\Column(type="string", name="meta_title")
*
* @var string
*/
#[ORM\Column(type: Types::STRING, name: 'meta_title')]
private $metaTitle;
}
6 changes: 6 additions & 0 deletions tests/Fixtures/Doctrine/Embeddable/BlogPostWithEmbedded.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,28 @@

namespace JMS\Serializer\Tests\Fixtures\Doctrine\Embeddable;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
*/
#[ORM\Entity]
class BlogPostWithEmbedded
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(type: Types::INTEGER)]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected $id;

/**
* @ORM\Embedded(class="BlogPostSeo", columnPrefix="seo_")
*/
#[ORM\Embedded(class: BlogPostSeo::class, columnPrefix: 'seo_')]
private $seo;
}
7 changes: 7 additions & 0 deletions tests/Fixtures/Doctrine/Entity/Author.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

namespace JMS\Serializer\Tests\Fixtures\Doctrine\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation\Groups;
use JMS\Serializer\Annotation\SerializedName;

/** @ORM\Entity */
#[ORM\Entity]
class Author
{
/**
Expand All @@ -17,13 +19,18 @@ class Author
*
* @Groups({"id_group"})
*/
#[ORM\Id]
#[ORM\Column(type: Types::INTEGER)]
#[Groups(groups: ['id_group'])]
protected $id;

/**
* @ORM\Column(type="string")
*
* @SerializedName("full_name")
*/
#[ORM\Column(type: Types::STRING)]
#[SerializedName(name: 'full_name')]
private $name;

public function __construct($name, $id = null)
Expand Down
5 changes: 5 additions & 0 deletions tests/Fixtures/Doctrine/Entity/AuthorExcludedId.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

namespace JMS\Serializer\Tests\Fixtures\Doctrine\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation\Exclude;
use JMS\Serializer\Annotation\SerializedName;

/** @ORM\Entity */
#[ORM\Entity]
class AuthorExcludedId
{
/**
Expand All @@ -17,6 +19,8 @@ class AuthorExcludedId
*
* @Exclude
*/
#[ORM\Id]
#[ORM\Column(type: Types::INTEGER)]
#[Exclude]
protected $id;

Expand All @@ -25,6 +29,7 @@ class AuthorExcludedId
*
* @SerializedName("full_name")
*/
#[ORM\Column(type: Types::STRING)]
#[SerializedName(name: 'full_name')]
private $name;

Expand Down
15 changes: 14 additions & 1 deletion tests/Fixtures/Doctrine/Entity/BlogPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace JMS\Serializer\Tests\Fixtures\Doctrine\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\Groups;
Expand All @@ -19,6 +20,7 @@
*
* @XmlRoot("blog-post")
*/
#[ORM\Entity]
#[XmlRoot(name: 'blog-post')]
class BlogPost
{
Expand All @@ -27,31 +29,38 @@ class BlogPost
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(type: Types::INTEGER)]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected $id;

/**
* @ORM\Column(type="guid")
*/
#[ORM\Column(type: Types::GUID)]
private $guid;

/**
* @ORM\Column(type="string")
*
* @Groups({"comments","post"})
*/
#[ORM\Column(type: Types::STRING)]
#[Groups(groups: ['comments', 'post'])]
private $title;

/**
* @ORM\Column(type="some_custom_type")
*/
#[ORM\Column(type: 'some_custom_type')]
protected $slug;

/**
* @ORM\Column(type="datetime")
*
* @XmlAttribute
*/
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
#[XmlAttribute]
private $createdAt;

Expand All @@ -66,6 +75,7 @@ class BlogPost
* @Groups({"post"})
* @XmlAttribute
*/
#[ORM\Column(type: Types::BOOLEAN)]
#[Type(name: 'integer')]
#[SerializedName(name: 'is_published')]
#[Groups(groups: ['post'])]
Expand All @@ -78,6 +88,7 @@ class BlogPost
* @XmlList(inline=true, entry="comment")
* @Groups({"comments"})
*/
#[ORM\OneToMany(targetEntity: Comment::class, mappedBy: 'blogPost')]
#[XmlList(entry: 'comment', inline: true)]
#[Groups(groups: ['comments'])]
private $comments;
Expand All @@ -87,13 +98,15 @@ class BlogPost
*
* @Groups({"post"})
*/
#[ORM\OneToOne(targetEntity: Author::class)]
#[Groups(groups: ['post'])]
private $author;

/**
* @Serializer\Exclude()
* @ORM\Column(type="integer")
* @Serializer\Exclude()
*/
#[ORM\Column(type: Types::INTEGER)]
#[Serializer\Exclude]
private $ref;

Expand Down
9 changes: 8 additions & 1 deletion tests/Fixtures/Doctrine/Entity/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,35 @@
namespace JMS\Serializer\Tests\Fixtures\Doctrine\Entity;

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

/** @ORM\Entity */
#[ORM\Entity]
class Comment
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\Column(type: Types::INTEGER)]
protected $id;

/**
* @ORM\Column(type="Author")
* @ORM\OneToOne(targetEntity="Author")
*/
#[ORM\OneToOne(targetEntity: Author::class)]
private $author;

/** @ORM\ManyToOne(targetEntity="BlogPost") */
#[ORM\ManyToOne(targetEntity: BlogPost::class)]
private $blogPost;

/**
* @ORM\Column(type="string")
*/
#[ORM\Column(type: Types::STRING)]
private $text;

public function __construct(Author $author, $text)
Expand Down
7 changes: 7 additions & 0 deletions tests/Fixtures/Doctrine/IdentityFields/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

namespace JMS\Serializer\Tests\Fixtures\Doctrine\IdentityFields;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;

/** @ORM\Entity */
#[ORM\Entity]
class Server
{
/**
Expand All @@ -18,6 +20,8 @@ class Server
* @var string
*/
#[Serializer\Type(name: 'string')]
#[ORM\Id]
#[ORM\Column(type: Types::STRING, name: 'ip_address')]
protected $ipAddress;

/**
Expand All @@ -30,6 +34,8 @@ class Server
*/
#[Serializer\SerializedName(name: 'server_id_extracted')]
#[Serializer\Type(name: 'string')]
#[ORM\Id]
#[ORM\Column(type: Types::STRING, name: 'server_id')]
protected $serverId;

/**
Expand All @@ -39,6 +45,7 @@ class Server
* @var string
*/
#[Serializer\Type(name: 'string')]
#[ORM\Column(type: Types::STRING)]
private $name;

/**
Expand Down
8 changes: 8 additions & 0 deletions tests/Fixtures/Doctrine/PersistendCollection/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

namespace JMS\Serializer\Tests\Fixtures\Doctrine\PersistendCollection;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;

/** @ORM\Entity */
#[ORM\Entity]
class App
{
/**
Expand All @@ -18,7 +20,10 @@ class App
*
* @var string
*/
#[Serializer\SerializedName(name: 'id')]
#[Serializer\Type(name: 'string')]
#[ORM\Id]
#[ORM\Column(type: Types::STRING, name: 'id')]
protected $id;

/**
Expand All @@ -28,13 +33,16 @@ class App
* @var string
*/
#[Serializer\Type(name: 'string')]
#[ORM\Column(type: Types::STRING)]
private $name;

/**
* @ORM\ManyToOne(targetEntity="SmartPhone")
* @Serializer\Type("JMS\Serializer\Tests\Fixtures\Doctrine\PersistendCollection\SmartPhone")
*
* @var SmartPhone
*/
#[ORM\ManyToOne(targetEntity: SmartPhone::class)]
#[Serializer\Type(name: SmartPhone::class)]
private $smartPhone;

Expand Down
6 changes: 6 additions & 0 deletions tests/Fixtures/Doctrine/PersistendCollection/SmartPhone.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;

/** @ORM\Entity */
#[ORM\Entity]
class SmartPhone
{
/**
Expand All @@ -23,6 +25,8 @@ class SmartPhone
*/
#[Serializer\SerializedName(name: 'id')]
#[Serializer\Type(name: 'string')]
#[ORM\Id]
#[ORM\Column(type: Types::STRING, name: 'id')]
protected $id;

/**
Expand All @@ -32,6 +36,7 @@ class SmartPhone
* @var string
*/
#[Serializer\Type(name: 'string')]
#[ORM\Column(type: Types::STRING)]
private $name;

/**
Expand All @@ -43,6 +48,7 @@ class SmartPhone
*/
#[Serializer\SerializedName(name: 'applications')]
#[Serializer\Type(name: 'ArrayCollection<JMS\Serializer\Tests\Fixtures\Doctrine\PersistendCollection\App>')]
#[ORM\OneToMany(targetEntity: App::class, mappedBy: 'smartPhone', cascade: ['persist'], orphanRemoval: true)]
private $apps;

/**
Expand Down
7 changes: 7 additions & 0 deletions tests/Fixtures/Doctrine/SingleTableInheritance/Clazz.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,31 @@
namespace JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance;

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

/**
* @ORM\Entity
*/
#[ORM\Entity]
class Clazz extends AbstractModel
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(type: Types::INTEGER)]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private $id;

/** @ORM\ManyToOne(targetEntity = "JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Teacher") */
#[ORM\ManyToOne(targetEntity: Teacher::class)]
private $teacher;

/** @ORM\ManyToMany(targetEntity = "JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Student") */
#[ORM\ManyToMany(targetEntity: Student::class)]
private $students;

public function __construct(Teacher $teacher, array $students)
Expand Down
Loading