Skip to content

Commit

Permalink
Pass 1 of review Entities
Browse files Browse the repository at this point in the history
  • Loading branch information
TomHAnderson committed Mar 2, 2024
1 parent 86f026f commit c94e4c0
Show file tree
Hide file tree
Showing 9 changed files with 307 additions and 13 deletions.
12 changes: 8 additions & 4 deletions tests/Assets/Entity/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,23 @@ public function getId(): int|null
return $this->id;
}

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

return $this;
}

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

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

return $this;
}

public function getUsername(): string|null
Expand Down
9 changes: 9 additions & 0 deletions tests/Assets/Entity/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace DoctrineORMModuleTest\Assets\Entity;

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

#[ORM\Entity]
Expand All @@ -18,6 +19,14 @@ class Category
#[ORM\Column(type: 'string', nullable: true)]
protected string $name;

#[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
4 changes: 2 additions & 2 deletions tests/Assets/Entity/City.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class City
#[ORM\Column(type: 'string', nullable: true)]
protected string $name;

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

public function getId(): int|null
Expand Down
3 changes: 3 additions & 0 deletions tests/Assets/Entity/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class Country
#[ORM\Column(type: 'string', nullable: true)]
protected string $name;

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

public function getId(): int|null
{
return $this->id;
Expand Down
4 changes: 3 additions & 1 deletion tests/Assets/Entity/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ 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
263 changes: 263 additions & 0 deletions tests/Assets/Entity/Entity.skipper

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion tests/Assets/Entity/EntityWithoutRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ public function getId(): int|null
return $this->id;
}

public function setId(int $id): void
public function setId(int $id): self
{
$this->id = $id;

return $this;
}
}
17 changes: 13 additions & 4 deletions tests/Assets/Entity/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace DoctrineORMModuleTest\Assets\Entity;

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

#[ORM\Entity]
Expand All @@ -19,8 +20,16 @@ class Product
protected string $name;

/** @var Category[] */
#[ORM\ManyToMany(targetEntity: Category::class)]
private array $categories;
#[ORM\ManyToMany(targetEntity: Category::class, inversedBy: 'products')]
#[ORM\JoinTable(name: 'ProductCategory')]
#[ORM\JoinColumn(name: 'Product_id', referencedColumnName: 'id')]
#[ORM\InverseJoinColumn(name: 'Category_id', referencedColumnName: 'id')]
private ArrayCollection $categories;

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

public function getId(): int|null
{
Expand All @@ -40,15 +49,15 @@ public function getName(): string
}

/** @param Category[] $categories */
public function setCategories(array $categories): self
public function setCategories(ArrayCollection $categories): self
{
$this->categories = $categories;

return $this;
}

/** @return Category[] */
public function getCategories(): array
public function getCategories(): ArrayCollection
{
return $this->categories;
}
Expand Down
4 changes: 3 additions & 1 deletion tests/Assets/Entity/TargetEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ public function getId(): int
return $this->id;
}

public function setId(int $id): void
public function setId(int $id): self
{
$this->id = $id;

return $this;
}
}

0 comments on commit c94e4c0

Please sign in to comment.