You are here

public function ComposerExecutableValidatorTest::testErrorIfComposerNotFound in Automatic Updates 8.2

Tests that an error is raised if the Composer executable isn't found.

File

tests/src/Kernel/ReadinessValidation/ComposerExecutableValidatorTest.php, line 30

Class

ComposerExecutableValidatorTest
@covers \Drupal\automatic_updates\Validator\ComposerExecutableValidator

Namespace

Drupal\Tests\automatic_updates\Kernel\ReadinessValidation

Code

public function testErrorIfComposerNotFound() : void {
  $exception = new IOException("This is your regularly scheduled error.");

  // The executable finder throws an exception if it can't find the requested
  // executable.
  $exec_finder = $this
    ->prophesize(ExecutableFinderInterface::class);
  $exec_finder
    ->find('composer')
    ->willThrow($exception)
    ->shouldBeCalled();
  $this->container
    ->set('package_manager.executable_finder', $exec_finder
    ->reveal());

  // The validator should translate that exception into an error.
  $error = ValidationResult::createError([
    $exception
      ->getMessage(),
  ]);
  $this
    ->assertCheckerResultsFromManager([
    $error,
  ], TRUE);
}