function FailureMarkerRequirementTest::testFailureMarkerExists

Tests that error is shown if failure marker already exists.

File

core/modules/package_manager/tests/src/Functional/FailureMarkerRequirementTest.php, line 35

Class

FailureMarkerRequirementTest
Tests that Package Manager's requirements check for the failure marker.

Namespace

Drupal\Tests\package_manager\Functional

Code

public function testFailureMarkerExists() : void {
  $account = $this->drupalCreateUser([
    'administer site configuration',
  ]);
  $this->drupalLogin($account);
  $fake_project_root = $this->root . DIRECTORY_SEPARATOR . $this->publicFilesDirectory;
  $this->container
    ->get(PathLocator::class)
    ->setPaths($fake_project_root, NULL, NULL, NULL);
  $failure_marker = $this->container
    ->get(FailureMarker::class);
  $message = $this->t('Package Manager is here to wreck your day.');
  $stage = new class  extends SandboxManagerBase {
    public function __construct() {
    }
    
    /**
     * {@inheritdoc}
     */
    // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable, Drupal.Commenting.VariableComment.Missing
    protected string $type = 'test';

};
  $failure_marker->write($stage, $message);
  $path = $failure_marker->getPath();
  $this->assertFileExists($path);
  $this->assertStringStartsWith($fake_project_root, $path);
  $this->drupalGet('/admin/reports/status');
  $assert_session = $this->assertSession();
  $assert_session->pageTextContains('Failed Package Manager update detected');
  $assert_session->pageTextContains($message->render());
}

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