class MessageDigestTest in Message Digest 8
Kernel tests for Message Digest.
@group message_digest
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements ServiceProviderInterface uses AssertContentTrait, AssertLegacyTrait, AssertHelperTrait, ConfigTestTrait, PhpunitCompatibilityTrait, RandomGeneratorTrait, TestRequirementsTrait
- class \Drupal\Tests\message_digest\Kernel\DigestTestBase uses AssertMailTrait, MessageTemplateCreateTrait, UserCreationTrait
- class \Drupal\Tests\message_digest\Kernel\MessageDigestTest
- class \Drupal\Tests\message_digest\Kernel\DigestTestBase uses AssertMailTrait, MessageTemplateCreateTrait, UserCreationTrait
Expanded class hierarchy of MessageDigestTest
File
- tests/
src/ Kernel/ MessageDigestTest.php, line 14
Namespace
Drupal\Tests\message_digest\KernelView source
class MessageDigestTest extends DigestTestBase {
/**
* Tests the plugin deriver for daily and weekly digests.
*/
public function testDigestNotifierPluginsExist() {
$count = 0;
foreach ($this->notifierManager
->getDefinitions() as $plugin_id => $plugin_definition) {
if ($plugin_definition['provider'] === 'message_digest') {
$dummy = Message::create([
'template' => 'foo',
]);
// Ensure the plugin can be instantiated.
$this->notifierManager
->createInstance($plugin_id, [], $dummy);
$count++;
}
}
$this
->assertEquals(2, $count, 'There are 2 digest notifiers.');
}
/**
* Tests the notifier sending and delivery.
*
* @param bool $reference_entity
* Whether or not an entity should be referenced in the message digest that
* is being sent.
* @param string $expected_subject
* The expected subject for the email that is being sent.
*
* @dataProvider providerTestNotifierDelivery
*/
public function testNotifierDelivery($reference_entity, $expected_subject) {
// Set the site name, so we can check that it is used in the subject of the
// digest e-mail.
$this
->config('system.site')
->set('name', 'Test site')
->save();
$template = $this
->createMessageTemplate('foo', 'Foo', 'Foo, foo', [
'Test message',
]);
$dummy = Message::create([
'template' => $template
->id(),
]);
/** @var \Drupal\message_digest\Plugin\Notifier\DigestInterface $digest_notifier */
$digest_notifier = $this->notifierManager
->createInstance('message_digest:daily', [], $dummy);
$configuration = [];
// If we are referencing an entity, create a test user and reference it in
// the message digest.
if ($reference_entity) {
$referenced_user = $this
->createUser([], 'Test user');
$configuration = [
'entity_type' => 'user',
'entity_id' => $referenced_user
->id(),
];
}
// Create a recipient and send the message.
$account = $this
->createUser();
$dummy
->setOwner($account);
$dummy
->save();
$this->notifierSender
->send($dummy, $configuration, $digest_notifier
->getPluginId());
$result = $this->container
->get('database')
->select('message_digest', 'm')
->fields('m')
->execute()
->fetchAllAssoc('id');
$this
->assertEquals(1, count($result));
foreach ($result as $row) {
$this
->assertEquals($account
->id(), $row->receiver);
$this
->assertEquals($digest_notifier
->getPluginId(), $row->notifier);
}
// Now deliver the message.
$this
->sendDigests();
$this
->assertMail('subject', $expected_subject, 'Expected email subject is set.');
$this
->assertMail('body', "Test message\n\n", 'Expected email body is set.');
$this
->assertMail('id', 'message_digest_digest', 'Expected email key is set.');
$this
->assertMail('to', $account
->getEmail(), 'Expected email recipient is set.');
// Verify that the aggregate alter hook was called.
// @see message_digest_test_message_digest_aggregate_alter()
$this
->assertTrue($this->container
->get('state')
->get('message_digest_test_message_digest_aggregate_alter', FALSE));
// Verify that hook_message_digest_view_mode_alter() has been called.
// @see message_digest_test_message_digest_view_mode_alter().
$this
->assertTrue($this->container
->get('state')
->get('message_digest_test_message_digest_view_mode_alter', FALSE));
}
/**
* Data provider for ::testNotifierDelivery().
*
* @return array
* An array of test data, each test case an array with two elements:
* - A boolean indicating whether or not an entity should be referenced.
* - The expected subject of the message digest e-mail that is sent.
*/
public function providerTestNotifierDelivery() {
return [
// Test case that does not reference an entity. In this case the site name
// should be mentioned in the message subject.
[
FALSE,
'Test site message digest',
],
// Test case that references an entity. In this case the name of the
// entity should be mentioned in the message subject. We are using a user
// entity to test this case.
[
TRUE,
'Test user message digest',
],
];
}
/**
* Tests message aggregation.
*/
public function testNotifierAggregation() {
// Send several messages.
$template = $this
->createMessageTemplate('foo', 'Foo', 'Foo, foo', []);
$account = $this
->createUser();
$message_1 = Message::create([
'template' => $template
->id(),
]);
$message_2 = Message::create([
'template' => $template
->id(),
]);
/** @var \Drupal\message_digest\Plugin\Notifier\DigestInterface $digest_notifier */
$digest_notifier = $this->notifierManager
->createInstance('message_digest:weekly', [], $message_1);
$message_1
->setOwner($account);
$message_1
->save();
$message_2
->setOwner($account);
$message_2
->save();
$this->notifierSender
->send($message_1, [], $digest_notifier
->getPluginId());
$this->notifierSender
->send($message_2, [], $digest_notifier
->getPluginId());
$result = $this->container
->get('database')
->select('message_digest', 'm')
->fields('m')
->execute()
->fetchAllAssoc('id');
$this
->assertEquals(2, count($result));
foreach ($result as $row) {
$this
->assertEquals($account
->id(), $row->receiver);
$this
->assertEquals($digest_notifier
->getPluginId(), $row->notifier);
}
// Aggregate and mark processed.
$start_time = $digest_notifier
->getEndTime();
$recipients = $digest_notifier
->getRecipients();
$this
->assertEquals(1, count($recipients));
foreach ($recipients as $uid) {
$results = $digest_notifier
->aggregate($uid, $start_time);
$digest_notifier
->setLastSent();
$expected = [
'' => [
'' => [
$message_1
->id(),
$message_2
->id(),
],
],
];
$this
->assertSame($expected, $results);
}
// Since this has been marked as sent, the notifier should return FALSE
// for processing again.
$this
->assertFalse($digest_notifier
->processDigest());
// Set last sent time to 8 days in the past.
$last_run = strtotime('-8 days', $this->container
->get('datetime.time')
->getRequestTime());
$this->container
->get('state')
->set($digest_notifier
->getPluginId() . '_last_run', $last_run);
$results = $digest_notifier
->aggregate($account
->id(), $start_time);
$this
->assertSame($expected, $results);
// Aggregate should not return any results once marked sent.
$digest_notifier
->markSent($account, $message_2
->id());
$this
->assertEmpty($digest_notifier
->getRecipients());
}
/**
* Test grouping by entity type, and ID.
*/
public function testDigestGrouping() {
$template = $this
->createMessageTemplate('foo', 'Foo', 'Foo, foo', []);
$account = $this
->createUser();
// Send several messages w/o grouping.
$global_messages = [];
foreach (range(1, 3) as $i) {
$message = Message::create([
'template' => $template
->id(),
]);
$message
->setOwner($account);
$message
->save();
$global_messages[$i] = $message;
$digest_notifier = $this->notifierManager
->createInstance('message_digest:weekly', [], $message);
$this->notifierSender
->send($message, [], $digest_notifier
->getPluginId());
}
// Now send some grouped by entity type.
$configuration = [
'entity_type' => 'foo',
'entity_id' => 'bar',
];
$grouped_messages = [];
foreach (range(1, 3) as $i) {
$message = Message::create([
'template' => $template
->id(),
]);
$message
->setOwner($account);
$message
->save();
$grouped_messages[$i] = $message;
/** @var \Drupal\message_digest\Plugin\Notifier\DigestInterface $digest_notifier */
$digest_notifier = $this->notifierManager
->createInstance('message_digest:weekly', $configuration, $message);
$this->notifierSender
->send($message, $configuration, $digest_notifier
->getPluginId());
}
// Aggregate and mark processed.
$results = $digest_notifier
->aggregate($account
->id(), $digest_notifier
->getEndTime());
$digest_notifier
->setLastSent();
$expected = [
'' => [
'' => [
'1',
'2',
'3',
],
],
'foo' => [
'bar' => [
'4',
'5',
'6',
],
],
];
$this
->assertSame($expected, $results);
}
/**
* Returns some message text, including HTML.
*
* @return array
* An array of message text.
*/
protected function getMessageText() {
$text = [];
// Subject.
$text[] = [
'value' => 'Test subject',
'format' => 'filtered_html',
];
// Body.
$text[] = [
'value' => '<div class="foo-bar">Some sweet <a href="[site:url]">message</a>.',
'format' => 'full_html',
];
return $text;
}
/**
* Tests sending with an entity_id and no type.
*/
public function testInvalidEntityType() {
$configuration = [
'entity_id' => 42,
];
$template = $this
->createMessageTemplate('foo', 'Foo', 'Foo, foo', []);
$message = Message::create([
'template' => $template
->id(),
]);
$digest_notifier = $this->notifierManager
->createInstance('message_digest:weekly', $configuration, $message);
$this
->expectException(InvalidDigestGroupingException::class);
$this
->expectExceptionMessage('Tried to create a message digest without both entity_type () and entity_id (42). These either both need to be empty, or have values.');
$this->notifierSender
->send($message, $configuration, $digest_notifier
->getPluginId());
}
/**
* Tests sending with an entity_type and no ID.
*/
public function testInvalidEntityId() {
$configuration = [
'entity_type' => 'foo',
];
$template = $this
->createMessageTemplate('foo', 'Foo', 'Foo, foo', []);
$message = Message::create([
'template' => $template
->id(),
]);
$digest_notifier = $this->notifierManager
->createInstance('message_digest:weekly', $configuration, $message);
$this
->expectException(InvalidDigestGroupingException::class);
$this
->expectExceptionMessage('Tried to create a message digest without both entity_type (foo) and entity_id (). These either both need to be empty, or have values.');
$this->notifierSender
->send($message, $configuration, $digest_notifier
->getPluginId());
}
/**
* Test old message purging.
*/
public function testMessageCleanup() {
$template = $this
->createMessageTemplate('foo', 'Foo', 'Foo, foo', []);
$account = $this
->createUser();
$messages = [];
// Send 10 messages.
foreach (range(1, 10) as $i) {
$message = Message::create([
'template' => $template
->id(),
]);
$message
->setOwner($account);
$message
->save();
$digest_notifier = $this->notifierManager
->createInstance('message_digest:weekly', [], $message);
$this->notifierSender
->send($message, [], $digest_notifier
->getPluginId());
$messages[$i] = $message;
}
$digest = $digest_notifier
->aggregate($account
->id(), $digest_notifier
->getEndTime());
$this
->assertEquals(10, count($digest['']['']));
$digest_notifier
->markSent($account, $messages[10]
->id());
// Delete 5 messages.
foreach (range(1, 5) as $i) {
$messages[$i]
->delete();
}
$this->digestManager
->cleanupOldMessages();
$result = $this->container
->get('database')
->select('message_digest', 'md')
->fields('md')
->execute()
->fetchAllAssoc('id');
$this
->assertEquals(5, count($result));
foreach ($result as $row) {
$this
->assertGreaterThan(5, $row->mid);
}
}
/**
* Tests that the message_digest table is cleaned up when deleting entities.
*/
public function testOrphanedEntityReferences() {
$template = $this
->createMessageTemplate('foo', 'Foo', 'Foo, foo', []);
// Create 3 test users and send 3 messages, one to each user.
$users = $messages = [];
for ($i = 0; $i < 3; $i++) {
$user = $this
->createUser();
$message = Message::create([
'template' => $template
->id(),
]);
$message
->setOwner($user);
$message
->save();
$digest_notifier = $this->notifierManager
->createInstance('message_digest:weekly', [], $message);
$this->notifierSender
->send($message, [], $digest_notifier
->getPluginId());
$users[$i] = $user;
$messages[$i] = $message;
}
// There should be 3 message digests.
$this
->assertRowCount(3);
// Delete one of the messages and verify that the corresponding message
// digest is cleaned up.
$orphaned_message_id = $messages[0]
->id();
$messages[0]
->delete();
$this
->assertRowCount(2);
foreach ($this
->getAllMessageDigests() as $digest) {
if ($digest->mid == $orphaned_message_id) {
$this
->fail('When a message is deleted its corresponding message digest is cleaned up.');
}
}
// Delete one of the users and verify that the corresponding message digest
// is cleaned up.
$orphaned_user_id = $users[1]
->id();
$users[1]
->delete();
$this
->assertRowCount(1);
foreach ($this
->getAllMessageDigests() as $digest) {
if ($digest->receiver == $orphaned_user_id) {
$this
->fail('When a user is deleted its corresponding message digest is cleaned up.');
}
}
}
/**
* Tests the message digest manager processing.
*/
public function testManagerProcessing() {
$this->digestManager
->processDigests();
$request_time = $this->container
->get('datetime.time')
->getRequestTime();
$this
->assertEquals($request_time, $this->container
->get('state')
->get('message_digest:daily_last_run'));
$this
->assertEquals($request_time, $this->container
->get('state')
->get('message_digest:weekly_last_run'));
$this
->assertEmpty($this
->getMails());
// Actually add some messages now, and reset last sent time.
$last_run = strtotime('-8 days', $this->container
->get('datetime.time')
->getRequestTime());
$this->container
->get('state')
->set('message_digest:weekly_last_run', $last_run);
$template = $this
->createMessageTemplate('foo', 'Foo', 'Foo, foo', $this
->getMessageText());
$account = $this
->createUser();
$messages = [];
// Send 10 messages.
foreach (range(1, 10) as $i) {
$message = Message::create([
'template' => $template
->id(),
]);
$message
->setOwner($account);
$message
->save();
$digest_notifier = $this->notifierManager
->createInstance('message_digest:weekly', [], $message);
$this->notifierSender
->send($message, [], $digest_notifier
->getPluginId());
$messages[$i] = $message;
}
// Ensure cron function actually calls the process method.
$this->container
->get('cron')
->run();
$emails = $this
->getMails();
$this
->assertEquals(1, count($emails));
$this
->assertMail('to', $account
->getEmail());
// Since the core mail service converts HTML to text, that should be be the
// case here too.
$expected = MailFormatHelper::wrapMail(MailFormatHelper::htmlToText(" <div>\n <div>\n Test subject\n</div>\n\n </div>\n <div>\n <div>\n <div class=\"foo-bar\">Some sweet <a href=\"http://localhost/\">message</a>.\n</div>\n\n </div>\n<hr /> <div>\n <div>\n Test subject\n</div>\n\n </div>\n <div>\n <div>\n <div class=\"foo-bar\">Some sweet <a href=\"http://localhost/\">message</a>.\n</div>\n\n </div>\n<hr /> <div>\n <div>\n Test subject\n</div>\n\n </div>\n <div>\n <div>\n <div class=\"foo-bar\">Some sweet <a href=\"http://localhost/\">message</a>.\n</div>\n\n </div>\n<hr /> <div>\n <div>\n Test subject\n</div>\n\n </div>\n <div>\n <div>\n <div class=\"foo-bar\">Some sweet <a href=\"http://localhost/\">message</a>.\n</div>\n\n </div>\n<hr /> <div>\n <div>\n Test subject\n</div>\n\n </div>\n <div>\n <div>\n <div class=\"foo-bar\">Some sweet <a href=\"http://localhost/\">message</a>.\n</div>\n\n </div>\n<hr /> <div>\n <div>\n Test subject\n</div>\n\n </div>\n <div>\n <div>\n <div class=\"foo-bar\">Some sweet <a href=\"http://localhost/\">message</a>.\n</div>\n\n </div>\n<hr /> <div>\n <div>\n Test subject\n</div>\n\n </div>\n <div>\n <div>\n <div class=\"foo-bar\">Some sweet <a href=\"http://localhost/\">message</a>.\n</div>\n\n </div>\n<hr /> <div>\n <div>\n Test subject\n</div>\n\n </div>\n <div>\n <div>\n <div class=\"foo-bar\">Some sweet <a href=\"http://localhost/\">message</a>.\n</div>\n\n </div>\n<hr /> <div>\n <div>\n Test subject\n</div>\n\n </div>\n <div>\n <div>\n <div class=\"foo-bar\">Some sweet <a href=\"http://localhost/\">message</a>.\n</div>\n\n </div>\n<hr /> <div>\n <div>\n Test subject\n</div>\n\n </div>\n <div>\n <div>\n <div class=\"foo-bar\">Some sweet <a href=\"http://localhost/\">message</a>.\n</div>\n\n </div>\n\n"));
$email = reset($emails);
$this
->assertEquals($expected, $email['body']);
}
/**
* Checks that message digest plugins can be correctly serialized.
*/
public function testDigestSerialization() {
foreach ([
'daily',
'weekly',
] as $interval) {
$plugin_id = "message_digest:{$interval}";
$dummy = Message::create([
'template' => 'foo',
]);
/** @var \Drupal\message_digest\Plugin\Notifier\DigestInterface $notifier */
$notifier = $this->notifierManager
->createInstance($plugin_id, [], $dummy);
/** @var \Drupal\message_digest\Plugin\Notifier\DigestInterface $unserialized_notifier */
$unserialized_notifier = unserialize(serialize($notifier));
$this
->assertEquals($plugin_id, $unserialized_notifier
->getPluginId());
}
}
/**
* Tests that a message is not sent if its owner has been deleted.
*/
public function testOrphanedMessage() {
// Create a test user.
$user = $this
->createUser();
// Create a test message owned by the test user.
$template = $this
->createMessageTemplate('foo', 'Foo', 'Foo, foo', []);
$message = Message::create([
'template' => $template
->id(),
]);
/** @var \Drupal\message_digest\Plugin\Notifier\DigestInterface $digest_notifier */
$digest_notifier = $this->notifierManager
->createInstance('message_digest:daily', [], $message);
$message
->setOwner($user);
$message
->save();
// Delete the user.
$user
->delete();
// Deliver the message and send out the digests.
$this->notifierSender
->send($message, [], $digest_notifier
->getPluginId());
$this
->sendDigests();
// Check that no mails have been sent.
$this
->assertEmpty($this
->getMails());
}
/**
* Returns all rows from the message_digest table.
*
* @return array
* An array of all table rows, keyed by ID.
*
* @throws \Exception
* Thrown when the database connection is not available on the container.
*/
protected function getAllMessageDigests() {
return $this->container
->get('database')
->select('message_digest', 'm')
->fields('m')
->execute()
->fetchAllAssoc('id');
}
/**
* Checks that the message_digest table contains the expected number of rows.
*
* @param int $expected_count
* The expected number of rows.
*
* @throws \Exception
* Thrown when the database connection is not available on the container.
*/
protected function assertRowCount($expected_count) {
$this
->assertEquals($expected_count, count($this
->getAllMessageDigests()));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AssertContentTrait:: |
protected | property | The current raw content. | |
AssertContentTrait:: |
protected | property | The drupalSettings value from the current raw $content. | |
AssertContentTrait:: |
protected | property | The XML structure parsed from the current raw $content. | 1 |
AssertContentTrait:: |
protected | property | The plain-text content of raw $content (text nodes). | |
AssertContentTrait:: |
protected | function | Passes if the raw text IS found escaped on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists with the given name or ID. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists with the given ID and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists with the given name and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists in the current page by the given XPath. | |
AssertContentTrait:: |
protected | function | Asserts that a checkbox field in the current page is checked. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists in the current page with a given Xpath result. | |
AssertContentTrait:: |
protected | function | Passes if a link with the specified label is found. | |
AssertContentTrait:: |
protected | function | Passes if a link containing a given href (part) is found. | |
AssertContentTrait:: |
protected | function | Asserts that each HTML ID is used for just a single element. | |
AssertContentTrait:: |
protected | function | Passes if the raw text IS NOT found escaped on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist with the given name or ID. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist with the given ID and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist with the given name and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist or its value does not match, by XPath. | |
AssertContentTrait:: |
protected | function | Asserts that a checkbox field in the current page is not checked. | |
AssertContentTrait:: |
protected | function | Passes if a link with the specified label is not found. | |
AssertContentTrait:: |
protected | function | Passes if a link containing a given href (part) is not found. | |
AssertContentTrait:: |
protected | function | Passes if a link containing a given href is not found in the main region. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page does not exist. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page is not checked. | |
AssertContentTrait:: |
protected | function | Triggers a pass if the perl regex pattern is not found in raw content. | |
AssertContentTrait:: |
protected | function | Passes if the raw text is NOT found on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Passes if the page (with HTML stripped) does not contains the text. | |
AssertContentTrait:: |
protected | function | Pass if the page title is not the given string. | |
AssertContentTrait:: |
protected | function | Passes if the text is found MORE THAN ONCE on the text version of the page. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page exists. | |
AssertContentTrait:: |
protected | function | Asserts that a select option with the visible text exists. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page is checked. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page is checked. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page exists. | |
AssertContentTrait:: |
protected | function | Triggers a pass if the Perl regex pattern is found in the raw content. | |
AssertContentTrait:: |
protected | function | Passes if the raw text IS found on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Passes if the page (with HTML stripped) contains the text. | |
AssertContentTrait:: |
protected | function | Helper for assertText and assertNoText. | |
AssertContentTrait:: |
protected | function | Asserts that a Perl regex pattern is found in the plain-text content. | |
AssertContentTrait:: |
protected | function | Asserts themed output. | |
AssertContentTrait:: |
protected | function | Pass if the page title is the given string. | |
AssertContentTrait:: |
protected | function | Passes if the text is found ONLY ONCE on the text version of the page. | |
AssertContentTrait:: |
protected | function | Helper for assertUniqueText and assertNoUniqueText. | |
AssertContentTrait:: |
protected | function | Builds an XPath query. | |
AssertContentTrait:: |
protected | function | Helper: Constructs an XPath for the given set of attributes and value. | |
AssertContentTrait:: |
protected | function | Searches elements using a CSS selector in the raw content. | |
AssertContentTrait:: |
protected | function | Get all option elements, including nested options, in a select. | |
AssertContentTrait:: |
protected | function | Gets the value of drupalSettings for the currently-loaded page. | |
AssertContentTrait:: |
protected | function | Gets the current raw content. | |
AssertContentTrait:: |
protected | function | Get the selected value from a select field. | |
AssertContentTrait:: |
protected | function | Retrieves the plain-text content from the current raw content. | |
AssertContentTrait:: |
protected | function | Get the current URL from the cURL handler. | 1 |
AssertContentTrait:: |
protected | function | Parse content returned from curlExec using DOM and SimpleXML. | |
AssertContentTrait:: |
protected | function | Removes all white-space between HTML tags from the raw content. | |
AssertContentTrait:: |
protected | function | Sets the value of drupalSettings for the currently-loaded page. | |
AssertContentTrait:: |
protected | function | Sets the raw content (e.g. HTML). | |
AssertContentTrait:: |
protected | function | Performs an xpath search on the contents of the internal browser. | |
AssertHelperTrait:: |
protected static | function | Casts MarkupInterface objects into strings. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertSame() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotSame() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead. | |
AssertLegacyTrait:: |
protected | function | ||
AssertMailTrait:: |
protected | function | Asserts that the most recently sent email message has the given value. | |
AssertMailTrait:: |
protected | function | Asserts that the most recently sent email message has the pattern in it. | |
AssertMailTrait:: |
protected | function | Asserts that the most recently sent email message has the string in it. | |
AssertMailTrait:: |
protected | function | Gets an array containing all emails sent during this test case. | |
AssertMailTrait:: |
protected | function | Outputs to verbose the most recent $count emails sent. | |
ConfigTestTrait:: |
protected | function | Returns a ConfigImporter object to import test configuration. | |
ConfigTestTrait:: |
protected | function | Copies configuration objects from source storage to target storage. | |
DigestTestBase:: |
protected | property | The message digest manager. | |
DigestTestBase:: |
public static | property |
Modules to enable. Overrides KernelTestBase:: |
1 |
DigestTestBase:: |
protected | property | Message notifier plugin manager. | |
DigestTestBase:: |
protected | property | The message notify sender service. | |
DigestTestBase:: |
protected | function | Helper method to process and deliver digests. | |
DigestTestBase:: |
public | function |
Overrides KernelTestBase:: |
|
KernelTestBase:: |
protected | property | Back up and restore any global variables that may be changed by tests. | |
KernelTestBase:: |
protected | property | Back up and restore static class properties that may be changed by tests. | |
KernelTestBase:: |
protected | property | Contains a few static class properties for performance. | |
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | @todo Move into Config test base class. | 7 |
KernelTestBase:: |
protected static | property | An array of config object names that are excluded from schema checking. | |
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | Do not forward any global state from the parent process to the processes that run the actual tests. | |
KernelTestBase:: |
protected | property | The app root. | |
KernelTestBase:: |
protected | property | Kernel tests are run in separate processes because they allow autoloading of code from extensions. Running the test in a separate process isolates this behavior from other tests. Subclasses should not override this property. | |
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | Set to TRUE to strict check all configuration saved. | 6 |
KernelTestBase:: |
protected | property | The virtual filesystem root directory. | |
KernelTestBase:: |
protected | function | 1 | |
KernelTestBase:: |
protected | function | Bootstraps a basic test environment. | |
KernelTestBase:: |
private | function | Bootstraps a kernel for a test. | |
KernelTestBase:: |
protected | function | Configuration accessor for tests. Returns non-overridden configuration. | |
KernelTestBase:: |
protected | function | Disables modules for this test. | |
KernelTestBase:: |
protected | function | Enables modules for this test. | |
KernelTestBase:: |
protected | function | Gets the config schema exclusions for this test. | |
KernelTestBase:: |
protected | function | Returns the Database connection info to be used for this test. | 1 |
KernelTestBase:: |
public | function | ||
KernelTestBase:: |
private | function | Returns Extension objects for $modules to enable. | |
KernelTestBase:: |
private static | function | Returns the modules to enable for this test. | |
KernelTestBase:: |
protected | function | Initializes the FileCache component. | |
KernelTestBase:: |
protected | function | Installs default configuration for a given list of modules. | |
KernelTestBase:: |
protected | function | Installs the storage schema for a specific entity type. | |
KernelTestBase:: |
protected | function | Installs database tables from a module schema definition. | |
KernelTestBase:: |
protected | function | Returns whether the current test method is running in a separate process. | |
KernelTestBase:: |
protected | function | ||
KernelTestBase:: |
public | function |
Registers test-specific services. Overrides ServiceProviderInterface:: |
26 |
KernelTestBase:: |
protected | function | Renders a render array. | 1 |
KernelTestBase:: |
protected | function | Sets the install profile and rebuilds the container to update it. | |
KernelTestBase:: |
protected | function | Sets an in-memory Settings variable. | |
KernelTestBase:: |
public static | function | 1 | |
KernelTestBase:: |
protected | function | Sets up the filesystem, so things like the file directory. | 2 |
KernelTestBase:: |
protected | function | Stops test execution. | |
KernelTestBase:: |
protected | function | 6 | |
KernelTestBase:: |
public | function | @after | |
KernelTestBase:: |
protected | function | Dumps the current state of the virtual filesystem to STDOUT. | |
KernelTestBase:: |
public | function | BC: Automatically resolve former KernelTestBase class properties. | |
KernelTestBase:: |
public | function | Prevents serializing any properties. | |
MessageDigestTest:: |
protected | function | Checks that the message_digest table contains the expected number of rows. | |
MessageDigestTest:: |
protected | function | Returns all rows from the message_digest table. | |
MessageDigestTest:: |
protected | function | Returns some message text, including HTML. | |
MessageDigestTest:: |
public | function | Data provider for ::testNotifierDelivery(). | |
MessageDigestTest:: |
public | function | Test grouping by entity type, and ID. | |
MessageDigestTest:: |
public | function | Tests the plugin deriver for daily and weekly digests. | |
MessageDigestTest:: |
public | function | Checks that message digest plugins can be correctly serialized. | |
MessageDigestTest:: |
public | function | Tests sending with an entity_type and no ID. | |
MessageDigestTest:: |
public | function | Tests sending with an entity_id and no type. | |
MessageDigestTest:: |
public | function | Tests the message digest manager processing. | |
MessageDigestTest:: |
public | function | Test old message purging. | |
MessageDigestTest:: |
public | function | Tests message aggregation. | |
MessageDigestTest:: |
public | function | Tests the notifier sending and delivery. | |
MessageDigestTest:: |
public | function | Tests that the message_digest table is cleaned up when deleting entities. | |
MessageDigestTest:: |
public | function | Tests that a message is not sent if its owner has been deleted. | |
MessageTemplateCreateTrait:: |
protected | function | Helper function to create and save a message template entity. | |
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. | |
RandomGeneratorTrait:: |
protected | property | The random generator. | |
RandomGeneratorTrait:: |
protected | function | Gets the random generator for the utility methods. | |
RandomGeneratorTrait:: |
protected | function | Generates a unique random string containing letters and numbers. | 1 |
RandomGeneratorTrait:: |
public | function | Generates a random PHP object. | |
RandomGeneratorTrait:: |
public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |
RandomGeneratorTrait:: |
public | function | Callback for random string validation. | |
StorageCopyTrait:: |
protected static | function | Copy the configuration from one storage to another and remove stale items. | |
TestRequirementsTrait:: |
private | function | Checks missing module requirements. | |
TestRequirementsTrait:: |
protected | function | Check module requirements for the Drupal use case. | 1 |
TestRequirementsTrait:: |
protected static | function | Returns the Drupal root directory. | |
UserCreationTrait:: |
protected | function | Checks whether a given list of permission names is valid. | |
UserCreationTrait:: |
protected | function | Creates an administrative role. | |
UserCreationTrait:: |
protected | function | Creates a role with specified permissions. | |
UserCreationTrait:: |
protected | function | Create a user with a given set of permissions. | |
UserCreationTrait:: |
protected | function | Grant permissions to a user role. | |
UserCreationTrait:: |
protected | function | Switch the current logged in user. | |
UserCreationTrait:: |
protected | function | Creates a random user account and sets it as current user. |