function AjaxCommandsTest::testAnnounceCommand

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php \Drupal\Tests\Core\Ajax\AjaxCommandsTest::testAnnounceCommand()
  2. 8.9.x core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php \Drupal\Tests\Core\Ajax\AjaxCommandsTest::testAnnounceCommand()
  3. 10 core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php \Drupal\Tests\Core\Ajax\AjaxCommandsTest::testAnnounceCommand()

@covers \Drupal\Core\Ajax\AnnounceCommand

@dataProvider announceCommandProvider

File

core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php, line 164

Class

AjaxCommandsTest
Test coverage for various classes in the \Drupal\Core\Ajax namespace.

Namespace

Drupal\Tests\Core\Ajax

Code

public function testAnnounceCommand($message, $priority, array $expected) : void {
    if ($priority === NULL) {
        $command = new AnnounceCommand($message);
    }
    else {
        $command = new AnnounceCommand($message, $priority);
    }
    $expected_assets = new AttachedAssets();
    $expected_assets->setLibraries([
        'core/drupal.announce',
    ]);
    $this->assertEquals($expected_assets, $command->getAttachedAssets());
    $this->assertSame($expected, $command->render());
}

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