-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from DATA-DOG/automated-testing-relation
Automated testing relation
- Loading branch information
Showing
3 changed files
with
225 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DataDog\AuditBundle\Tests\Entity; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Doctrine\Common\Collections\Collection; | ||
use Doctrine\DBAL\Types\Types; | ||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
/** | ||
* @ORM\Entity() | ||
* @ORM\Table() | ||
*/ | ||
#[ORM\Entity] | ||
#[ORM\Table] | ||
class Post | ||
{ | ||
/** | ||
* @ORM\Id() | ||
* @ORM\GeneratedValue() | ||
* @ORM\Column(type="integer") | ||
*/ | ||
#[ORM\Id] | ||
#[ORM\GeneratedValue] | ||
#[ORM\Column(type: Types::INTEGER)] | ||
private int $id; | ||
|
||
/** | ||
* @ORM\Column(type="string", length=255) | ||
*/ | ||
#[ORM\Column(type: Types::STRING, length: 255)] | ||
private string $title; | ||
|
||
/** | ||
* @ORM\ManyToMany(targetEntity=Tag::class, inversedBy="posts") | ||
*/ | ||
#[ORM\ManyToMany(targetEntity: Tag::class, inversedBy: 'posts')] | ||
private Collection $tags; | ||
|
||
public function __construct() | ||
{ | ||
$this->tags = new ArrayCollection(); | ||
} | ||
|
||
public function getId(): int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getTitle(): string | ||
{ | ||
return $this->title; | ||
} | ||
|
||
public function setTitle(string $title): self | ||
{ | ||
$this->title = $title; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return Tag[] | ||
*/ | ||
public function getTags(): Collection | ||
{ | ||
return $this->tags; | ||
} | ||
|
||
public function addTag(Tag $tag): self | ||
{ | ||
if (!$this->tags->contains($tag)) { | ||
$this->tags[] = $tag; | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
public function removeTag(Tag $tag): self | ||
{ | ||
if ($this->tags->contains($tag)) { | ||
$this->tags->removeElement($tag); | ||
} | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters