protected function setUp()
 {
     parent::setUp();
     // Create test user.
     $admin_user = $this->drupalCreateUser(array('synchronize configuration', 'access content', 'access administration pages', 'administer site configuration', 'administer content types', 'administer nodes', 'bypass node access', 'administer node fields', 'administer node display'));
     $this->drupalLogin($admin_user);
 }
Beispiel #2
0
 public function setUp()
 {
     parent::setUp();
     $web_user = $this->drupalCreateUser(array('view test entity', 'administer entity_test content'));
     $this->drupalLogin($web_user);
     $this->fieldStorageSingle = array('name' => 'field_single', 'entity_type' => 'entity_test', 'type' => 'test_field');
     $this->fieldStorageUnlimited = array('name' => 'field_unlimited', 'entity_type' => 'entity_test', 'type' => 'test_field', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
     $this->instance = array('entity_type' => 'entity_test', 'bundle' => 'entity_test', 'label' => $this->randomName() . '_label', 'description' => '[site:name]_description', 'weight' => mt_rand(0, 127), 'settings' => array('test_instance_setting' => $this->randomName()));
 }
 protected function setUp()
 {
     parent::setUp();
     // Create test user.
     $admin_user = $this->drupalCreateUser(['access content', 'administer taxonomy', 'access administration pages', 'administer site configuration', 'administer content types', 'administer nodes', 'bypass node access', 'administer node fields', 'administer node display']);
     $this->drupalLogin($admin_user);
     // Create content type, with underscores.
     $this->typeName = 'test_' . strtolower($this->randomMachineName());
     $type = $this->drupalCreateContentType(['name' => $this->typeName, 'type' => $this->typeName]);
     $this->type = $type->id();
 }
 protected function setUp()
 {
     parent::setUp();
     // Field storage with cardinality 1.
     $this->card1 = entity_create('field_storage_config', ['field_name' => 'card_1', 'entity_type' => 'entity_test', 'type' => 'list_integer', 'cardinality' => 1, 'settings' => ['allowed_values' => [0 => 'Zero', 1 => 'One', 2 => 'Some <script>dangerous</script> & unescaped <strong>markup</strong>', 3 => 'Some HTML encoded markup with &lt; &amp; &gt;']]]);
     $this->card1->save();
     // Field storage with cardinality 2.
     $this->card2 = entity_create('field_storage_config', ['field_name' => 'card_2', 'entity_type' => 'entity_test', 'type' => 'list_integer', 'cardinality' => 2, 'settings' => ['allowed_values' => [0 => 'Zero', 1 => 'One', 2 => 'Some <script>dangerous</script> & unescaped <strong>markup</strong>']]]);
     $this->card2->save();
     // Create a web user.
     $this->drupalLogin($this->drupalCreateUser(['view test entity', 'administer entity_test content']));
 }
 function setUp()
 {
     parent::setUp();
     $this->field_name = 'test_options';
     entity_create('field_storage_config', array('name' => $this->field_name, 'entity_type' => 'entity_test_rev', 'type' => 'list_text', 'cardinality' => 1, 'settings' => array('allowed_values_function' => 'options_test_dynamic_values_callback')))->save();
     $this->instance = entity_create('field_instance_config', array('field_name' => $this->field_name, 'entity_type' => 'entity_test_rev', 'bundle' => 'entity_test_rev', 'required' => TRUE))->save();
     entity_get_form_display('entity_test_rev', 'entity_test_rev', 'default')->setComponent($this->field_name, array('type' => 'options_select'))->save();
     // Create an entity and prepare test data that will be used by
     // options_test_dynamic_values_callback().
     $values = array('user_id' => mt_rand(1, 10), 'name' => $this->randomMachineName());
     $this->entity = entity_create('entity_test_rev', $values);
     $this->entity->save();
     $this->test = array('label' => $this->entity->label(), 'uuid' => $this->entity->uuid(), 'bundle' => $this->entity->bundle(), 'uri' => $this->entity->url());
 }
Beispiel #6
0
 protected function setUp()
 {
     parent::setUp();
     $this->fieldName = Unicode::strtolower($this->randomMachineName() . '_field_name');
     $field_storage = array('field_name' => $this->fieldName, 'entity_type' => $this->entityTypeId, 'type' => 'test_field', 'cardinality' => 4);
     entity_create('field_storage_config', $field_storage)->save();
     $this->fieldStorage = FieldStorageConfig::load($this->entityTypeId . '.' . $this->fieldName);
     $field = array('field_storage' => $this->fieldStorage, 'bundle' => $this->entityTypeId);
     entity_create('field_config', $field)->save();
     $this->field = FieldConfig::load($this->entityTypeId . '.' . $field['bundle'] . '.' . $this->fieldName);
     entity_get_form_display($this->entityTypeId, $this->entityTypeId, 'default')->setComponent($this->fieldName)->save();
     for ($i = 0; $i < 3; ++$i) {
         ConfigurableLanguage::create(array('id' => 'l' . $i, 'label' => $this->randomString()))->save();
     }
 }
 protected function setUp()
 {
     parent::setUp();
     $field_name = 'test_options';
     $this->fieldStorage = FieldStorageConfig::create(['field_name' => $field_name, 'entity_type' => 'entity_test_rev', 'type' => 'list_string', 'cardinality' => 1, 'settings' => ['allowed_values_function' => 'options_test_dynamic_values_callback']]);
     $this->fieldStorage->save();
     $this->field = FieldConfig::create(['field_name' => $field_name, 'entity_type' => 'entity_test_rev', 'bundle' => 'entity_test_rev', 'required' => TRUE])->save();
     entity_get_form_display('entity_test_rev', 'entity_test_rev', 'default')->setComponent($field_name, ['type' => 'options_select'])->save();
     // Create an entity and prepare test data that will be used by
     // options_test_dynamic_values_callback().
     $values = ['user_id' => mt_rand(1, 10), 'name' => $this->randomMachineName()];
     $this->entity = EntityTestRev::create($values);
     $this->entity->save();
     $this->test = ['label' => $this->entity->label(), 'uuid' => $this->entity->uuid(), 'bundle' => $this->entity->bundle(), 'uri' => $this->entity->url()];
 }
 function setUp()
 {
     parent::setUp();
     $this->field_name = drupal_strtolower($this->randomName() . '_field_name');
     $field = array('name' => $this->field_name, 'entity_type' => $this->entity_type, 'type' => 'test_field', 'cardinality' => 4, 'translatable' => TRUE);
     entity_create('field_storage_config', $field)->save();
     $this->fieldStorage = entity_load('field_storage_config', $this->entity_type . '.' . $this->field_name);
     $instance = array('field_storage' => $this->fieldStorage, 'bundle' => $this->entity_type);
     entity_create('field_instance_config', $instance)->save();
     $this->instance = entity_load('field_instance_config', $this->entity_type . '.' . $instance['bundle'] . '.' . $this->field_name);
     entity_get_form_display($this->entity_type, $this->entity_type, 'default')->setComponent($this->field_name)->save();
     for ($i = 0; $i < 3; ++$i) {
         $language = new Language(array('id' => 'l' . $i, 'name' => $this->randomString()));
         language_save($language);
     }
 }
 protected function setUp()
 {
     parent::setUp();
     $web_user = $this->drupalCreateUser(array('view test_view_field content'));
     $this->drupalLogin($web_user);
     // Create content type.
     $content_type_info = $this->drupalCreateContentType();
     $content_type = $content_type_info->id();
     $field_storage = array('field_name' => 'test_view_field', 'entity_type' => 'node', 'type' => 'text');
     FieldStorageConfig::create($field_storage)->save();
     $field = array('field_name' => $field_storage['field_name'], 'entity_type' => 'node', 'bundle' => $content_type);
     FieldConfig::create($field)->save();
     // Assign display properties for the 'default' and 'teaser' view modes.
     foreach (array('default', 'teaser') as $view_mode) {
         entity_get_display('node', $content_type, $view_mode)->setComponent($field_storage['field_name'])->save();
     }
     // Create test node.
     $this->testViewFieldValue = 'This is some text';
     $settings = array();
     $settings['type'] = $content_type;
     $settings['title'] = 'Field view access test';
     $settings['test_view_field'] = array(array('value' => $this->testViewFieldValue));
     $this->node = $this->drupalCreateNode($settings);
 }
 protected function setUp()
 {
     parent::setUp();
     $this->drupalLogin($this->drupalCreateUser(array('synchronize configuration')));
 }