You are here

public function MessengerTest::testAddWithDuplicates in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Messenger/MessengerTest.php \Drupal\KernelTests\Core\Messenger\MessengerTest::testAddWithDuplicates()
  2. 10 core/tests/Drupal/KernelTests/Core/Messenger/MessengerTest.php \Drupal\KernelTests\Core\Messenger\MessengerTest::testAddWithDuplicates()

Tests we do add duplicates with repeat flag.

@covers ::addStatus @covers ::addWarning @covers ::addError @covers ::deleteByType

File

core/tests/Drupal/KernelTests/Core/Messenger/MessengerTest.php, line 107

Class

MessengerTest
@group Messenger @coversDefaultClass \Drupal\Core\Messenger\Messenger

Namespace

Drupal\KernelTests\Core\Messenger

Code

public function testAddWithDuplicates() {
  $this->messenger
    ->addStatus('Duplicated status message', TRUE);
  $this->messenger
    ->addStatus('Duplicated status message', TRUE);
  $this
    ->assertCount(2, $this->messenger
    ->deleteByType(MessengerInterface::TYPE_STATUS));
  $this->messenger
    ->addWarning('Duplicated warning message', TRUE);
  $this->messenger
    ->addWarning('Duplicated warning message', TRUE);
  $this
    ->assertCount(2, $this->messenger
    ->deleteByType(MessengerInterface::TYPE_WARNING));
  $this->messenger
    ->addError('Duplicated error message', TRUE);
  $this->messenger
    ->addError('Duplicated error message', TRUE);
  $this
    ->assertCount(2, $this->messenger
    ->deleteByType(MessengerInterface::TYPE_ERROR));
}