protected function WorkbenchEmailTestBase::assertNeedsReviewNotifications in Workbench Email 8
Same name and namespace in other branches
- 2.x tests/src/Functional/WorkbenchEmailTestBase.php \Drupal\Tests\workbench_email\Functional\WorkbenchEmailTestBase::assertNeedsReviewNotifications()
Assert notifications sent for needs review.
Parameters
\Drupal\node\NodeInterface $node: Node updated.
1 call to WorkbenchEmailTestBase::assertNeedsReviewNotifications()
- WorkbenchEmailTestBase::testEndToEnd in tests/
src/ Functional/ WorkbenchEmailTestBase.php - Test administration.
File
- tests/
src/ Functional/ WorkbenchEmailTestBase.php, line 409
Class
- WorkbenchEmailTestBase
- Defines a base class for workbench email tests.
Namespace
Drupal\Tests\workbench_email\FunctionalCode
protected function assertNeedsReviewNotifications(NodeInterface $node) {
// Check mail goes to approvers.
$captured_emails = $this->container
->get('state')
->get('system.test_mail_collector') ?: [];
// Should only be two emails.
$this
->assertCount(2, $captured_emails);
$last = end($captured_emails);
$prev = prev($captured_emails);
$mails = [
$last['to'],
$prev['to'],
];
sort($mails);
$expected = [
$this->approver1
->getEmail(),
$this->approver2
->getEmail(),
];
sort($expected);
$this
->assertEquals($expected, $mails);
$this
->assertEquals(sprintf('Content needs review: %s', $node
->getTitle()), $last['subject']);
$this
->assertEquals(sprintf('Content needs review: %s', $node
->getTitle()), $prev['subject']);
$this
->assertEquals($this->editor
->getEmail(), $last['reply-to']);
$this
->assertEquals($this->editor
->getEmail(), $prev['reply-to']);
$this
->assertStringContainsString(sprintf('Content with title %s needs review. You can view it at', $node
->label()), preg_replace('/\\s+/', ' ', $prev['body']));
$this
->assertStringContainsString(sprintf('Content with title %s needs review. You can view it at', $node
->label()), preg_replace('/\\s+/', ' ', $last['body']));
$this
->assertStringContainsString($node
->toUrl('canonical', [
'absolute' => TRUE,
])
->toString(), preg_replace('/\\s+/', ' ', $prev['body']));
$this
->assertStringContainsString($node
->toUrl('canonical', [
'absolute' => TRUE,
])
->toString(), preg_replace('/\\s+/', ' ', $last['body']));
}