Skip to content

Commit 598fead

Browse files
mbabkerfranmomu
authored andcommitted
Another batch of mapping tests refactored
1 parent 680e4b4 commit 598fead

21 files changed

+643
-772
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the Doctrine Behavioral Extensions package.
7+
* (c) Gediminas Morkevicius <[email protected]> http://www.gediminasm.org
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Gedmo\Tests\Mapping\Fixture;
13+
14+
use Doctrine\DBAL\Types\Types;
15+
use Doctrine\ORM\Mapping as ORM;
16+
17+
/**
18+
* Class Embedded
19+
*
20+
* @author Fabian Sabau <[email protected]>
21+
*
22+
* @ORM\Embeddable
23+
*/
24+
#[ORM\Embeddable]
25+
class Embedded
26+
{
27+
/**
28+
* @var string
29+
*
30+
* @ORM\Column(type="string")
31+
*/
32+
#[ORM\Column(type: Types::STRING)]
33+
private $subtitle;
34+
}

tests/Gedmo/Mapping/Fixture/Loggable.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@
1111

1212
use Doctrine\DBAL\Types\Types;
1313
use Doctrine\ORM\Mapping as ORM;
14+
use Gedmo\Loggable\Entity\LogEntry;
1415
use Gedmo\Mapping\Annotation as Gedmo;
1516

1617
/**
1718
* @ORM\Entity
1819
*
19-
* @Gedmo\Loggable
20+
* @Gedmo\Loggable(logEntryClass="Gedmo\Loggable\Entity\LogEntry")
2021
*/
2122
#[ORM\Entity]
22-
#[Gedmo\Loggable]
23+
#[Gedmo\Loggable(logEntryClass: LogEntry::class)]
2324
class Loggable
2425
{
2526
/**

tests/Gedmo/Mapping/Fixture/LoggableComposite.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@
1111

1212
use Doctrine\DBAL\Types\Types;
1313
use Doctrine\ORM\Mapping as ORM;
14+
use Gedmo\Loggable\Entity\LogEntry;
1415
use Gedmo\Mapping\Annotation as Gedmo;
1516

1617
/**
1718
* @ORM\Entity
1819
*
19-
* @Gedmo\Loggable
20+
* @Gedmo\Loggable(logEntryClass="Gedmo\Loggable\Entity\LogEntry")
2021
*/
2122
#[ORM\Entity]
22-
#[Gedmo\Loggable]
23+
#[Gedmo\Loggable(logEntryClass: LogEntry::class)]
2324
class LoggableComposite
2425
{
2526
/**

tests/Gedmo/Mapping/Fixture/LoggableCompositeRelation.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@
1111

1212
use Doctrine\DBAL\Types\Types;
1313
use Doctrine\ORM\Mapping as ORM;
14+
use Gedmo\Loggable\Entity\LogEntry;
1415
use Gedmo\Mapping\Annotation as Gedmo;
1516

1617
/**
1718
* @ORM\Entity
1819
*
19-
* @Gedmo\Loggable
20+
* @Gedmo\Loggable(logEntryClass="Gedmo\Loggable\Entity\LogEntry")
2021
*/
2122
#[ORM\Entity]
22-
#[Gedmo\Loggable]
23+
#[Gedmo\Loggable(logEntryClass: LogEntry::class)]
2324
class LoggableCompositeRelation
2425
{
2526
/**
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the Doctrine Behavioral Extensions package.
7+
* (c) Gediminas Morkevicius <[email protected]> http://www.gediminasm.org
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Gedmo\Tests\Mapping\Fixture;
13+
14+
use Doctrine\DBAL\Types\Types;
15+
use Doctrine\ORM\Mapping as ORM;
16+
use Gedmo\Loggable\Entity\LogEntry;
17+
use Gedmo\Mapping\Annotation as Gedmo;
18+
19+
/**
20+
* @ORM\Entity
21+
*
22+
* @Gedmo\Loggable(logEntryClass="Gedmo\Loggable\Entity\LogEntry")
23+
*/
24+
#[ORM\Entity]
25+
#[Gedmo\Loggable(logEntryClass: LogEntry::class)]
26+
class LoggableWithEmbedded
27+
{
28+
/**
29+
* @var int
30+
*
31+
* @ORM\Id
32+
* @ORM\GeneratedValue
33+
* @ORM\Column(type="integer")
34+
*/
35+
#[ORM\Id]
36+
#[ORM\GeneratedValue]
37+
#[ORM\Column(type: Types::INTEGER)]
38+
private $id;
39+
40+
/**
41+
* @var string
42+
*
43+
* @ORM\Column(name="title", type="string")
44+
*
45+
* @Gedmo\Versioned
46+
*/
47+
#[ORM\Column(name: 'title', type: Types::STRING)]
48+
#[Gedmo\Versioned]
49+
private $title;
50+
51+
/**
52+
* @var Embedded
53+
*
54+
* @ORM\Embedded(class="Gedmo\Tests\Mapping\Fixture\Embedded")
55+
*
56+
* @Gedmo\Versioned
57+
*/
58+
#[ORM\Embedded(class: Embedded::class)]
59+
#[Gedmo\Versioned]
60+
private $embedded;
61+
}

tests/Gedmo/Mapping/Fixture/Sluggable.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,15 @@ class Sluggable
4444
/**
4545
* @ORM\Column(name="code", type="string", length=16)
4646
*/
47-
#[ORM\Column(name: 'code', type: Types::STRING, length: 64, nullable: true)]
47+
#[ORM\Column(name: 'code', type: Types::STRING, length: 16, nullable: true)]
4848
private ?string $code = null;
4949

50+
/**
51+
* @ORM\Column(name="ean", type="string", length=13)
52+
*/
53+
#[ORM\Column(name: 'ean', type: Types::STRING, length: 13, nullable: true)]
54+
private ?string $ean = null;
55+
5056
/**
5157
* @var string|null
5258
*
@@ -56,17 +62,17 @@ class Sluggable
5662
* @Gedmo\SlugHandlerOption(name="separator", value="/")
5763
* }),
5864
* @Gedmo\SlugHandler(class="Gedmo\Sluggable\Handler\RelativeSlugHandler", options={
59-
* @Gedmo\SlugHandlerOption(name="relationField", value="user"),
60-
* @Gedmo\SlugHandlerOption(name="relationSlugField", value="slug"),
61-
* @Gedmo\SlugHandlerOption(name="separator", value="/")
65+
* @Gedmo\SlugHandlerOption(name="relationField", value="parent"),
66+
* @Gedmo\SlugHandlerOption(name="relationSlugField", value="test"),
67+
* @Gedmo\SlugHandlerOption(name="separator", value="-")
6268
* })
63-
* }, separator="-", updatable=false, fields={"title", "code"})
69+
* }, separator="_", updatable=false, fields={"title", "ean", "code"}, style="camel")
6470
*
6571
* @ORM\Column(name="slug", type="string", length=64, unique=true)
6672
*/
67-
#[Gedmo\Slug(separator: '-', updatable: false, fields: ['title', 'code'])]
73+
#[Gedmo\Slug(separator: '_', updatable: false, fields: ['title', 'ean', 'code'], style: 'camel')]
6874
#[Gedmo\SlugHandler(class: TreeSlugHandler::class, options: ['parentRelationField' => 'parent', 'separator' => '/'])]
69-
#[Gedmo\SlugHandler(class: RelativeSlugHandler::class, options: ['relationField' => 'user', 'relationSlugField' => 'slug', 'separator' => '/'])]
75+
#[Gedmo\SlugHandler(class: RelativeSlugHandler::class, options: ['relationField' => 'parent', 'relationSlugField' => 'test', 'separator' => '-'])]
7076
#[ORM\Column(name: 'slug', type: Types::STRING, length: 64, unique: true)]
7177
private $slug;
7278

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the Doctrine Behavioral Extensions package.
7+
* (c) Gediminas Morkevicius <[email protected]> http://www.gediminasm.org
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Gedmo\Tests\Mapping\Fixture;
13+
14+
use Doctrine\Common\Collections\ArrayCollection;
15+
use Doctrine\Common\Collections\Collection;
16+
use Doctrine\DBAL\Types\Types;
17+
use Doctrine\ORM\Mapping as ORM;
18+
use Gedmo\Mapping\Annotation as Gedmo;
19+
20+
/**
21+
* @ORM\Entity
22+
* @ORM\Table(name="sortables")
23+
*/
24+
#[ORM\Entity]
25+
#[ORM\Table(name: 'sortables')]
26+
class Sortable
27+
{
28+
/**
29+
* @var int
30+
*
31+
* @ORM\Id
32+
* @ORM\GeneratedValue
33+
* @ORM\Column(type="integer")
34+
*/
35+
#[ORM\Id]
36+
#[ORM\GeneratedValue]
37+
#[ORM\Column(type: Types::INTEGER)]
38+
private $id;
39+
40+
/**
41+
* @var string
42+
*
43+
* @ORM\Column(type="string", length=128)
44+
*/
45+
#[ORM\Column(type: Types::STRING, length: 128)]
46+
private $title;
47+
48+
/**
49+
* @var int
50+
*
51+
* @ORM\Column(type="integer")
52+
*
53+
* @Gedmo\SortablePosition
54+
*/
55+
#[ORM\Column(type: Types::INTEGER)]
56+
#[Gedmo\SortablePosition]
57+
private $position;
58+
59+
/**
60+
* @var string
61+
*
62+
* @ORM\Column(type="string", length=128)
63+
*
64+
* @Gedmo\SortableGroup
65+
*/
66+
#[ORM\Column(type: Types::STRING, length: 128)]
67+
#[Gedmo\SortableGroup]
68+
private $grouping;
69+
70+
/**
71+
* @var SortableGroup
72+
*
73+
* @ORM\ManyToOne(targetEntity="Sluggable")
74+
*
75+
* @Gedmo\SortableGroup
76+
*/
77+
#[ORM\ManyToOne(targetEntity: SortableGroup::class)]
78+
#[Gedmo\SortableGroup]
79+
private $sortable_group;
80+
81+
/**
82+
* @var Collection<int, SortableGroup>
83+
*
84+
* @ORM\ManyToMany(targetEntity="SortableGroup")
85+
* @ORM\JoinTable(name="sortable_sortable_groups",
86+
* joinColumns={@ORM\JoinColumn(name="sortable_id")},
87+
* inverseJoinColumns={@ORM\JoinColumn(name="group_id")}
88+
* )
89+
*
90+
* @Gedmo\SortableGroup
91+
*/
92+
#[ORM\ManyToMany(targetEntity: SortableGroup::class)]
93+
#[ORM\JoinTable(name: 'sortable_sortable_groups')]
94+
#[ORM\JoinColumn(name: 'sortable_id')]
95+
#[ORM\InverseJoinColumn(name: 'group_id')]
96+
#[Gedmo\SortableGroup]
97+
private Collection $sortable_groups;
98+
99+
public function __construct()
100+
{
101+
$this->sortable_groups = new ArrayCollection();
102+
}
103+
}

tests/Gedmo/Mapping/Fixture/SortableGroup.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,34 @@
1111

1212
namespace Gedmo\Tests\Mapping\Fixture;
1313

14+
use Doctrine\DBAL\Types\Types;
1415
use Doctrine\ORM\Mapping as ORM;
1516

1617
/**
17-
* @ORM\Table(name="test_sortable_groups")
1818
* @ORM\Entity
19+
* @ORM\Table(name="test_sortable_groups")
1920
*/
21+
#[ORM\Entity]
22+
#[ORM\Table(name: 'test_sortable_groups')]
2023
class SortableGroup
2124
{
2225
/**
23-
* @var int|null
26+
* @var int
2427
*
25-
* @ORM\Column(type="integer")
2628
* @ORM\Id
2729
* @ORM\GeneratedValue
30+
* @ORM\Column(type="integer")
2831
*/
32+
#[ORM\Id]
33+
#[ORM\GeneratedValue]
34+
#[ORM\Column(type: Types::INTEGER)]
2935
private $id;
3036

3137
/**
32-
* @var string|null
38+
* @var string
3339
*
34-
* @ORM\Column(length=64)
40+
* @ORM\Column(type="string", length=64)
3541
*/
42+
#[ORM\Column(type: Types::STRING, length: 64)]
3643
private $name;
3744
}

0 commit comments

Comments
 (0)