protected function TwigWhiteListTest::setUp in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Theme/TwigWhiteListTest.php \Drupal\system\Tests\Theme\TwigWhiteListTest::setUp()
Performs setup tasks before each individual test method is run.
Overrides KernelTestBase::setUp
File
- core/
modules/ system/ src/ Tests/ Theme/ TwigWhiteListTest.php, line 47 - Contains \Drupal\system\Tests\Theme\TwigWhiteListTest.php.
Class
- TwigWhiteListTest
- Tests white-listing of entity properties.
Namespace
Drupal\system\Tests\ThemeCode
protected function setUp() {
parent::setUp();
$this
->installSchema('system', array(
'router',
'sequences',
));
$this
->installEntitySchema('node');
$this
->installEntitySchema('user');
$this
->installEntitySchema('taxonomy_term');
NodeType::create([
'type' => 'page',
'name' => 'Basic page',
'display_submitted' => FALSE,
])
->save();
// Add a vocabulary so we can test different view modes.
$vocabulary = Vocabulary::create([
'name' => $this
->randomMachineName(),
'description' => $this
->randomMachineName(),
'vid' => $this
->randomMachineName(),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'help' => '',
]);
$vocabulary
->save();
// Add a term to the vocabulary.
$this->term = Term::create([
'name' => 'Sometimes people are just jerks',
'description' => $this
->randomMachineName(),
'vid' => $vocabulary
->id(),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
]);
$this->term
->save();
// Create a field.
$handler_settings = array(
'target_bundles' => array(
$vocabulary
->id() => $vocabulary
->id(),
),
'auto_create' => TRUE,
);
// Add the term field.
FieldStorageConfig::create(array(
'field_name' => 'field_term',
'type' => 'entity_reference',
'entity_type' => 'node',
'cardinality' => 1,
'settings' => array(
'target_type' => 'taxonomy_term',
),
))
->save();
FieldConfig::create(array(
'field_name' => 'field_term',
'entity_type' => 'node',
'bundle' => 'page',
'label' => 'Terms',
'settings' => array(
'handler' => 'default',
'handler_settings' => $handler_settings,
),
))
->save();
// Show on default display and teaser.
entity_get_display('node', 'page', 'default')
->setComponent('field_term', array(
'type' => 'entity_reference_label',
))
->save();
// Boot twig environment.
$this->twig = \Drupal::service('twig');
}