public function SubscriptionsBlockTest::setUp in Message Subscribe 8
Overrides BrowserTestBase::setUp
File
- message_subscribe_ui/
tests/ src/ Functional/ SubscriptionsBlockTest.php, line 69
Class
- SubscriptionsBlockTest
- Tests for the advanced subscriptions block.
Namespace
Drupal\Tests\message_subscribe_ui\FunctionalCode
public function setUp() {
parent::setUp();
$this->adminUser = $this
->createUser([], NULL, TRUE);
// Permission to flag/unflag users is intentionally omitted.
$permissions = [
'access user profiles',
'flag subscribe_node',
'unflag subscribe_node',
'flag subscribe_term',
'unflag subscribe_term',
];
$this->webUser = $this
->createUser($permissions);
$this
->createContentType([
'type' => 'article',
]);
// Add some entities that can be referenced.
foreach (range(1, 2) as $i) {
$vocab = $this
->createVocabulary();
$handler_settings = [
'target_bundles' => [
$vocab
->id() => $vocab
->id(),
],
];
$this
->createEntityReferenceField('node', 'article', 'field_terms_' . $i, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinition::CARDINALITY_UNLIMITED);
foreach (range(1, 5) as $j) {
$this->terms[] = $this
->createTerm($vocab);
}
}
$this->node = $this
->createNode([
'type' => 'article',
'uid' => $this->adminUser
->id(),
'field_terms_1' => [
$this->terms[1],
$this->terms[3],
],
'field_terms_2' => [
$this->terms[7],
$this->terms[9],
],
]);
// Place the subscription block.
$this
->placeBlock('message_subscribe_ui_block', [
'label' => t('Manage subscriptions'),
]);
$this->flagService = $this->container
->get('flag');
}