class FailureMarkerRequirementTest

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

@group package_manager @internal

Hierarchy

Expanded class hierarchy of FailureMarkerRequirementTest

File

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

Namespace

Drupal\Tests\package_manager\Functional
View source
class FailureMarkerRequirementTest extends BrowserTestBase {
    use StringTranslationTrait;
    use AssertPreconditionsTrait;
    
    /**
     * {@inheritdoc}
     */
    protected static $modules = [
        'package_manager',
        'package_manager_bypass',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected $defaultTheme = 'stark';
    
    /**
     * Tests that error is shown if failure marker already exists.
     */
    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 StageBase {
            public function __construct() {
            }
            
            /**
             * {@inheritdoc}
             */
            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.