Skip to content

Commit

Permalink
Another batch of mapping tests refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
mbabker authored and franmomu committed Dec 13, 2023
1 parent 680e4b4 commit 598fead
Show file tree
Hide file tree
Showing 21 changed files with 643 additions and 772 deletions.
34 changes: 34 additions & 0 deletions tests/Gedmo/Mapping/Fixture/Embedded.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Doctrine Behavioral Extensions package.
* (c) Gediminas Morkevicius <gediminas.morkevicius@gmail.com> http://www.gediminasm.org
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Gedmo\Tests\Mapping\Fixture;

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

/**
* Class Embedded
*
* @author Fabian Sabau <fabian.sabau@socialbit.de>
*
* @ORM\Embeddable
*/
#[ORM\Embeddable]
class Embedded
{
/**
* @var string
*
* @ORM\Column(type="string")
*/
#[ORM\Column(type: Types::STRING)]
private $subtitle;
}
5 changes: 3 additions & 2 deletions tests/Gedmo/Mapping/Fixture/Loggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Loggable\Entity\LogEntry;
use Gedmo\Mapping\Annotation as Gedmo;

/**
* @ORM\Entity
*
* @Gedmo\Loggable
* @Gedmo\Loggable(logEntryClass="Gedmo\Loggable\Entity\LogEntry")
*/
#[ORM\Entity]
#[Gedmo\Loggable]
#[Gedmo\Loggable(logEntryClass: LogEntry::class)]
class Loggable
{
/**
Expand Down
5 changes: 3 additions & 2 deletions tests/Gedmo/Mapping/Fixture/LoggableComposite.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Loggable\Entity\LogEntry;
use Gedmo\Mapping\Annotation as Gedmo;

/**
* @ORM\Entity
*
* @Gedmo\Loggable
* @Gedmo\Loggable(logEntryClass="Gedmo\Loggable\Entity\LogEntry")
*/
#[ORM\Entity]
#[Gedmo\Loggable]
#[Gedmo\Loggable(logEntryClass: LogEntry::class)]
class LoggableComposite
{
/**
Expand Down
5 changes: 3 additions & 2 deletions tests/Gedmo/Mapping/Fixture/LoggableCompositeRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Loggable\Entity\LogEntry;
use Gedmo\Mapping\Annotation as Gedmo;

/**
* @ORM\Entity
*
* @Gedmo\Loggable
* @Gedmo\Loggable(logEntryClass="Gedmo\Loggable\Entity\LogEntry")
*/
#[ORM\Entity]
#[Gedmo\Loggable]
#[Gedmo\Loggable(logEntryClass: LogEntry::class)]
class LoggableCompositeRelation
{
/**
Expand Down
61 changes: 61 additions & 0 deletions tests/Gedmo/Mapping/Fixture/LoggableWithEmbedded.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Doctrine Behavioral Extensions package.
* (c) Gediminas Morkevicius <gediminas.morkevicius@gmail.com> http://www.gediminasm.org
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Gedmo\Tests\Mapping\Fixture;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Loggable\Entity\LogEntry;
use Gedmo\Mapping\Annotation as Gedmo;

/**
* @ORM\Entity
*
* @Gedmo\Loggable(logEntryClass="Gedmo\Loggable\Entity\LogEntry")
*/
#[ORM\Entity]
#[Gedmo\Loggable(logEntryClass: LogEntry::class)]
class LoggableWithEmbedded
{
/**
* @var int
*
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::INTEGER)]
private $id;

/**
* @var string
*
* @ORM\Column(name="title", type="string")
*
* @Gedmo\Versioned
*/
#[ORM\Column(name: 'title', type: Types::STRING)]
#[Gedmo\Versioned]
private $title;

/**
* @var Embedded
*
* @ORM\Embedded(class="Gedmo\Tests\Mapping\Fixture\Embedded")
*
* @Gedmo\Versioned
*/
#[ORM\Embedded(class: Embedded::class)]
#[Gedmo\Versioned]
private $embedded;
}
20 changes: 13 additions & 7 deletions tests/Gedmo/Mapping/Fixture/Sluggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@ class Sluggable
/**
* @ORM\Column(name="code", type="string", length=16)
*/
#[ORM\Column(name: 'code', type: Types::STRING, length: 64, nullable: true)]
#[ORM\Column(name: 'code', type: Types::STRING, length: 16, nullable: true)]
private ?string $code = null;

/**
* @ORM\Column(name="ean", type="string", length=13)
*/
#[ORM\Column(name: 'ean', type: Types::STRING, length: 13, nullable: true)]
private ?string $ean = null;

/**
* @var string|null
*
Expand All @@ -56,17 +62,17 @@ class Sluggable
* @Gedmo\SlugHandlerOption(name="separator", value="/")
* }),
* @Gedmo\SlugHandler(class="Gedmo\Sluggable\Handler\RelativeSlugHandler", options={
* @Gedmo\SlugHandlerOption(name="relationField", value="user"),
* @Gedmo\SlugHandlerOption(name="relationSlugField", value="slug"),
* @Gedmo\SlugHandlerOption(name="separator", value="/")
* @Gedmo\SlugHandlerOption(name="relationField", value="parent"),
* @Gedmo\SlugHandlerOption(name="relationSlugField", value="test"),
* @Gedmo\SlugHandlerOption(name="separator", value="-")
* })
* }, separator="-", updatable=false, fields={"title", "code"})
* }, separator="_", updatable=false, fields={"title", "ean", "code"}, style="camel")
*
* @ORM\Column(name="slug", type="string", length=64, unique=true)
*/
#[Gedmo\Slug(separator: '-', updatable: false, fields: ['title', 'code'])]
#[Gedmo\Slug(separator: '_', updatable: false, fields: ['title', 'ean', 'code'], style: 'camel')]
#[Gedmo\SlugHandler(class: TreeSlugHandler::class, options: ['parentRelationField' => 'parent', 'separator' => '/'])]
#[Gedmo\SlugHandler(class: RelativeSlugHandler::class, options: ['relationField' => 'user', 'relationSlugField' => 'slug', 'separator' => '/'])]
#[Gedmo\SlugHandler(class: RelativeSlugHandler::class, options: ['relationField' => 'parent', 'relationSlugField' => 'test', 'separator' => '-'])]
#[ORM\Column(name: 'slug', type: Types::STRING, length: 64, unique: true)]
private $slug;

Expand Down
103 changes: 103 additions & 0 deletions tests/Gedmo/Mapping/Fixture/Sortable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Doctrine Behavioral Extensions package.
* (c) Gediminas Morkevicius <gediminas.morkevicius@gmail.com> http://www.gediminasm.org
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Gedmo\Tests\Mapping\Fixture;

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

/**
* @ORM\Entity
* @ORM\Table(name="sortables")
*/
#[ORM\Entity]
#[ORM\Table(name: 'sortables')]
class Sortable
{
/**
* @var int
*
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::INTEGER)]
private $id;

/**
* @var string
*
* @ORM\Column(type="string", length=128)
*/
#[ORM\Column(type: Types::STRING, length: 128)]
private $title;

/**
* @var int
*
* @ORM\Column(type="integer")
*
* @Gedmo\SortablePosition
*/
#[ORM\Column(type: Types::INTEGER)]
#[Gedmo\SortablePosition]
private $position;

/**
* @var string
*
* @ORM\Column(type="string", length=128)
*
* @Gedmo\SortableGroup
*/
#[ORM\Column(type: Types::STRING, length: 128)]
#[Gedmo\SortableGroup]
private $grouping;

/**
* @var SortableGroup
*
* @ORM\ManyToOne(targetEntity="Sluggable")
*
* @Gedmo\SortableGroup
*/
#[ORM\ManyToOne(targetEntity: SortableGroup::class)]
#[Gedmo\SortableGroup]
private $sortable_group;

/**
* @var Collection<int, SortableGroup>
*
* @ORM\ManyToMany(targetEntity="SortableGroup")
* @ORM\JoinTable(name="sortable_sortable_groups",
* joinColumns={@ORM\JoinColumn(name="sortable_id")},
* inverseJoinColumns={@ORM\JoinColumn(name="group_id")}
* )
*
* @Gedmo\SortableGroup
*/
#[ORM\ManyToMany(targetEntity: SortableGroup::class)]
#[ORM\JoinTable(name: 'sortable_sortable_groups')]
#[ORM\JoinColumn(name: 'sortable_id')]
#[ORM\InverseJoinColumn(name: 'group_id')]
#[Gedmo\SortableGroup]
private Collection $sortable_groups;

public function __construct()
{
$this->sortable_groups = new ArrayCollection();
}
}
17 changes: 12 additions & 5 deletions tests/Gedmo/Mapping/Fixture/SortableGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,34 @@

namespace Gedmo\Tests\Mapping\Fixture;

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

/**
* @ORM\Table(name="test_sortable_groups")
* @ORM\Entity
* @ORM\Table(name="test_sortable_groups")
*/
#[ORM\Entity]
#[ORM\Table(name: 'test_sortable_groups')]
class SortableGroup
{
/**
* @var int|null
* @var int
*
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::INTEGER)]
private $id;

/**
* @var string|null
* @var string
*
* @ORM\Column(length=64)
* @ORM\Column(type="string", length=64)
*/
#[ORM\Column(type: Types::STRING, length: 64)]
private $name;
}
Loading

0 comments on commit 598fead

Please sign in to comment.