-
Notifications
You must be signed in to change notification settings - Fork 0
/
EntityTestCaseTraitTest.php
91 lines (71 loc) · 2.42 KB
/
EntityTestCaseTraitTest.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
88
89
90
91
<?php
/**
* (c) Meritoo.pl, http://www.meritoo.pl
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Meritoo\Test\CommonBundle\Traits\Test\Entity;
use Doctrine\Common\Persistence\ObjectRepository;
use Doctrine\ORM\EntityManagerInterface;
use Meritoo\CommonBundle\Traits\Test\Entity\EntityTestCaseTrait;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
/**
* @internal
* @covers \Meritoo\CommonBundle\Traits\Test\Entity\EntityTestCaseTrait
*/
class EntityTestCaseTraitTest extends TestCase
{
public function testPersistAndFlush(): void
{
$trait = $this->getMockedTrait('persistAndFlush');
$trait
->method('persistAndFlush')
->willReturn(null)
;
static::assertNull($trait->persistAndFlush(new \stdClass()));
}
public function testUpdateDatabaseSchema(): void
{
$trait = $this->getMockedTrait('updateDatabaseSchema');
$trait
->method('updateDatabaseSchema')
->willReturn(null)
;
static::assertNull($trait->updateDatabaseSchema());
}
public function testDropDatabaseSchema(): void
{
$trait = $this->getMockedTrait('dropDatabaseSchema');
$trait
->method('dropDatabaseSchema')
->willReturn(null)
;
static::assertNull($trait->dropDatabaseSchema());
}
public function testGetEntityManager(): void
{
$trait = $this->getMockedTrait('getEntityManager');
$entityManager = $this->createMock(EntityManagerInterface::class);
$trait
->method('getEntityManager')
->willReturn($entityManager)
;
static::assertInstanceOf(EntityManagerInterface::class, $trait->getEntityManager());
}
public function testGetRepository(): void
{
$trait = $this->getMockedTrait('getRepository');
$repository = $this->createMock(ObjectRepository::class);
$trait
->method('getRepository')
->willReturn($repository)
;
static::assertInstanceOf(ObjectRepository::class, $trait->getRepository(\stdClass::class));
}
private function getMockedTrait(string $method): MockObject
{
return $this->getMockForTrait(EntityTestCaseTrait::class, [], '', true, true, true, [$method]);
}
}