protected function IpAddressFieldTest::setUp in IP address fields 8
Same name and namespace in other branches
- 2.0.x src/Tests/IpAddressFieldTest.php \Drupal\field_ipaddress\Tests\IpAddressFieldTest::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 WebTestBase::setUp
File
- src/
Tests/ IpAddressFieldTest.php, line 39
Class
- IpAddressFieldTest
- Tests IP address field functionality.
Namespace
Drupal\field_ipaddress\TestsCode
protected function setUp() {
parent::setUp();
$web_user = $this
->drupalCreateUser([
'access content',
'view test entity',
'administer entity_test content',
'administer entity_test form display',
'administer content types',
'administer node fields',
]);
$this
->drupalLogin($web_user);
$this->fieldStorage = FieldStorageConfig::create([
'field_name' => $this->field_name,
'entity_type' => 'entity_test',
'type' => 'ipaddress',
'settings' => [],
]);
$this->fieldStorage
->save();
$this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => 'entity_test',
'required' => TRUE,
]);
$this->field
->save();
// Create a form display for the default form mode.
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($this->field_name, [
'type' => 'ipaddress_default',
])
->save();
}