You are here

public function AjaxCommandsTest::testAnnounceCommand in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php \Drupal\Tests\Core\Ajax\AjaxCommandsTest::testAnnounceCommand()
  2. 9 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 88

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) {
  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());
}