function LockFileValidatorTest::testCreateWithNoLock

Tests that if no active lock file exists, a stage cannot be created.

@covers ::storeHash

File

core/modules/package_manager/tests/src/Kernel/LockFileValidatorTest.php, line 73

Class

LockFileValidatorTest
@coversDefaultClass \Drupal\package_manager\Validator\LockFileValidator[[api-linebreak]] @group package_manager @internal

Namespace

Drupal\Tests\package_manager\Kernel

Code

public function testCreateWithNoLock() : void {
  unlink($this->activeDir . '/composer.lock');
  $project_root = $this->container
    ->get(PathLocator::class)
    ->getProjectRoot();
  $lock_file_path = $project_root . DIRECTORY_SEPARATOR . 'composer.lock';
  $no_lock = ValidationResult::createError([
    $this->t('The active lock file (@file) does not exist.', [
      '@file' => $lock_file_path,
    ]),
  ]);
  $stage = $this->assertResults([
    $no_lock,
  ], PreCreateEvent::class);
  // The stage was not created successfully, so the status check should be
  // clear.
  $this->assertStatusCheckResults([], $stage);
}

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