function ComposerRunnerTest::testRunner

Tests that the Composer runner runs Composer through the PHP interpreter.

File

core/modules/package_manager/tests/src/Unit/ComposerRunnerTest.php, line 30

Class

ComposerRunnerTest
Tests Package Manager's Composer runner service.

Namespace

Drupal\Tests\package_manager\Unit

Code

public function testRunner() : void {
  $executable_finder = $this->prophesize(ExecutableFinderInterface::class);
  $executable_finder->find('composer')
    ->willReturn('/mock/composer')
    ->shouldBeCalled();
  $process_factory = $this->prophesize(ProcessFactoryInterface::class);
  $process_factory->create([
    PHP_BINARY,
    '/mock/composer',
    '--version',
  ], NULL, Argument::withKey('COMPOSER_HOME'))
    ->shouldBeCalled();
  $file_system = $this->prophesize(FileSystemInterface::class);
  $file_system->getTempDirectory()
    ->shouldBeCalled();
  $file_system->prepareDirectory(Argument::cetera())
    ->shouldBeCalled();
  $runner = new ComposerRunner($executable_finder->reveal(), $process_factory->reveal(), $file_system->reveal(), $this->getConfigFactoryStub([
    'system.site' => [
      'uuid' => 'testing',
    ],
  ]));
  $runner->run([
    '--version',
  ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.