Issue #2396701 by hussainweb: Clean-up options module test members - ensure property definition and use of camelCase naming convention
parent
e6d2492039
commit
f85d43e317
|
@ -37,6 +37,13 @@ abstract class LocaleUpdateBase extends WebTestBase {
|
|||
*/
|
||||
protected $timestampNew;
|
||||
|
||||
/**
|
||||
* Timestamp for current time.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $timestampNow;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
|
@ -59,7 +66,7 @@ abstract class LocaleUpdateBase extends WebTestBase {
|
|||
$this->timestampOld = REQUEST_TIME - 300;
|
||||
$this->timestampMedium = REQUEST_TIME - 200;
|
||||
$this->timestampNew = REQUEST_TIME - 100;
|
||||
$this->timestamp_now = REQUEST_TIME;
|
||||
$this->timestampNow = REQUEST_TIME;
|
||||
|
||||
// Enable import of translations. By default this is disabled for automated
|
||||
// tests.
|
||||
|
|
|
@ -141,7 +141,7 @@ class LocaleUpdateTest extends LocaleUpdateBase {
|
|||
// Check the status on the Available translation status page.
|
||||
$this->assertRaw('<label for="edit-langcodes-de" class="visually-hidden">Update German</label>', 'German language found');
|
||||
$this->assertText('Updates for: Contributed module one, Contributed module two, Custom module one, Locale test', 'Updates found');
|
||||
$this->assertText('Contributed module one (' . format_date($this->timestamp_now, 'html_date') . ')', 'Updates for Contrib module one');
|
||||
$this->assertText('Contributed module one (' . format_date($this->timestampNow, 'html_date') . ')', 'Updates for Contrib module one');
|
||||
$this->assertText('Contributed module two (' . format_date($this->timestampNew, 'html_date') . ')', 'Updates for Contrib module two');
|
||||
|
||||
// Execute the translation update.
|
||||
|
@ -158,10 +158,10 @@ class LocaleUpdateTest extends LocaleUpdateBase {
|
|||
// from the database. The function was called earlier during this test.
|
||||
drupal_static_reset('locale_translation_get_file_history');
|
||||
$history = locale_translation_get_file_history();
|
||||
$this->assertTrue($history['contrib_module_one']['de']->timestamp >= $this->timestamp_now, 'Translation of contrib_module_one is imported');
|
||||
$this->assertTrue($history['contrib_module_one']['de']->last_checked >= $this->timestamp_now, 'Translation of contrib_module_one is updated');
|
||||
$this->assertTrue($history['contrib_module_one']['de']->timestamp >= $this->timestampNow, 'Translation of contrib_module_one is imported');
|
||||
$this->assertTrue($history['contrib_module_one']['de']->last_checked >= $this->timestampNow, 'Translation of contrib_module_one is updated');
|
||||
$this->assertEqual($history['contrib_module_two']['de']->timestamp, $this->timestampNew, 'Translation of contrib_module_two is imported');
|
||||
$this->assertTrue($history['contrib_module_two']['de']->last_checked >= $this->timestamp_now, 'Translation of contrib_module_two is updated');
|
||||
$this->assertTrue($history['contrib_module_two']['de']->last_checked >= $this->timestampNow, 'Translation of contrib_module_two is updated');
|
||||
$this->assertEqual($history['contrib_module_three']['de']->timestamp, $this->timestampMedium, 'Translation of contrib_module_three is not imported');
|
||||
$this->assertEqual($history['contrib_module_three']['de']->last_checked, $this->timestampMedium, 'Translation of contrib_module_three is not updated');
|
||||
|
||||
|
@ -215,7 +215,7 @@ class LocaleUpdateTest extends LocaleUpdateBase {
|
|||
$this->assertTrue($history['contrib_module_one']['de']->timestamp >= $this->timestampMedium, 'Translation of contrib_module_one is imported');
|
||||
$this->assertEqual($history['contrib_module_one']['de']->last_checked, $this->timestampMedium, 'Translation of contrib_module_one is updated');
|
||||
$this->assertEqual($history['contrib_module_two']['de']->timestamp, $this->timestampNew, 'Translation of contrib_module_two is imported');
|
||||
$this->assertTrue($history['contrib_module_two']['de']->last_checked >= $this->timestamp_now, 'Translation of contrib_module_two is updated');
|
||||
$this->assertTrue($history['contrib_module_two']['de']->last_checked >= $this->timestampNow, 'Translation of contrib_module_two is updated');
|
||||
$this->assertEqual($history['contrib_module_three']['de']->timestamp, $this->timestampMedium, 'Translation of contrib_module_three is not imported');
|
||||
$this->assertEqual($history['contrib_module_three']['de']->last_checked, $this->timestampMedium, 'Translation of contrib_module_three is not updated');
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ abstract class OptionsDynamicValuesTestBase extends FieldTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('options', 'entity_test', 'options_test');
|
||||
public static $modules = ['options', 'entity_test', 'options_test'];
|
||||
|
||||
/**
|
||||
* The created entity.
|
||||
|
@ -38,43 +38,43 @@ abstract class OptionsDynamicValuesTestBase extends FieldTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->field_name = 'test_options';
|
||||
$this->fieldStorage = entity_create('field_storage_config', array(
|
||||
'field_name' => $this->field_name,
|
||||
$field_name = 'test_options';
|
||||
$this->fieldStorage = entity_create('field_storage_config', [
|
||||
'field_name' => $field_name,
|
||||
'entity_type' => 'entity_test_rev',
|
||||
'type' => 'list_string',
|
||||
'cardinality' => 1,
|
||||
'settings' => array(
|
||||
'settings' => [
|
||||
'allowed_values_function' => 'options_test_dynamic_values_callback',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
$this->fieldStorage->save();
|
||||
|
||||
$this->field = entity_create('field_config', array(
|
||||
'field_name' => $this->field_name,
|
||||
$this->field = entity_create('field_config', [
|
||||
'field_name' => $field_name,
|
||||
'entity_type' => 'entity_test_rev',
|
||||
'bundle' => 'entity_test_rev',
|
||||
'required' => TRUE,
|
||||
))->save();
|
||||
])->save();
|
||||
entity_get_form_display('entity_test_rev', 'entity_test_rev', 'default')
|
||||
->setComponent($this->field_name, array(
|
||||
->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 = array(
|
||||
$values = [
|
||||
'user_id' => mt_rand(1, 10),
|
||||
'name' => $this->randomMachineName(),
|
||||
);
|
||||
];
|
||||
$this->entity = entity_create('entity_test_rev', $values);
|
||||
$this->entity->save();
|
||||
$this->test = array(
|
||||
$this->test = [
|
||||
'label' => $this->entity->label(),
|
||||
'uuid' => $this->entity->uuid(),
|
||||
'bundle' => $this->entity->bundle(),
|
||||
'uri' => $this->entity->url(),
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,19 +29,39 @@ class OptionsFieldUITest extends FieldTestBase {
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type_name;
|
||||
protected $typeName;
|
||||
|
||||
/**
|
||||
* Machine name of the created content type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* Name of the option field.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $fieldName;
|
||||
|
||||
/**
|
||||
* Admin path to manage field storage settings.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $adminPath;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Create test user.
|
||||
$admin_user = $this->drupalCreateUser(array('access content', 'administer taxonomy', 'access administration pages', 'administer site configuration', 'administer content types', 'administer nodes', 'bypass node access', 'administer node fields', 'administer node display'));
|
||||
$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.
|
||||
$type_name = 'test_' . strtolower($this->randomMachineName());
|
||||
$this->type_name = $type_name;
|
||||
$type = $this->drupalCreateContentType(array('name' => $type_name, 'type' => $type_name));
|
||||
$this->typeName = 'test_' . strtolower($this->randomMachineName());
|
||||
$type = $this->drupalCreateContentType(['name' => $this->typeName, 'type' => $this->typeName]);
|
||||
$this->type = $type->type;
|
||||
}
|
||||
|
||||
|
@ -49,7 +69,7 @@ class OptionsFieldUITest extends FieldTestBase {
|
|||
* Options (integer) : test 'allowed values' input.
|
||||
*/
|
||||
function testOptionsAllowedValuesInteger() {
|
||||
$this->field_name = 'field_options_integer';
|
||||
$this->fieldName = 'field_options_integer';
|
||||
$this->createOptionsField('list_integer');
|
||||
|
||||
// Flat list of textual values.
|
||||
|
@ -73,7 +93,7 @@ class OptionsFieldUITest extends FieldTestBase {
|
|||
// Create a node with actual data for the field.
|
||||
$settings = array(
|
||||
'type' => $this->type,
|
||||
$this->field_name => array(array('value' => 1)),
|
||||
$this->fieldName => array(array('value' => 1)),
|
||||
);
|
||||
$node = $this->drupalCreateNode($settings);
|
||||
|
||||
|
@ -105,7 +125,7 @@ class OptionsFieldUITest extends FieldTestBase {
|
|||
* Options (float) : test 'allowed values' input.
|
||||
*/
|
||||
function testOptionsAllowedValuesFloat() {
|
||||
$this->field_name = 'field_options_float';
|
||||
$this->fieldName = 'field_options_float';
|
||||
$this->createOptionsField('list_float');
|
||||
|
||||
// Flat list of textual values.
|
||||
|
@ -128,7 +148,7 @@ class OptionsFieldUITest extends FieldTestBase {
|
|||
// Create a node with actual data for the field.
|
||||
$settings = array(
|
||||
'type' => $this->type,
|
||||
$this->field_name => array(array('value' => .5)),
|
||||
$this->fieldName => array(array('value' => .5)),
|
||||
);
|
||||
$node = $this->drupalCreateNode($settings);
|
||||
|
||||
|
@ -165,7 +185,7 @@ class OptionsFieldUITest extends FieldTestBase {
|
|||
* Options (text) : test 'allowed values' input.
|
||||
*/
|
||||
function testOptionsAllowedValuesText() {
|
||||
$this->field_name = 'field_options_text';
|
||||
$this->fieldName = 'field_options_text';
|
||||
$this->createOptionsField('list_string');
|
||||
|
||||
// Flat list of textual values.
|
||||
|
@ -190,7 +210,7 @@ class OptionsFieldUITest extends FieldTestBase {
|
|||
// Create a node with actual data for the field.
|
||||
$settings = array(
|
||||
'type' => $this->type,
|
||||
$this->field_name => array(array('value' => 'One')),
|
||||
$this->fieldName => array(array('value' => 'One')),
|
||||
);
|
||||
$node = $this->drupalCreateNode($settings);
|
||||
|
||||
|
@ -230,7 +250,7 @@ class OptionsFieldUITest extends FieldTestBase {
|
|||
* Options (text) : test 'trimmed values' input.
|
||||
*/
|
||||
function testOptionsTrimmedValuesText() {
|
||||
$this->field_name = 'field_options_trimmed_text';
|
||||
$this->fieldName = 'field_options_trimmed_text';
|
||||
$this->createOptionsField('list_string');
|
||||
|
||||
// Explicit keys.
|
||||
|
@ -248,19 +268,19 @@ class OptionsFieldUITest extends FieldTestBase {
|
|||
protected function createOptionsField($type) {
|
||||
// Create a field.
|
||||
entity_create('field_storage_config', array(
|
||||
'field_name' => $this->field_name,
|
||||
'field_name' => $this->fieldName,
|
||||
'entity_type' => 'node',
|
||||
'type' => $type,
|
||||
))->save();
|
||||
entity_create('field_config', array(
|
||||
'field_name' => $this->field_name,
|
||||
'field_name' => $this->fieldName,
|
||||
'entity_type' => 'node',
|
||||
'bundle' => $this->type,
|
||||
))->save();
|
||||
|
||||
entity_get_form_display('node', $this->type, 'default')->setComponent($this->field_name)->save();
|
||||
entity_get_form_display('node', $this->type, 'default')->setComponent($this->fieldName)->save();
|
||||
|
||||
$this->admin_path = 'admin/structure/types/manage/' . $this->type . '/fields/node.' . $this->type . '.' . $this->field_name . '/storage';
|
||||
$this->adminPath = 'admin/structure/types/manage/' . $this->type . '/fields/node.' . $this->type . '.' . $this->fieldName . '/storage';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -277,14 +297,14 @@ class OptionsFieldUITest extends FieldTestBase {
|
|||
*/
|
||||
function assertAllowedValuesInput($input_string, $result, $message) {
|
||||
$edit = array('field_storage[settings][allowed_values]' => $input_string);
|
||||
$this->drupalPostForm($this->admin_path, $edit, t('Save field settings'));
|
||||
$this->drupalPostForm($this->adminPath, $edit, t('Save field settings'));
|
||||
$this->assertNoRaw('&lt;', 'The page does not have double escaped HTML tags.');
|
||||
|
||||
if (is_string($result)) {
|
||||
$this->assertText($result, $message);
|
||||
}
|
||||
else {
|
||||
$field_storage = FieldStorageConfig::loadByName('node', $this->field_name);
|
||||
$field_storage = FieldStorageConfig::loadByName('node', $this->fieldName);
|
||||
$this->assertIdentical($field_storage->getSetting('allowed_values'), $result, $message);
|
||||
}
|
||||
}
|
||||
|
@ -293,7 +313,7 @@ class OptionsFieldUITest extends FieldTestBase {
|
|||
* Tests normal and key formatter display on node display.
|
||||
*/
|
||||
function testNodeDisplay() {
|
||||
$this->field_name = strtolower($this->randomMachineName());
|
||||
$this->fieldName = strtolower($this->randomMachineName());
|
||||
$this->createOptionsField('list_integer');
|
||||
$node = $this->drupalCreateNode(array('type' => $this->type));
|
||||
|
||||
|
@ -305,12 +325,12 @@ class OptionsFieldUITest extends FieldTestBase {
|
|||
0|$off",
|
||||
);
|
||||
|
||||
$this->drupalPostForm($this->admin_path, $edit, t('Save field settings'));
|
||||
$this->assertText(format_string('Updated field !field_name field settings.', array('!field_name' => $this->field_name)), "The 'On' and 'Off' form fields work for boolean fields.");
|
||||
$this->drupalPostForm($this->adminPath, $edit, t('Save field settings'));
|
||||
$this->assertText(format_string('Updated field !field_name field settings.', array('!field_name' => $this->fieldName)), "The 'On' and 'Off' form fields work for boolean fields.");
|
||||
|
||||
// Select a default value.
|
||||
$edit = array(
|
||||
$this->field_name => '1',
|
||||
$this->fieldName => '1',
|
||||
);
|
||||
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
|
||||
|
||||
|
@ -318,9 +338,9 @@ class OptionsFieldUITest extends FieldTestBase {
|
|||
$file_formatters = array('list_default', 'list_key');
|
||||
foreach ($file_formatters as $formatter) {
|
||||
$edit = array(
|
||||
"fields[$this->field_name][type]" => $formatter,
|
||||
"fields[$this->fieldName][type]" => $formatter,
|
||||
);
|
||||
$this->drupalPostForm('admin/structure/types/manage/' . $this->type_name . '/display', $edit, t('Save'));
|
||||
$this->drupalPostForm('admin/structure/types/manage/' . $this->typeName . '/display', $edit, t('Save'));
|
||||
$this->drupalGet('node/' . $node->id());
|
||||
|
||||
if ($formatter == 'list_default') {
|
||||
|
|
|
@ -21,41 +21,34 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('node', 'options', 'entity_test', 'options_test', 'taxonomy', 'field_ui');
|
||||
public static $modules = ['node', 'options', 'entity_test', 'options_test', 'taxonomy', 'field_ui'];
|
||||
|
||||
/**
|
||||
* A field storage with cardinality 1 to use in this test class.
|
||||
*
|
||||
* @var \Drupal\field\Entity\FieldStorageConfig
|
||||
*/
|
||||
protected $card_1;
|
||||
protected $card1;
|
||||
|
||||
/**
|
||||
* A field storage with cardinality 2 to use in this test class.
|
||||
*
|
||||
* @var \Drupal\field\Entity\FieldStorageConfig
|
||||
*/
|
||||
protected $card_2;
|
||||
|
||||
/**
|
||||
* A user with permission to view and manage entities.
|
||||
*
|
||||
* @var \Drupal\user\UserInterface
|
||||
*/
|
||||
protected $web_user;
|
||||
protected $card2;
|
||||
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Field storage with cardinality 1.
|
||||
$this->card_1 = entity_create('field_storage_config', array(
|
||||
$this->card1 = entity_create('field_storage_config', [
|
||||
'field_name' => 'card_1',
|
||||
'entity_type' => 'entity_test',
|
||||
'type' => 'list_integer',
|
||||
'cardinality' => 1,
|
||||
'settings' => array(
|
||||
'allowed_values' => array(
|
||||
'settings' => [
|
||||
'allowed_values' => [
|
||||
// Make sure that 0 works as an option.
|
||||
0 => 'Zero',
|
||||
1 => 'One',
|
||||
|
@ -63,32 +56,31 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
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();
|
||||
],
|
||||
],
|
||||
]);
|
||||
$this->card1->save();
|
||||
|
||||
// Field storage with cardinality 2.
|
||||
$this->card_2 = entity_create('field_storage_config', array(
|
||||
$this->card2 = entity_create('field_storage_config', [
|
||||
'field_name' => 'card_2',
|
||||
'entity_type' => 'entity_test',
|
||||
'type' => 'list_integer',
|
||||
'cardinality' => 2,
|
||||
'settings' => array(
|
||||
'allowed_values' => array(
|
||||
'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();
|
||||
],
|
||||
],
|
||||
]);
|
||||
$this->card2->save();
|
||||
|
||||
// Create a web user.
|
||||
$this->web_user = $this->drupalCreateUser(array('view test entity', 'administer entity_test content'));
|
||||
$this->drupalLogin($this->web_user);
|
||||
$this->drupalLogin($this->drupalCreateUser(['view test entity', 'administer entity_test content']));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,22 +88,22 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
*/
|
||||
function testRadioButtons() {
|
||||
// Create an instance of the 'single value' field.
|
||||
$field = entity_create('field_config', array(
|
||||
'field_storage' => $this->card_1,
|
||||
$field = entity_create('field_config', [
|
||||
'field_storage' => $this->card1,
|
||||
'bundle' => 'entity_test',
|
||||
));
|
||||
]);
|
||||
$field->save();
|
||||
entity_get_form_display('entity_test', 'entity_test', 'default')
|
||||
->setComponent($this->card_1->getName(), array(
|
||||
->setComponent($this->card1->getName(), [
|
||||
'type' => 'options_buttons',
|
||||
))
|
||||
])
|
||||
->save();
|
||||
|
||||
// Create an entity.
|
||||
$entity = entity_create('entity_test', array(
|
||||
$entity = entity_create('entity_test', [
|
||||
'user_id' => 1,
|
||||
'name' => $this->randomMachineName(),
|
||||
));
|
||||
]);
|
||||
$entity->save();
|
||||
$entity_init = clone $entity;
|
||||
|
||||
|
@ -140,8 +132,8 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
$this->assertFieldValues($entity_init, 'card_1', array());
|
||||
|
||||
// Check that required radios with one option is auto-selected.
|
||||
$this->card_1->settings['allowed_values'] = array(99 => 'Only allowed value');
|
||||
$this->card_1->save();
|
||||
$this->card1->settings['allowed_values'] = [99 => 'Only allowed value'];
|
||||
$this->card1->save();
|
||||
$field->required = TRUE;
|
||||
$field->save();
|
||||
$this->drupalGet('entity_test/manage/' . $entity->id());
|
||||
|
@ -154,12 +146,12 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
function testCheckBoxes() {
|
||||
// Create an instance of the 'multiple values' field.
|
||||
$field = entity_create('field_config', array(
|
||||
'field_storage' => $this->card_2,
|
||||
'field_storage' => $this->card2,
|
||||
'bundle' => 'entity_test',
|
||||
));
|
||||
$field->save();
|
||||
entity_get_form_display('entity_test', 'entity_test', 'default')
|
||||
->setComponent($this->card_2->getName(), array(
|
||||
->setComponent($this->card2->getName(), array(
|
||||
'type' => 'options_buttons',
|
||||
))
|
||||
->save();
|
||||
|
@ -229,8 +221,8 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
$this->assertFieldValues($entity_init, 'card_2', array());
|
||||
|
||||
// Required checkbox with one option is auto-selected.
|
||||
$this->card_2->settings['allowed_values'] = array(99 => 'Only allowed value');
|
||||
$this->card_2->save();
|
||||
$this->card2->settings['allowed_values'] = array(99 => 'Only allowed value');
|
||||
$this->card2->save();
|
||||
$field->required = TRUE;
|
||||
$field->save();
|
||||
$this->drupalGet('entity_test/manage/' . $entity->id());
|
||||
|
@ -243,13 +235,13 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
function testSelectListSingle() {
|
||||
// Create an instance of the 'single value' field.
|
||||
$field = entity_create('field_config', array(
|
||||
'field_storage' => $this->card_1,
|
||||
'field_storage' => $this->card1,
|
||||
'bundle' => 'entity_test',
|
||||
'required' => TRUE,
|
||||
));
|
||||
$field->save();
|
||||
entity_get_form_display('entity_test', 'entity_test', 'default')
|
||||
->setComponent($this->card_1->getName(), array(
|
||||
->setComponent($this->card1->getName(), array(
|
||||
'type' => 'options_select',
|
||||
))
|
||||
->save();
|
||||
|
@ -307,9 +299,9 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
|
||||
// Test optgroups.
|
||||
|
||||
$this->card_1->settings['allowed_values'] = array();
|
||||
$this->card_1->settings['allowed_values_function'] = 'options_test_allowed_values_callback';
|
||||
$this->card_1->save();
|
||||
$this->card1->settings['allowed_values'] = array();
|
||||
$this->card1->settings['allowed_values_function'] = 'options_test_allowed_values_callback';
|
||||
$this->card1->save();
|
||||
|
||||
// Display form: with no field data, nothing is selected
|
||||
$this->drupalGet('entity_test/manage/' . $entity->id());
|
||||
|
@ -343,12 +335,12 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
function testSelectListMultiple() {
|
||||
// Create an instance of the 'multiple values' field.
|
||||
$field = entity_create('field_config', array(
|
||||
'field_storage' => $this->card_2,
|
||||
'field_storage' => $this->card2,
|
||||
'bundle' => 'entity_test',
|
||||
));
|
||||
$field->save();
|
||||
entity_get_form_display('entity_test', 'entity_test', 'default')
|
||||
->setComponent($this->card_2->getName(), array(
|
||||
->setComponent($this->card2->getName(), array(
|
||||
'type' => 'options_select',
|
||||
))
|
||||
->save();
|
||||
|
@ -426,9 +418,9 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
// Test optgroups.
|
||||
|
||||
// Use a callback function defining optgroups.
|
||||
$this->card_2->settings['allowed_values'] = array();
|
||||
$this->card_2->settings['allowed_values_function'] = 'options_test_allowed_values_callback';
|
||||
$this->card_2->save();
|
||||
$this->card2->settings['allowed_values'] = array();
|
||||
$this->card2->settings['allowed_values_function'] = 'options_test_allowed_values_callback';
|
||||
$this->card2->save();
|
||||
$field->required = FALSE;
|
||||
$field->save();
|
||||
|
||||
|
|
Loading…
Reference in New Issue