1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* AJGL CSV Bundle |
5
|
|
|
* |
6
|
|
|
* Copyright (C) Antonio J. García Lagar <[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 Ajgl\Bundle\CsvBundle\Tests\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use Ajgl\Bundle\CsvBundle\DependencyInjection\AjglCsvExtension; |
15
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @author Antonio J. García Lagar <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
class AjglCsvExtensionTest extends \PHPUnit_Framework_TestCase |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var ContainerBuilder |
24
|
|
|
*/ |
25
|
|
|
protected $container; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var AjglCsvExtension |
29
|
|
|
*/ |
30
|
|
|
protected $extension; |
31
|
|
|
|
32
|
|
|
protected function setUp() |
33
|
|
|
{ |
34
|
|
|
$this->container = new ContainerBuilder(); |
35
|
|
|
$this->extension = new AjglCsvExtension(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function testCsvServiceDefinition() |
39
|
|
|
{ |
40
|
|
|
$this->extension->load(array(), $this->container); |
41
|
|
|
|
42
|
|
|
$this->assertTrue($this->container->hasParameter('ajgl_csv.reader.default_type')); |
43
|
|
|
$this->assertTrue($this->container->hasParameter('ajgl_csv.writer.default_type')); |
44
|
|
|
$this->assertTrue($this->container->hasDefinition('ajgl_csv')); |
45
|
|
|
|
46
|
|
|
$this->assertSame('php', $this->container->getParameter('ajgl_csv.reader.default_type')); |
47
|
|
|
$this->assertSame('php', $this->container->getParameter('ajgl_csv.writer.default_type')); |
48
|
|
|
|
49
|
|
|
$definition = $this->container->getDefinition('ajgl_csv'); |
50
|
|
|
$this->assertSame( |
51
|
|
|
'Ajgl\Csv\Csv', |
52
|
|
|
$definition->getClass() |
53
|
|
|
); |
54
|
|
|
|
55
|
|
|
$calls = $definition->getMethodCalls(); |
56
|
|
|
$this->assertCount(2, $calls); |
57
|
|
|
foreach ($calls as $call) { |
58
|
|
|
switch ($call[0]) { |
59
|
|
|
case 'setDefaultReaderType': |
60
|
|
|
$this->assertSame(array('%ajgl_csv.reader.default_type%'), $call[1]); |
61
|
|
|
break; |
62
|
|
|
case 'setDefaultWriterType': |
63
|
|
|
$this->assertSame(array('%ajgl_csv.writer.default_type%'), $call[1]); |
64
|
|
|
break; |
65
|
|
|
default: |
66
|
|
|
$this->fail("Unexpected method call '{$call[0]}'"); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|