You are here

public function DeliveryCandidateTest::testAddRemoveFlag in Message Subscribe 8

Test adding and removing flags.

@covers ::addFlag @covers ::removeFlag @covers ::getFlags @covers ::setFlags

File

tests/src/Unit/Subscribers/DeliveryCandidateTest.php, line 41

Class

DeliveryCandidateTest
Unit tests for the delivery candidate class.

Namespace

Drupal\Tests\message_subscribe\Unit\Subscribers

Code

public function testAddRemoveFlag() {
  $candidate = new DeliveryCandidate([], [], 42);
  $this
    ->assertEmpty($candidate
    ->getFlags());
  $this
    ->assertInstanceOf(DeliveryCandidateInterface::class, $candidate
    ->addFlag('foo'));
  $this
    ->assertEquals([
    'foo' => 'foo',
  ], $candidate
    ->getFlags());
  $this
    ->assertInstanceOf(DeliveryCandidateInterface::class, $candidate
    ->removeFlag('foo'));
  $this
    ->assertEmpty($candidate
    ->getFlags());
  $this
    ->assertInstanceOf(DeliveryCandidateInterface::class, $candidate
    ->setFlags([
    'foo',
    'bar',
  ]));
  $this
    ->assertEquals([
    'foo' => 'foo',
    'bar' => 'bar',
  ], $candidate
    ->getFlags());
}