function MessengerTest::testAddWithDuplicates

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Messenger/MessengerTest.php \Drupal\KernelTests\Core\Messenger\MessengerTest::testAddWithDuplicates()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Messenger/MessengerTest.php \Drupal\KernelTests\Core\Messenger\MessengerTest::testAddWithDuplicates()
  3. 11.x 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 109

Class

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

Namespace

Drupal\KernelTests\Core\Messenger

Code

public function testAddWithDuplicates() : void {
    $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));
}

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