RecipientPluginUpdatePathTest.php in Workbench Email 8
File
tests/src/Functional/RecipientPluginUpdatePathTest.php
View source
<?php
namespace Drupal\Tests\workbench_email\Functional;
use Composer\Semver\Semver;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
class RecipientPluginUpdatePathTest extends UpdatePathTestBase {
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../fixtures/update/recipient-plugins.php.gz',
];
}
public function testUpdatePath() {
if (Semver::satisfies(\Drupal::VERSION, '~9')) {
$this
->markTestSkipped('This test is only for Drupal 8');
}
$this->container
->get('module_installer')
->install([
'block',
]);
$this
->runUpdates();
$entity_type_manager = $this->container
->get('entity_type.manager');
$template = $entity_type_manager
->getStorage('workbench_email_template')
->load('send');
$nodes = $entity_type_manager
->getStorage('node')
->loadByProperties([
'title' => 'test node',
]);
$recipients = $template
->getRecipients(reset($nodes));
$expected = [
'bob@example.com',
'admin@example.com',
'terri@example.com',
];
$this
->assertEquals(sort($expected), sort($recipients));
$this
->assertNull($template
->get('author'));
$this
->assertNull($template
->get('fields'));
$this
->assertNull($template
->get('roles'));
}
}