class DeliveryCandidateTest in Message Subscribe 8
Unit tests for the delivery candidate class.
@group message_subscribe
@coversDefaultClass \Drupal\message_subscribe\Subscribers\DeliveryCandidate
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\message_subscribe\Unit\Subscribers\DeliveryCandidateTest
Expanded class hierarchy of DeliveryCandidateTest
File
- tests/
src/ Unit/ Subscribers/ DeliveryCandidateTest.php, line 16
Namespace
Drupal\Tests\message_subscribe\Unit\SubscribersView source
class DeliveryCandidateTest extends UnitTestCase {
/**
* Test construction.
*
* @covers ::__construct
* @covers ::getFlags
* @covers ::getNotifiers
* @covers ::getAccountId
*/
public function testConstruct() {
$candidate = new DeliveryCandidate([
'foo',
], [
'bar',
], 123);
$this
->assertEquals([
'foo' => 'foo',
], $candidate
->getFlags());
$this
->assertEquals([
'bar' => 'bar',
], $candidate
->getNotifiers());
$this
->assertEquals(123, $candidate
->getAccountId());
}
/**
* Test adding and removing flags.
*
* @covers ::addFlag
* @covers ::removeFlag
* @covers ::getFlags
* @covers ::setFlags
*/
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());
}
/**
* Test adding and removing flags.
*
* @covers ::addNotifier
* @covers ::removeNotifier
* @covers ::getNotifiers
* @covers ::setNotifiers
*/
public function testAddRemoveNotifier() {
$candidate = new DeliveryCandidate([], [], 42);
$this
->assertEmpty($candidate
->getNotifiers());
$this
->assertInstanceOf(DeliveryCandidateInterface::class, $candidate
->addNotifier('foo'));
$this
->assertEquals([
'foo' => 'foo',
], $candidate
->getNotifiers());
$this
->assertInstanceOf(DeliveryCandidateInterface::class, $candidate
->removeNotifier('foo'));
$this
->assertEmpty($candidate
->getNotifiers());
$this
->assertInstanceOf(DeliveryCandidateInterface::class, $candidate
->setNotifiers([
'foo',
'bar',
]));
$this
->assertEquals([
'foo' => 'foo',
'bar' => 'bar',
], $candidate
->getNotifiers());
}
/**
* Test setting account ID.
*
* @covers ::getAccountId
* @covers ::setAccountId
*/
public function testAccountId() {
$candidate = new DeliveryCandidate([], [], 42);
$this
->assertEquals(42, $candidate
->getAccountId());
$this
->assertInstanceOf(DeliveryCandidateInterface::class, $candidate
->setAccountId(123));
$this
->assertEquals(123, $candidate
->getAccountId());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeliveryCandidateTest:: |
public | function | Test setting account ID. | |
DeliveryCandidateTest:: |
public | function | Test adding and removing flags. | |
DeliveryCandidateTest:: |
public | function | Test adding and removing flags. | |
DeliveryCandidateTest:: |
public | function | Test construction. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UnitTestCase:: |
protected | function | 340 |