/
HealthzRepositoryTest.php
87 lines (74 loc) · 2.08 KB
/
HealthzRepositoryTest.php
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
declare(strict_types = 1);
/**
* /tests/Functional/Repository/HealthzRepositoryTest.php
*
* @author TLe, Tarmo Leppänen <tarmo.leppanen@pinja.com>
*/
namespace App\Tests\Functional\Repository;
use App\Entity\Healthz;
use App\Repository\HealthzRepository;
use App\Utils\Tests\PhpUnitUtil;
use Exception;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Throwable;
/**
* Class HealthzRepositoryTest
*
* @package App\Tests\Functional\Repository
* @author TLe, Tarmo Leppänen <tarmo.leppanen@pinja.com>
*/
class HealthzRepositoryTest extends KernelTestCase
{
/**
* @throws Throwable
*/
public static function tearDownAfterClass(): void
{
static::bootKernel();
PhpUnitUtil::loadFixtures(static::$kernel);
static::$kernel->shutdown();
parent::tearDownAfterClass();
}
/**
* @throws Throwable
*/
public function testThatReadValueMethodReturnsExpectedWithEmptyDatabase(): void
{
static::bootKernel();
PhpUnitUtil::loadFixtures(static::$kernel);
static::assertNull($this->getRepository()->read());
}
/**
* @depends testThatReadValueMethodReturnsExpectedWithEmptyDatabase
*
* @throws Throwable
*/
public function testThatCreateValueReturnsExpected(): void
{
/** @noinspection UnnecessaryAssertionInspection */
static::assertInstanceOf(Healthz::class, $this->getRepository()->create());
}
/**
* @depends testThatCreateValueReturnsExpected
*
* @throws Throwable
*/
public function testThatReadValueReturnExpectedAfterCreate(): void
{
static::assertNotNull($this->getRepository()->read());
}
/**
* @depends testThatReadValueReturnExpectedAfterCreate
*
* @throws Exception
*/
public function testThatCleanupMethodClearsDatabaseReturnsExpected(): void
{
static::assertSame(0, $this->getRepository()->cleanup());
}
private function getRepository(): HealthzRepository
{
return static::getContainer()->get(HealthzRepository::class);
}
}