Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
InfoCommandTest.php
Go to the documentation of this file.
1 <?php
9 
10 class InfoCommandTest extends \PHPUnit\Framework\TestCase
11 {
12 
13  private $installedOutput = 'name : 3rdp/a
14 descrip. : Plugin project A
15 keywords :
16 versions : * 1.0.0
17 type : library
18 names : 3rdp/a
19 
20 requires
21 php >=5.4.11
22 3rdp/c 1.1.0';
23 
27  protected $application;
28 
32  protected $infoCommand;
33 
34  protected function setUp()
35  {
36  $this->application = $this->createMock(\Magento\Composer\MagentoComposerApplication::class);
37 
38  $this->infoCommand = new InfoCommand($this->application);
39  }
40 
44  public function testRun($input, $output)
45  {
46  $this->application->expects($this->once())->method('runComposerCommand')->willReturn($input);
47  $result = $this->infoCommand->run('3rdp/a');
48  $this->assertEquals($output, $result);
49  }
50 
51  public function testRunInstalled()
52  {
53  $this->application->expects($this->once())->method('runComposerCommand')->willReturn($this->installedOutput);
54  $result = $this->infoCommand->run('3rdp/a', true);
55  $this->assertEquals(
56  [
57  'name' => '3rdp/a',
58  'descrip.' => 'Plugin project A',
59  'versions' => '* 1.0.0',
60  'keywords' => '',
61  'type' => 'library',
62  'names' => '3rdp/a',
63  'current_version' => '1.0.0',
64  'available_versions' => [],
65  'new_versions' => []
66  ],
67  $result
68  );
69  }
70 
76  public function getCommandOutputDataProvider()
77  {
78  return [
79  'Package not installed' => [
80  'name : 3rdp/a
81 descrip. : Plugin project A
82 keywords :
83 versions : 1.0.0, 1.1.0
84 type : library
85 names : 3rdp/a
86 
87 requires
88 php >=5.4.11
89 3rdp/c 1.1.0',
90  [
91  'name' => '3rdp/a',
92  'descrip.' => 'Plugin project A',
93  'versions' => '1.0.0, 1.1.0',
94  'keywords' => '',
95  'type' => 'library',
96  'names' => '3rdp/a',
97  'current_version' => '',
98  'available_versions' => [
99  '1.0.0',
100  '1.1.0'
101  ],
102  'new_versions' => [
103  '1.0.0',
104  '1.1.0'
105  ]
106  ]
107  ],
108  'Package installed' => [
109  'name : 3rdp/a
110 descrip. : Plugin project A
111 keywords :
112 versions : 1.0.0, 1.1.0, * 1.1.2, 1.2.0
113 type : library
114 names : 3rdp/a
115 
116 requires
117 php >=5.4.11
118 3rdp/c 1.1.0',
119  [
120  'name' => '3rdp/a',
121  'descrip.' => 'Plugin project A',
122  'versions' => '1.0.0, 1.1.0, * 1.1.2, 1.2.0',
123  'keywords' => '',
124  'type' => 'library',
125  'names' => '3rdp/a',
126  'current_version' => '1.1.2',
127  'available_versions' => [
128  '1.0.0',
129  '1.1.0',
130  '1.2.0'
131  ],
132  'new_versions' => [
133  '1.2.0'
134  ]
135  ]
136  ],
137  ];
138  }
139 }
testRun($input, $output)