Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RequireUpdateDryRunCommandTest.php
Go to the documentation of this file.
1 <?php
10 
11 class RequireUpdateDryRunCommandTest extends \PHPUnit\Framework\TestCase
12 {
16  protected $application;
17 
21  protected $infoCommand;
22 
27 
31  private $errorMessage = 'Loading composer repositories with package information
32 Updating dependencies (including require-dev)
33 Your requirements could not be resolved to an installable set of packages.
34 
35  Problem 1
36  - 3rdp/e 1.0.0 requires 3rdp/d 1.0.0 -> no matching package found.
37  - 3rdp/e 1.0.0 requires 3rdp/d 1.0.0 -> no matching package found.
38  - 3rdp/e 1.0.0 requires 3rdp/d 1.0.0 -> no matching package found.
39  - Installation request for 3rdp/e 1.0.0 -> satisfiable by 3rdp/e[1.0.0].
40 
41 Potential causes:
42  - A typo in the package name
43  - The package is not available in a stable-enough version according to your minimum-stability setting
44  see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.
45 
46 Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.';
47 
51  private $packageInfo = [
52  'name' => '3rdp/d',
53  'descrip.' => 'Plugin project A',
54  'versions' => '* 1.0.0, 1.1.0, 1.2.0',
55  'keywords' => '',
56  'type' => 'library',
57  'names' => '3rdp/d',
58  'current_version' => '1.0.0',
59  'available_versions' => [
60  '1.1.0',
61  '1.2.0'
62  ]
63  ];
64 
65  protected function setUp()
66  {
67  $this->application = $this->createMock(\Magento\Composer\MagentoComposerApplication::class);
68  $this->infoCommand = $this->createMock(\Magento\Composer\InfoCommand::class);
69 
70  $this->requireUpdateDryRunCommand = new RequireUpdateDryRunCommand(
71  $this->application,
72  $this->infoCommand
73  );
74  }
75 
76  public function testRun()
77  {
78  $this->application->expects($this->exactly(2))->method('runComposerCommand');
79  $this->requireUpdateDryRunCommand->run([], '');
80  }
81 
86  public function testRunException()
87  {
88  $this->application->expects($this->at(1))
89  ->method('runComposerCommand')
90  ->willThrowException(new \RuntimeException($this->errorMessage));
91  $this->infoCommand->expects($this->once())->method('run')->willReturn($this->packageInfo);
92  $this->requireUpdateDryRunCommand->run(['3rdp/e 1.2.0'], '');
93  }
94 
95 }