protected function ChosenFieldWidgetsTest::setUp in Chosen 3.0.x
Same name and namespace in other branches
- 8.2 modules/chosen_field/tests/src/Functional/ChosenFieldWidgetsTest.php \Drupal\Tests\chosen_field\Functional\ChosenFieldWidgetsTest::setUp()
Function used to setup before running the test.
Overrides BrowserTestBase::setUp
File
- modules/
chosen_field/ tests/ src/ Functional/ ChosenFieldWidgetsTest.php, line 52
Class
- ChosenFieldWidgetsTest
- Test the Chosen widgets.
Namespace
Drupal\Tests\chosen_field\FunctionalCode
protected function setUp() {
parent::setUp();
// Field storage with cardinality 1.
$this->card_1 = \Drupal::entityTypeManager()
->getStorage('field_storage_config')
->create([
'field_name' => 'card_1',
'entity_type' => 'entity_test',
'type' => 'list_integer',
'cardinality' => 1,
'settings' => [
'allowed_values' => [
// Make sure that 0 works as an option.
0 => 'Zero',
1 => 'One',
// Make sure that option text is properly sanitized.
2 => 'Some <script>dangerous</script> & unescaped <strong>markup</strong>',
// Make sure that HTML entities in option text are not double-encoded.
3 => 'Some HTML encoded markup with < & >',
],
],
]);
$this->card_1
->save();
// Field storage with cardinality 2.
$this->card_2 = \Drupal::entityTypeManager()
->getStorage('field_storage_config')
->create([
'field_name' => 'card_2',
'entity_type' => 'entity_test',
'type' => 'list_integer',
'cardinality' => 2,
'settings' => [
'allowed_values' => [
// Make sure that 0 works as an option.
0 => 'Zero',
1 => 'One',
// Make sure that option text is properly sanitized.
2 => 'Some <script>dangerous</script> & unescaped <strong>markup</strong>',
],
],
]);
$this->card_2
->save();
// Create a web user.
$this
->drupalLogin($this
->drupalCreateUser([
'view test entity',
'administer entity_test content',
]));
}