function TaxonomyFieldFilterTest::setUp in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php \Drupal\taxonomy\Tests\Views\TaxonomyFieldFilterTest::setUp()
Sets up a Drupal site for running functional and integration tests.
Installs Drupal with the installation profile specified in \Drupal\simpletest\WebTestBase::$profile into the prefixed database.
Afterwards, installs any additional modules specified in the static \Drupal\simpletest\WebTestBase::$modules property of each class in the class hierarchy.
After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.
Overrides ViewTestBase::setUp
File
- core/
modules/ taxonomy/ src/ Tests/ Views/ TaxonomyFieldFilterTest.php, line 49 - Contains \Drupal\taxonomy\Tests\Views\TaxonomyFieldFilterTest.
Class
- TaxonomyFieldFilterTest
- Tests taxonomy field filters with translations.
Namespace
Drupal\taxonomy\Tests\ViewsCode
function setUp() {
parent::setUp();
// Add two new languages.
ConfigurableLanguage::createFromLangcode('fr')
->save();
ConfigurableLanguage::createFromLangcode('es')
->save();
// Set up term names.
$this->termNames = array(
'en' => 'Food in Paris',
'es' => 'Comida en Paris',
'fr' => 'Nouriture en Paris',
);
// Create a vocabulary.
$this->vocabulary = entity_create('taxonomy_vocabulary', array(
'name' => 'Views testing tags',
'vid' => 'views_testing_tags',
));
$this->vocabulary
->save();
// Add a translatable field to the vocabulary.
$field = entity_create('field_storage_config', array(
'field_name' => 'field_foo',
'entity_type' => 'taxonomy_term',
'type' => 'text',
));
$field
->save();
entity_create('field_config', array(
'field_name' => 'field_foo',
'entity_type' => 'taxonomy_term',
'label' => 'Foo',
'bundle' => 'views_testing_tags',
))
->save();
// Create term with translations.
$taxonomy = $this
->createTermWithProperties(array(
'name' => $this->termNames['en'],
'langcode' => 'en',
'description' => $this->termNames['en'],
'field_foo' => $this->termNames['en'],
));
foreach (array(
'es',
'fr',
) as $langcode) {
$translation = $taxonomy
->addTranslation($langcode, array(
'name' => $this->termNames[$langcode],
));
$translation->description->value = $this->termNames[$langcode];
$translation->field_foo->value = $this->termNames[$langcode];
}
$taxonomy
->save();
Views::viewsData()
->clear();
ViewTestData::createTestViews(get_class($this), array(
'taxonomy_test_views',
));
$this->container
->get('router.builder')
->rebuild();
}