|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the xAPI package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Christian Flothmann <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Xabbuh\XApi\Bundle\ClientBundle\Tests\DependencyInjection\Compiler; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
|
15
|
|
|
use Xabbuh\XApi\Bundle\ClientBundle\DependencyInjection\Compiler\RegisterSerializerMetadataPass; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @author Christian Flothmann <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
class RegisterSerializerMetadataPassTest extends \PHPUnit_Framework_TestCase |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @var RegisterSerializerMetadataPass |
|
24
|
|
|
*/ |
|
25
|
|
|
private $compilerPass; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var Definition |
|
29
|
|
|
*/ |
|
30
|
|
|
private $fileLocator; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var \Symfony\Component\DependencyInjection\ContainerBuilder |
|
34
|
|
|
*/ |
|
35
|
|
|
private $containerBuilder; |
|
36
|
|
|
|
|
37
|
|
|
protected function setUp() |
|
38
|
|
|
{ |
|
39
|
|
|
$this->compilerPass = new RegisterSerializerMetadataPass(); |
|
40
|
|
|
$this->fileLocator = $this->createFileLocatorDefinition(); |
|
41
|
|
|
$this->containerBuilder = $this->createContainerBuilderMock($this->fileLocator); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function testSerializerMetadataAreNotRegisteredBeforeProcess() |
|
45
|
|
|
{ |
|
46
|
|
|
$this->compilerPass->process($this->containerBuilder); |
|
47
|
|
|
|
|
48
|
|
|
$this->assertArrayHasKey('Xabbuh\XApi\Model', $this->fileLocator->getArgument(0)); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
private function createFileLocatorDefinition() |
|
52
|
|
|
{ |
|
53
|
|
|
return new Definition('\Metadata\Driver\FileLocator', array(array())); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
private function createContainerBuilderMock($fileLocator) |
|
57
|
|
|
{ |
|
58
|
|
|
$containerBuilder = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerBuilder') |
|
59
|
|
|
->setMethods(array('findDefinition')) |
|
60
|
|
|
->getMock(); |
|
61
|
|
|
$containerBuilder->expects($this->any()) |
|
62
|
|
|
->method('findDefinition') |
|
63
|
|
|
->with('jms_serializer.metadata.file_locator') |
|
64
|
|
|
->will($this->returnValue($fileLocator)); |
|
65
|
|
|
|
|
66
|
|
|
return $containerBuilder; |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|