protected function ArgumentValidatorTest::setUp in Views taxonomy term name into ID 8
Overrides ViewTestBase::setUp
File
- tests/
src/ Functional/ ArgumentValidatorTest.php, line 65
Class
- ArgumentValidatorTest
- Tests the taxonomy term name transformed into ID argument validator.
Namespace
Drupal\Tests\views_taxonomy_term_name_into_id\FunctionalCode
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
ViewTestData::createTestViews(get_class($this), [
'views_taxonomy_term_name_into_id_test',
]);
// Create the vocabulary for the tag field.
$vocabulary = $this
->createVocabulary();
// Create content type.
$this
->drupalCreateContentType([
'type' => 'article',
]);
$field_name = 'field_' . $vocabulary
->id();
$handler_settings = [
'target_bundles' => [
$vocabulary
->id() => $vocabulary
->id(),
],
'auto_create' => TRUE,
];
$this
->createEntityReferenceField('node', 'article', $field_name, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
// Create terms.
$this->terms[1] = $this
->createTerm($vocabulary, [
'name' => 'First',
]);
$this->terms[2] = $this
->createTerm($vocabulary, [
'name' => 'Second',
]);
// Create a node and link it to the first term.
$settings = [
'type' => 'article',
'title' => 'Article 1',
];
$settings[$field_name][0]['target_id'] = $this->terms[1]
->id();
$this->node = $this
->drupalCreateNode($settings);
}