1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Tests\GBProd\DoctrineSpecificationBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\EntityManager; |
6
|
|
|
use Doctrine\ORM\QueryBuilder; |
7
|
|
|
use GBProd\DoctrineSpecificationBundle\DependencyInjection\DoctrineSpecificationExtension; |
8
|
|
|
use GBProd\DoctrineSpecification\Handler; |
9
|
|
|
use GBProd\DoctrineSpecification\Registry; |
10
|
|
|
use PHPUnit\Framework\TestCase; |
11
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Tests for DoctrineSpecificationExtension |
15
|
|
|
* |
16
|
|
|
* @author gbprod <[email protected]> |
17
|
|
|
*/ |
18
|
|
|
class DoctrineSpecificationExtensionTest extends TestCase |
19
|
|
|
{ |
20
|
|
|
private $extension; |
21
|
|
|
private $container; |
22
|
|
|
|
23
|
|
|
protected function setUp() |
24
|
|
|
{ |
25
|
|
|
$this->extension = new DoctrineSpecificationExtension(); |
26
|
|
|
|
27
|
|
|
$this->container = new ContainerBuilder(); |
28
|
|
|
$this->container->registerExtension($this->extension); |
29
|
|
|
|
30
|
|
|
$em = $this->prophesize(EntityManager::class); |
31
|
|
|
$em |
32
|
|
|
->createQueryBuilder() |
33
|
|
|
->willReturn( |
34
|
|
|
$this->prophesize(QueryBuilder::class)->reveal() |
35
|
|
|
) |
36
|
|
|
; |
37
|
|
|
|
38
|
|
|
$this->container->set('doctrine.orm.entity_manager', $em->reveal()); |
39
|
|
|
|
40
|
|
|
$this->container->loadFromExtension($this->extension->getAlias()); |
41
|
|
|
$this->container->compile(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function testLoadHasServices() |
45
|
|
|
{ |
46
|
|
|
$this->assertTrue( |
47
|
|
|
$this->container->has('gbprod.doctrine_specification_registry') |
48
|
|
|
); |
49
|
|
|
|
50
|
|
|
$this->assertTrue( |
51
|
|
|
$this->container->has('gbprod.doctrine_specification_handler') |
52
|
|
|
); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function testLoadRegistry() |
56
|
|
|
{ |
57
|
|
|
$registry = $this->container->get('gbprod.doctrine_specification_registry'); |
58
|
|
|
|
59
|
|
|
$this->assertInstanceOf(Registry::class, $registry); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function testLoadHandler() |
63
|
|
|
{ |
64
|
|
|
$handler = $this->container->get('gbprod.doctrine_specification_handler'); |
65
|
|
|
|
66
|
|
|
$this->assertInstanceOf(Handler::class, $handler); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|