Passed
Pull Request — master (#10)
by Anatoly
02:28
created

EntryManagerTest::testList()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 1
eloc 12
c 2
b 0
f 1
nc 1
nop 0
dl 0
loc 18
rs 9.8666
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