|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Bundle\Example\Tests\Service; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Import classes |
|
7
|
|
|
*/ |
|
8
|
|
|
use App\Tests\ContainerAwareTrait; |
|
9
|
|
|
use App\Tests\DatabaseSchemaToolTrait; |
|
10
|
|
|
use PHPUnit\Framework\TestCase; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* EntryManagerTest |
|
14
|
|
|
*/ |
|
15
|
|
|
class EntryManagerTest extends TestCase |
|
16
|
|
|
{ |
|
17
|
|
|
use ContainerAwareTrait; |
|
18
|
|
|
use DatabaseSchemaToolTrait; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @return void |
|
22
|
|
|
* |
|
23
|
|
|
* @runInSeparateProcess |
|
24
|
|
|
*/ |
|
25
|
|
|
public function testCountAll() : void |
|
26
|
|
|
{ |
|
27
|
|
|
$container = $this->getContainer(); |
|
28
|
|
|
$doctrine = $container->get('doctrine'); |
|
29
|
|
|
|
|
30
|
|
|
$entityManager = $doctrine->getManager('master'); |
|
31
|
|
|
$this->createDatabaseSchema($entityManager); |
|
32
|
|
|
|
|
33
|
|
|
$entryManager = $container->get('entryManager'); |
|
34
|
|
|
$this->assertSame(0, $entryManager->countAll()); |
|
35
|
|
|
|
|
36
|
|
|
$entryManager->create(['name' => 'foo', 'slug' => 'foo']); |
|
37
|
|
|
$this->assertSame(1, $entryManager->countAll()); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @return void |
|
42
|
|
|
* |
|
43
|
|
|
* @runInSeparateProcess |
|
44
|
|
|
*/ |
|
45
|
|
|
public function testList() : void |
|
46
|
|
|
{ |
|
47
|
|
|
$container = $this->getContainer(); |
|
48
|
|
|
$doctrine = $container->get('doctrine'); |
|
49
|
|
|
|
|
50
|
|
|
$entityManager = $doctrine->getManager('master'); |
|
51
|
|
|
$this->createDatabaseSchema($entityManager); |
|
52
|
|
|
|
|
53
|
|
|
$entryManager = $container->get('entryManager'); |
|
54
|
|
|
$this->assertSame([], $entryManager->getList(null, null)); |
|
55
|
|
|
|
|
56
|
|
|
$foo = $entryManager->create(['name' => 'foo', 'slug' => 'foo']); |
|
57
|
|
|
$bar = $entryManager->create(['name' => 'bar', 'slug' => 'bar']); |
|
58
|
|
|
|
|
59
|
|
|
$entries = $entryManager->getList(null, null); |
|
60
|
|
|
$this->assertCount(2, $entries); |
|
61
|
|
|
$this->assertSame($foo->getId()->toString(), (string) $entries[1]->getId()); |
|
62
|
|
|
$this->assertSame($bar->getId()->toString(), (string) $entries[0]->getId()); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|