Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
MagentoComposerApplicationTest.php
Go to the documentation of this file.
1 <?php
7 use Composer\Console\Application;
10 use Symfony\Component\Console\Output\BufferedOutput;
11 
12 class MagentoComposerApplicationTest extends \PHPUnit\Framework\TestCase
13 {
17  protected $application;
18 
23 
27  protected $inputFactory;
28 
32  protected $consoleOutput;
33 
34  protected function setUp()
35  {
36  $this->composerApplication = $this->createMock(\Composer\Console\Application::class);
37  $this->inputFactory = $this->createMock(\Magento\Composer\ConsoleArrayInputFactory::class);
38  $this->consoleOutput = $this->createMock(\Symfony\Component\Console\Output\BufferedOutput::class);
39 
40  $this->application = new MagentoComposerApplication(
41  'path1',
42  'path2',
43  $this->composerApplication,
44  $this->inputFactory,
45  $this->consoleOutput
46  );
47  }
48 
53  function testWrongExitCode()
54  {
55  $this->composerApplication->expects($this->once())->method('run')->willReturn(1);
56 
57  $this->application->runComposerCommand(['command'=>'update']);
58  }
59 
60  function testRunCommand()
61  {
62  $inputData = ['command' => 'update', MagentoComposerApplication::COMPOSER_WORKING_DIR => '.'];
63 
64  $this->composerApplication->expects($this->once())->method('resetComposer');
65 
66  $this->inputFactory->expects($this->once())->method('create')->with($inputData);
67 
68  $this->consoleOutput->expects($this->once())->method('fetch')->willReturn('Nothing to update');
69 
70  $this->composerApplication->expects($this->once())->method('run')->willReturn(0);
71 
72  $message = $this->application->runComposerCommand($inputData);
73  $this->assertEquals('Nothing to update', $message);
74  }
75 }
$message