|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This is part of the webuni/composer-yaml-plugin package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Martin Hasoň <[email protected]> |
|
7
|
|
|
* (c) Webuni s.r.o. <[email protected]> |
|
8
|
|
|
* |
|
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
10
|
|
|
* file that was distributed with this source code. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Webuni\ComposerYamlPlugin\Tests; |
|
14
|
|
|
|
|
15
|
|
|
use Composer\Composer; |
|
16
|
|
|
use Composer\Console\Application; |
|
17
|
|
|
use Composer\IO\BufferIO; |
|
18
|
|
|
use Composer\Plugin\PluginManager; |
|
19
|
|
|
use Symfony\Component\Console\Input\ArrayInput; |
|
20
|
|
|
use Symfony\Component\Console\Output\BufferedOutput; |
|
21
|
|
|
use Webuni\ComposerYamlPlugin\Plugin; |
|
22
|
|
|
|
|
23
|
|
|
final class PluginTest extends CompatibleTestsCase |
|
24
|
|
|
{ |
|
25
|
|
|
private $plugin; |
|
26
|
|
|
|
|
27
|
|
|
protected function setUp() |
|
28
|
|
|
{ |
|
29
|
|
|
$this->plugin = new Plugin(); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function testAddNewCommand() |
|
33
|
|
|
{ |
|
34
|
|
|
$pm = $this |
|
35
|
|
|
->getMockBuilder(PluginManager::class) |
|
36
|
|
|
->disableOriginalConstructor() |
|
37
|
|
|
->setMethods(['getPlugins']) |
|
38
|
|
|
->getMock() |
|
39
|
|
|
; |
|
40
|
|
|
|
|
41
|
|
|
$pm |
|
42
|
|
|
->expects($this->any()) |
|
43
|
|
|
->method('getPlugins') |
|
44
|
|
|
->willReturn([$this->plugin]) |
|
45
|
|
|
; |
|
46
|
|
|
|
|
47
|
|
|
$composer = $this->getMockBuilder(Composer::class)->getMock(); |
|
48
|
|
|
$composer |
|
49
|
|
|
->expects($this->any()) |
|
50
|
|
|
->method('getPluginManager') |
|
51
|
|
|
->willReturn($pm) |
|
52
|
|
|
; |
|
53
|
|
|
|
|
54
|
|
|
$this->plugin->activate($composer, new BufferIO()); |
|
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
$app = $this |
|
57
|
|
|
->getMockBuilder(Application::class) |
|
58
|
|
|
->setMethods(['getComposer']) |
|
59
|
|
|
->getMock() |
|
60
|
|
|
; |
|
61
|
|
|
|
|
62
|
|
|
$app |
|
63
|
|
|
->expects($this->any()) |
|
64
|
|
|
->method('getComposer') |
|
65
|
|
|
->willReturn($composer) |
|
66
|
|
|
; |
|
67
|
|
|
|
|
68
|
|
|
$output = new BufferedOutput(); |
|
69
|
|
|
|
|
70
|
|
|
$app->doRun(new ArrayInput(['-d' => sys_get_temp_dir()]), $output); |
|
71
|
|
|
$this->assertRegExp('/yaml-convert +Converts a composer\.yaml to json or vice-versa/', $output->fetch()); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: