|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Zenify\DoctrineBehaviors\Tests\DI; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\ORM\EntityManager; |
|
8
|
|
|
use Knp\DoctrineBehaviors\ORM\Blameable\BlameableSubscriber; |
|
9
|
|
|
use Knp\DoctrineBehaviors\ORM\Geocodable\GeocodableSubscriber; |
|
10
|
|
|
use Knp\DoctrineBehaviors\ORM\Loggable\LoggableSubscriber; |
|
11
|
|
|
use Knp\DoctrineBehaviors\ORM\Sluggable\SluggableSubscriber; |
|
12
|
|
|
use Knp\DoctrineBehaviors\ORM\SoftDeletable\SoftDeletableSubscriber; |
|
13
|
|
|
use Knp\DoctrineBehaviors\ORM\Timestampable\TimestampableSubscriber; |
|
14
|
|
|
use Knp\DoctrineBehaviors\ORM\Translatable\TranslatableSubscriber; |
|
15
|
|
|
use Knp\DoctrineBehaviors\ORM\Tree\TreeSubscriber; |
|
16
|
|
|
use Nette\DI\Container; |
|
17
|
|
|
use PHPUnit\Framework\TestCase; |
|
18
|
|
|
use Zenify; |
|
19
|
|
|
use Zenify\DoctrineBehaviors\Tests\ContainerFactory; |
|
20
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
final class DoctrineBehaviorsExtensionTest extends TestCase |
|
23
|
|
|
{ |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var int |
|
27
|
|
|
*/ |
|
28
|
|
|
const LISTENER_COUNT = 20; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var string[] |
|
32
|
|
|
*/ |
|
33
|
|
|
private $listeners = [ |
|
34
|
|
|
BlameableSubscriber::class, |
|
35
|
|
|
GeocodableSubscriber::class, |
|
36
|
|
|
LoggableSubscriber::class, |
|
37
|
|
|
SluggableSubscriber::class, |
|
38
|
|
|
SoftDeletableSubscriber::class, |
|
39
|
|
|
TimestampableSubscriber::class, |
|
40
|
|
|
TranslatableSubscriber::class, |
|
41
|
|
|
TreeSubscriber::class, |
|
42
|
|
|
]; |
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
public function testExtensions() |
|
46
|
|
|
{ |
|
47
|
|
|
$container = (new ContainerFactory)->create(); |
|
48
|
|
|
|
|
49
|
|
|
/** @var EntityManager $entityManager */ |
|
50
|
|
|
$entityManager = $container->getByType(EntityManager::class); |
|
51
|
|
|
$this->assertInstanceOf(EntityManager::class, $entityManager); |
|
52
|
|
|
|
|
53
|
|
|
$count = 0; |
|
54
|
|
|
foreach ($entityManager->getEventManager()->getListeners() as $listenerSet) { |
|
55
|
|
|
foreach ($listenerSet as $listener) { |
|
56
|
|
|
$this->assertContains(get_class($listener), $this->listeners); |
|
57
|
|
|
$count++; |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
$this->assertEquals(self::LISTENER_COUNT, $count); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
|