|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* functional tests for graviton:generate:bundle |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace Graviton\GeneratorBundle\Tests\Command; |
|
7
|
|
|
|
|
8
|
|
|
use Sensio\Bundle\GeneratorBundle\Tests\Command\GenerateBundleCommandTest as BaseTest; |
|
9
|
|
|
use Graviton\GeneratorBundle\Command\GenerateBundleCommand; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* functional tests for graviton:generate:bundle |
|
13
|
|
|
* |
|
14
|
|
|
* @author List of contributors <https://github.com/libgraviton/graviton/graphs/contributors> |
|
15
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|
16
|
|
|
* @link http://swisscom.ch |
|
17
|
|
|
* |
|
18
|
|
|
* @todo fix that updateKernel is not getting tested |
|
19
|
|
|
*/ |
|
20
|
|
|
class GenerateBundleCommandTest extends BaseTest |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* test basic calls to command |
|
24
|
|
|
* |
|
25
|
|
|
* @param array $options options |
|
26
|
|
|
* @param string $input cli input |
|
27
|
|
|
* @param array $expected results to assert |
|
28
|
|
|
* |
|
29
|
|
|
* @return void |
|
30
|
|
|
* |
|
31
|
|
|
* @dataProvider getInteractiveCommandData |
|
32
|
|
|
*/ |
|
33
|
|
|
public function testInteractiveCommand($options, $input, $expected) |
|
34
|
|
|
{ |
|
35
|
|
|
parent::testInteractiveCommand($options, $input, $expected); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* get command |
|
40
|
|
|
* |
|
41
|
|
|
* @param \Graviton\GeneratorBundle\Generator\BundleGenerator $generator generator |
|
42
|
|
|
* @param object $input input mock |
|
43
|
|
|
* |
|
44
|
|
|
* @return \Graviton\GeneratorBundle\Command\GenerateBundleCommand |
|
45
|
|
|
*/ |
|
46
|
|
|
protected function getCommand($generator, $input) |
|
47
|
|
|
{ |
|
48
|
|
|
$command = $this |
|
49
|
|
|
->getMockBuilder('Graviton\GeneratorBundle\Command\GenerateBundleCommand') |
|
50
|
|
|
->setMethods(array('checkAutoloader', 'updateKernel')) |
|
51
|
|
|
->getMock(); |
|
52
|
|
|
|
|
53
|
|
|
$command->setContainer($this->getContainer()); |
|
54
|
|
|
$command->setHelperSet($this->getHelperSet($input)); |
|
55
|
|
|
$command->setGenerator($generator); |
|
56
|
|
|
|
|
57
|
|
|
return $command; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* get generator |
|
62
|
|
|
* |
|
63
|
|
|
* @return \Graviton\GeneratorBundle\Generator\BundleGenerator |
|
64
|
|
|
*/ |
|
65
|
|
|
protected function getGenerator() |
|
66
|
|
|
{ |
|
67
|
|
|
// get a noop generator |
|
68
|
|
|
return $this |
|
69
|
|
|
->getMockBuilder('Graviton\GeneratorBundle\Generator\BundleGenerator') |
|
70
|
|
|
->disableOriginalConstructor() |
|
71
|
|
|
->setMethods(['generate', 'generateBundle']) |
|
72
|
|
|
->getMock(); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* get bundle |
|
77
|
|
|
* |
|
78
|
|
|
* @return \Graviton\BundleBundle\GravitonBundleInterface |
|
|
|
|
|
|
79
|
|
|
* |
|
80
|
|
|
* @todo move one class up |
|
81
|
|
|
*/ |
|
82
|
|
|
protected function getBundle() |
|
83
|
|
|
{ |
|
84
|
|
|
$bundle = $this->createMock('Graviton\BundleBundle\GravitonBundleBundle'); |
|
85
|
|
|
$bundle |
|
86
|
|
|
->expects($this->any()) |
|
87
|
|
|
->method('getPath') |
|
88
|
|
|
->will($this->returnValue(sys_get_temp_dir())); |
|
89
|
|
|
|
|
90
|
|
|
return $bundle; |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.