-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathSluggablePositionTest.php
More file actions
66 lines (54 loc) · 1.8 KB
/
SluggablePositionTest.php
File metadata and controls
66 lines (54 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?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\Sluggable;
use Doctrine\Common\EventManager;
use Gedmo\Sluggable\SluggableListener;
use Gedmo\Tests\Sluggable\Fixture\Position;
use Gedmo\Tests\Tool\BaseTestCaseORM;
/**
* These are tests for Sluggable behavior
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
*/
final class SluggablePositionTest extends BaseTestCaseORM
{
protected function setUp(): void
{
parent::setUp();
$evm = new EventManager();
$evm->addEventSubscriber(new SluggableListener());
$this->getDefaultMockSqliteEntityManager($evm);
$this->populate();
}
public function testPositionedSlugOrder(): void
{
$meta = $this->em->getClassMetadata(Position::class);
$repo = $this->em->getRepository(Position::class);
$object = $repo->find(1);
$slug = $meta->getFieldValue($object, 'slug');
static::assertSame('code-other-title-prop', $slug);
}
protected function getUsedEntityFixtures(): array
{
return [
Position::class,
];
}
private function populate(): void
{
$meta = $this->em->getClassMetadata(Position::class);
$object = new Position();
$meta->setFieldValue($object, 'title', 'title');
$meta->setFieldValue($object, 'prop', 'prop');
$meta->setFieldValue($object, 'code', 'code');
$meta->setFieldValue($object, 'other', 'other');
$this->em->persist($object);
$this->em->flush();
}
}