1 | <?php |
||
27 | class VersionsCheckPluginTest extends \PHPUnit_Framework_TestCase |
||
28 | { |
||
29 | /** |
||
30 | * @var BufferIO |
||
31 | */ |
||
32 | private $io; |
||
33 | |||
34 | /** |
||
35 | * @var Composer|\PHPUnit_Framework_MockObject_MockObject |
||
36 | */ |
||
37 | private $composer; |
||
38 | |||
39 | /** |
||
40 | * @var Config |
||
41 | */ |
||
42 | private $config; |
||
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | protected function setUp() |
||
48 | { |
||
49 | $this->io = new BufferIO(); |
||
50 | $this->composer = $this->getMock('Composer\Composer'); |
||
51 | $this->config = new Config(false); |
||
52 | |||
53 | $this->composer->expects($this->any())->method('getConfig') |
||
54 | ->willReturn($this->config); |
||
55 | $this->composer->expects($this->any())->method('getPackage') |
||
56 | ->willReturn(new RootPackage('my/project', '1.0.0', '1.0.0')); |
||
57 | $this->composer->expects($this->any())->method('getPluginManager') |
||
58 | ->willReturn(new PluginManager($this->io, $this->composer)); |
||
59 | $this->composer->expects($this->any())->method('getEventDispatcher') |
||
60 | ->willReturn(new EventDispatcher($this->composer, $this->io)); |
||
61 | $this->composer->expects($this->any())->method('getRepositoryManager') |
||
62 | ->willReturn(new RepositoryManager($this->io, new Config())); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * @dataProvider getTestOptionsData |
||
67 | * |
||
68 | * @param array|null $configData |
||
69 | * @param array $expectedOptions |
||
70 | */ |
||
71 | public function testOptions($configData, array $expectedOptions) |
||
72 | { |
||
73 | if (null === $configData) { |
||
74 | $this->composer->expects($this->any())->method('getConfig') |
||
|
|||
75 | ->willReturn(null); |
||
76 | } else { |
||
77 | $this->config->merge($configData); |
||
78 | } |
||
79 | |||
80 | $plugin = new VersionsCheckPlugin(); |
||
81 | $plugin->activate($this->composer, $this->io); |
||
82 | |||
83 | $this->assertAttributeSame($expectedOptions, 'options', $plugin); |
||
84 | } |
||
85 | |||
86 | public function getTestOptionsData() |
||
87 | { |
||
88 | return array( |
||
89 | 'No option' => array( |
||
90 | null, |
||
91 | array( |
||
92 | 'show-links' => true, |
||
93 | ), |
||
94 | ), |
||
95 | 'Empty array options' => array( |
||
96 | array(), |
||
97 | array( |
||
98 | 'show-links' => true, |
||
99 | ), |
||
100 | ), |
||
101 | 'Empty array plugin options' => array( |
||
102 | array( |
||
103 | 'config' => array( |
||
104 | 'sllh-composer-versions-check' => array(), |
||
105 | ), |
||
106 | ), |
||
107 | array( |
||
108 | 'show-links' => true, |
||
109 | ), |
||
110 | ), |
||
111 | 'Empty plugin options' => array( |
||
112 | array( |
||
113 | 'config' => array( |
||
114 | 'sllh-composer-versions-check' => null, |
||
115 | ), |
||
116 | ), |
||
117 | array( |
||
118 | 'show-links' => true, |
||
119 | ), |
||
120 | ), |
||
121 | 'False plugin options' => array( |
||
122 | array( |
||
123 | 'config' => array( |
||
124 | 'sllh-composer-versions-check' => false, |
||
125 | ), |
||
126 | ), |
||
127 | array( |
||
128 | 'show-links' => true, |
||
129 | ), |
||
130 | ), |
||
131 | 'Activate show-links' => array( |
||
132 | array( |
||
133 | 'config' => array( |
||
134 | 'sllh-composer-versions-check' => array( |
||
135 | 'show-links' => true, |
||
136 | ), |
||
137 | ), |
||
138 | ), |
||
139 | array( |
||
140 | 'show-links' => true, |
||
141 | ), |
||
142 | ), |
||
143 | 'Disable show-links' => array( |
||
144 | array( |
||
145 | 'config' => array( |
||
146 | 'sllh-composer-versions-check' => array( |
||
147 | 'show-links' => false, |
||
148 | ), |
||
149 | ), |
||
150 | ), |
||
151 | array( |
||
152 | 'show-links' => false, |
||
153 | ), |
||
154 | ), |
||
155 | ); |
||
156 | } |
||
157 | |||
158 | public function testPluginRegister() |
||
168 | |||
169 | public function testUpdateCommand() |
||
194 | |||
195 | public function testPreferLowest() |
||
217 | |||
218 | public function testPreferLowestNotExists() |
||
244 | |||
245 | private function addComposerPlugin(PluginInterface $plugin) |
||
252 | } |
||
253 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.