|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of Bldr.io |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Aaron Scherer <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the MIT license that is bundled |
|
9
|
|
|
* with this source code in the file LICENSE |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Bldr\Test\DependencyInjection; |
|
13
|
|
|
|
|
14
|
|
|
use Bldr\DependencyInjection\ContainerBuilder; |
|
15
|
|
|
use org\bovigo\vfs\vfsStream; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @author Luis Cordova <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
class ContainerBuilderTest extends \PHPUnit_Framework_TestCase |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @var ContainerBuilder |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $containerBuilder; |
|
26
|
|
|
protected $application; |
|
27
|
|
|
protected $input; |
|
28
|
|
|
protected $output; |
|
29
|
|
|
protected $root; |
|
30
|
|
|
|
|
31
|
|
|
public function setUp() |
|
32
|
|
|
{ |
|
33
|
|
|
$this->application = $this->getMockBuilder('Bldr\Application') |
|
34
|
|
|
->disableOriginalConstructor() |
|
35
|
|
|
->getMock() |
|
36
|
|
|
; |
|
37
|
|
|
$this->input = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface') |
|
38
|
|
|
->disableOriginalConstructor() |
|
39
|
|
|
->getMock() |
|
40
|
|
|
; |
|
41
|
|
|
$this->output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface') |
|
42
|
|
|
->disableOriginalConstructor() |
|
43
|
|
|
->getMock() |
|
44
|
|
|
; |
|
45
|
|
|
|
|
46
|
|
|
$this->root = vfsStream::setup(); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function testGetThirdPartyBlocks() |
|
50
|
|
|
{ |
|
51
|
|
|
$embeddedComposer = $this->getMockBuilder('Dflydev\EmbeddedComposer\Core\EmbeddedComposer') |
|
52
|
|
|
->disableOriginalConstructor() |
|
53
|
|
|
->getMock() |
|
54
|
|
|
; |
|
55
|
|
|
$config = $this->getMockBuilder('Composer\Config') |
|
56
|
|
|
->disableOriginalConstructor() |
|
57
|
|
|
->getMock() |
|
58
|
|
|
; |
|
59
|
|
|
$config->expects($this->once()) |
|
60
|
|
|
->method('has') |
|
61
|
|
|
->with('block-loader') |
|
62
|
|
|
->willReturn(true) |
|
63
|
|
|
; |
|
64
|
|
|
$config->expects($this->once()) |
|
65
|
|
|
->method('get') |
|
66
|
|
|
->with('block-loader') |
|
67
|
|
|
->willReturn('build/blocks.yml') |
|
68
|
|
|
; |
|
69
|
|
|
$embeddedComposer |
|
70
|
|
|
->expects($this->once()) |
|
71
|
|
|
->method('getExternalComposerConfig') |
|
72
|
|
|
->willReturn($config) |
|
73
|
|
|
; |
|
74
|
|
|
$embeddedComposer |
|
75
|
|
|
->expects($this->once()) |
|
76
|
|
|
->method('getExternalRootDirectory') |
|
77
|
|
|
->willReturn(vfsStream::url('root')) |
|
78
|
|
|
; |
|
79
|
|
|
$this->application |
|
80
|
|
|
->expects($this->once()) |
|
81
|
|
|
->method('getEmbeddedComposer') |
|
82
|
|
|
->willReturn($embeddedComposer) |
|
83
|
|
|
; |
|
84
|
|
|
|
|
85
|
|
|
$bldrFolder = vfsStream::newDirectory('build')->at($this->root); |
|
86
|
|
|
vfsStream::newFile('blocks.yml') |
|
87
|
|
|
->withContent('[ \stdClass, \stdClass ]') |
|
88
|
|
|
->at($bldrFolder) |
|
89
|
|
|
; |
|
90
|
|
|
|
|
91
|
|
|
$this->containerBuilder = new ContainerBuilder( |
|
92
|
|
|
$this->application, |
|
93
|
|
|
$this->input, |
|
94
|
|
|
$this->output |
|
95
|
|
|
); |
|
96
|
|
|
|
|
97
|
|
|
$this->assertCount(2, $this->containerBuilder->getThirdPartyBlocks()); |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|