options.test

Tests for options.module.

File

drupal-7.x/modules/field/modules/options/options.test
View source
  1. <?php
  2. /**
  3. * @file
  4. * Tests for options.module.
  5. */
  6. class OptionsWidgetsTestCase extends FieldTestCase {
  7. public static function getInfo() {
  8. return array(
  9. 'name' => 'Options widgets',
  10. 'description' => "Test the Options widgets.",
  11. 'group' => 'Field types'
  12. );
  13. }
  14. function setUp() {
  15. parent::setUp('field_test', 'list_test');
  16. // Field with cardinality 1.
  17. $this->card_1 = array(
  18. 'field_name' => 'card_1',
  19. 'type' => 'list_integer',
  20. 'cardinality' => 1,
  21. 'settings' => array(
  22. // Make sure that 0 works as an option.
  23. 'allowed_values' => array(0 => 'Zero', 1 => 'One', 2 => 'Some <script>dangerous</script> & unescaped <strong>markup</strong>'),
  24. ),
  25. );
  26. $this->card_1 = field_create_field($this->card_1);
  27. // Field with cardinality 2.
  28. $this->card_2 = array(
  29. 'field_name' => 'card_2',
  30. 'type' => 'list_integer',
  31. 'cardinality' => 2,
  32. 'settings' => array(
  33. // Make sure that 0 works as an option.
  34. 'allowed_values' => array(0 => 'Zero', 1 => 'One', 2 => 'Some <script>dangerous</script> & unescaped <strong>markup</strong>'),
  35. ),
  36. );
  37. $this->card_2 = field_create_field($this->card_2);
  38. // Boolean field.
  39. $this->bool = array(
  40. 'field_name' => 'bool',
  41. 'type' => 'list_boolean',
  42. 'cardinality' => 1,
  43. 'settings' => array(
  44. // Make sure that 0 works as a 'on' value'.
  45. 'allowed_values' => array(1 => 'Zero', 0 => 'Some <script>dangerous</script> & unescaped <strong>markup</strong>'),
  46. ),
  47. );
  48. $this->bool = field_create_field($this->bool);
  49. // Create a web user.
  50. $this->web_user = $this->drupalCreateUser(array('access field_test content', 'administer field_test content'));
  51. $this->drupalLogin($this->web_user);
  52. }
  53. /**
  54. * Tests the 'options_buttons' widget (single select).
  55. */
  56. function testRadioButtons() {
  57. // Create an instance of the 'single value' field.
  58. $instance = array(
  59. 'field_name' => $this->card_1['field_name'],
  60. 'entity_type' => 'test_entity',
  61. 'bundle' => 'test_bundle',
  62. 'widget' => array(
  63. 'type' => 'options_buttons',
  64. ),
  65. );
  66. $instance = field_create_instance($instance);
  67. $langcode = LANGUAGE_NONE;
  68. // Create an entity.
  69. $entity_init = field_test_create_stub_entity();
  70. $entity = clone $entity_init;
  71. $entity->is_new = TRUE;
  72. field_test_entity_save($entity);
  73. // With no field data, no buttons are checked.
  74. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
  75. $this->assertNoFieldChecked("edit-card-1-$langcode-0");
  76. $this->assertNoFieldChecked("edit-card-1-$langcode-1");
  77. $this->assertNoFieldChecked("edit-card-1-$langcode-2");
  78. $this->assertRaw('Some dangerous &amp; unescaped <strong>markup</strong>', 'Option text was properly filtered.');
  79. // Select first option.
  80. $edit = array("card_1[$langcode]" => 0);
  81. $this->drupalPost(NULL, $edit, t('Save'));
  82. $this->assertFieldValues($entity_init, 'card_1', $langcode, array(0));
  83. // Check that the selected button is checked.
  84. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
  85. $this->assertFieldChecked("edit-card-1-$langcode-0");
  86. $this->assertNoFieldChecked("edit-card-1-$langcode-1");
  87. $this->assertNoFieldChecked("edit-card-1-$langcode-2");
  88. // Unselect option.
  89. $edit = array("card_1[$langcode]" => '_none');
  90. $this->drupalPost(NULL, $edit, t('Save'));
  91. $this->assertFieldValues($entity_init, 'card_1', $langcode, array());
  92. // Check that required radios with one option is auto-selected.
  93. $this->card_1['settings']['allowed_values'] = array(99 => 'Only allowed value');
  94. field_update_field($this->card_1);
  95. $instance['required'] = TRUE;
  96. field_update_instance($instance);
  97. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
  98. $this->assertFieldChecked("edit-card-1-$langcode-99");
  99. }
  100. /**
  101. * Tests the 'options_buttons' widget (multiple select).
  102. */
  103. function testCheckBoxes() {
  104. // Create an instance of the 'multiple values' field.
  105. $instance = array(
  106. 'field_name' => $this->card_2['field_name'],
  107. 'entity_type' => 'test_entity',
  108. 'bundle' => 'test_bundle',
  109. 'widget' => array(
  110. 'type' => 'options_buttons',
  111. ),
  112. );
  113. $instance = field_create_instance($instance);
  114. $langcode = LANGUAGE_NONE;
  115. // Create an entity.
  116. $entity_init = field_test_create_stub_entity();
  117. $entity = clone $entity_init;
  118. $entity->is_new = TRUE;
  119. field_test_entity_save($entity);
  120. // Display form: with no field data, nothing is checked.
  121. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
  122. $this->assertNoFieldChecked("edit-card-2-$langcode-0");
  123. $this->assertNoFieldChecked("edit-card-2-$langcode-1");
  124. $this->assertNoFieldChecked("edit-card-2-$langcode-2");
  125. $this->assertRaw('Some dangerous &amp; unescaped <strong>markup</strong>', 'Option text was properly filtered.');
  126. // Submit form: select first and third options.
  127. $edit = array(
  128. "card_2[$langcode][0]" => TRUE,
  129. "card_2[$langcode][1]" => FALSE,
  130. "card_2[$langcode][2]" => TRUE,
  131. );
  132. $this->drupalPost(NULL, $edit, t('Save'));
  133. $this->assertFieldValues($entity_init, 'card_2', $langcode, array(0, 2));
  134. // Display form: check that the right options are selected.
  135. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
  136. $this->assertFieldChecked("edit-card-2-$langcode-0");
  137. $this->assertNoFieldChecked("edit-card-2-$langcode-1");
  138. $this->assertFieldChecked("edit-card-2-$langcode-2");
  139. // Submit form: select only first option.
  140. $edit = array(
  141. "card_2[$langcode][0]" => TRUE,
  142. "card_2[$langcode][1]" => FALSE,
  143. "card_2[$langcode][2]" => FALSE,
  144. );
  145. $this->drupalPost(NULL, $edit, t('Save'));
  146. $this->assertFieldValues($entity_init, 'card_2', $langcode, array(0));
  147. // Display form: check that the right options are selected.
  148. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
  149. $this->assertFieldChecked("edit-card-2-$langcode-0");
  150. $this->assertNoFieldChecked("edit-card-2-$langcode-1");
  151. $this->assertNoFieldChecked("edit-card-2-$langcode-2");
  152. // Submit form: select the three options while the field accepts only 2.
  153. $edit = array(
  154. "card_2[$langcode][0]" => TRUE,
  155. "card_2[$langcode][1]" => TRUE,
  156. "card_2[$langcode][2]" => TRUE,
  157. );
  158. $this->drupalPost(NULL, $edit, t('Save'));
  159. $this->assertText('this field cannot hold more than 2 values', 'Validation error was displayed.');
  160. // Submit form: uncheck all options.
  161. $edit = array(
  162. "card_2[$langcode][0]" => FALSE,
  163. "card_2[$langcode][1]" => FALSE,
  164. "card_2[$langcode][2]" => FALSE,
  165. );
  166. $this->drupalPost(NULL, $edit, t('Save'));
  167. // Check that the value was saved.
  168. $this->assertFieldValues($entity_init, 'card_2', $langcode, array());
  169. // Required checkbox with one option is auto-selected.
  170. $this->card_2['settings']['allowed_values'] = array(99 => 'Only allowed value');
  171. field_update_field($this->card_2);
  172. $instance['required'] = TRUE;
  173. field_update_instance($instance);
  174. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
  175. $this->assertFieldChecked("edit-card-2-$langcode-99");
  176. }
  177. /**
  178. * Tests the 'options_select' widget (single select).
  179. */
  180. function testSelectListSingle() {
  181. // Create an instance of the 'single value' field.
  182. $instance = array(
  183. 'field_name' => $this->card_1['field_name'],
  184. 'entity_type' => 'test_entity',
  185. 'bundle' => 'test_bundle',
  186. 'required' => TRUE,
  187. 'widget' => array(
  188. 'type' => 'options_select',
  189. ),
  190. );
  191. $instance = field_create_instance($instance);
  192. $langcode = LANGUAGE_NONE;
  193. // Create an entity.
  194. $entity_init = field_test_create_stub_entity();
  195. $entity = clone $entity_init;
  196. $entity->is_new = TRUE;
  197. field_test_entity_save($entity);
  198. // Display form.
  199. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
  200. // A required field without any value has a "none" option.
  201. $this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', array(':id' => 'edit-card-1-' . $langcode, ':label' => t('- Select a value -'))), 'A required select list has a "Select a value" choice.');
  202. // With no field data, nothing is selected.
  203. $this->assertNoOptionSelected("edit-card-1-$langcode", '_none');
  204. $this->assertNoOptionSelected("edit-card-1-$langcode", 0);
  205. $this->assertNoOptionSelected("edit-card-1-$langcode", 1);
  206. $this->assertNoOptionSelected("edit-card-1-$langcode", 2);
  207. $this->assertRaw('Some dangerous &amp; unescaped markup', 'Option text was properly filtered.');
  208. // Submit form: select invalid 'none' option.
  209. $edit = array("card_1[$langcode]" => '_none');
  210. $this->drupalPost(NULL, $edit, t('Save'));
  211. $this->assertRaw(t('!title field is required.', array('!title' => $instance['field_name'])), 'Cannot save a required field when selecting "none" from the select list.');
  212. // Submit form: select first option.
  213. $edit = array("card_1[$langcode]" => 0);
  214. $this->drupalPost(NULL, $edit, t('Save'));
  215. $this->assertFieldValues($entity_init, 'card_1', $langcode, array(0));
  216. // Display form: check that the right options are selected.
  217. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
  218. // A required field with a value has no 'none' option.
  219. $this->assertFalse($this->xpath('//select[@id=:id]//option[@value="_none"]', array(':id' => 'edit-card-1-' . $langcode)), 'A required select list with an actual value has no "none" choice.');
  220. $this->assertOptionSelected("edit-card-1-$langcode", 0);
  221. $this->assertNoOptionSelected("edit-card-1-$langcode", 1);
  222. $this->assertNoOptionSelected("edit-card-1-$langcode", 2);
  223. // Make the field non required.
  224. $instance['required'] = FALSE;
  225. field_update_instance($instance);
  226. // Display form.
  227. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
  228. // A non-required field has a 'none' option.
  229. $this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', array(':id' => 'edit-card-1-' . $langcode, ':label' => t('- None -'))), 'A non-required select list has a "None" choice.');
  230. // Submit form: Unselect the option.
  231. $edit = array("card_1[$langcode]" => '_none');
  232. $this->drupalPost('test-entity/manage/' . $entity->ftid . '/edit', $edit, t('Save'));
  233. $this->assertFieldValues($entity_init, 'card_1', $langcode, array());
  234. // Test optgroups.
  235. $this->card_1['settings']['allowed_values'] = array();
  236. $this->card_1['settings']['allowed_values_function'] = 'list_test_allowed_values_callback';
  237. field_update_field($this->card_1);
  238. // Display form: with no field data, nothing is selected
  239. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
  240. $this->assertNoOptionSelected("edit-card-1-$langcode", 0);
  241. $this->assertNoOptionSelected("edit-card-1-$langcode", 1);
  242. $this->assertNoOptionSelected("edit-card-1-$langcode", 2);
  243. $this->assertRaw('Some dangerous &amp; unescaped markup', 'Option text was properly filtered.');
  244. $this->assertRaw('Group 1', 'Option groups are displayed.');
  245. // Submit form: select first option.
  246. $edit = array("card_1[$langcode]" => 0);
  247. $this->drupalPost(NULL, $edit, t('Save'));
  248. $this->assertFieldValues($entity_init, 'card_1', $langcode, array(0));
  249. // Display form: check that the right options are selected.
  250. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
  251. $this->assertOptionSelected("edit-card-1-$langcode", 0);
  252. $this->assertNoOptionSelected("edit-card-1-$langcode", 1);
  253. $this->assertNoOptionSelected("edit-card-1-$langcode", 2);
  254. // Submit form: Unselect the option.
  255. $edit = array("card_1[$langcode]" => '_none');
  256. $this->drupalPost('test-entity/manage/' . $entity->ftid . '/edit', $edit, t('Save'));
  257. $this->assertFieldValues($entity_init, 'card_1', $langcode, array());
  258. }
  259. /**
  260. * Tests the 'options_select' widget (multiple select).
  261. */
  262. function testSelectListMultiple() {
  263. // Create an instance of the 'multiple values' field.
  264. $instance = array(
  265. 'field_name' => $this->card_2['field_name'],
  266. 'entity_type' => 'test_entity',
  267. 'bundle' => 'test_bundle',
  268. 'widget' => array(
  269. 'type' => 'options_select',
  270. ),
  271. );
  272. $instance = field_create_instance($instance);
  273. $langcode = LANGUAGE_NONE;
  274. // Create an entity.
  275. $entity_init = field_test_create_stub_entity();
  276. $entity = clone $entity_init;
  277. $entity->is_new = TRUE;
  278. field_test_entity_save($entity);
  279. // Display form: with no field data, nothing is selected.
  280. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
  281. $this->assertNoOptionSelected("edit-card-2-$langcode", 0);
  282. $this->assertNoOptionSelected("edit-card-2-$langcode", 1);
  283. $this->assertNoOptionSelected("edit-card-2-$langcode", 2);
  284. $this->assertRaw('Some dangerous &amp; unescaped markup', 'Option text was properly filtered.');
  285. // Submit form: select first and third options.
  286. $edit = array("card_2[$langcode][]" => array(0 => 0, 2 => 2));
  287. $this->drupalPost(NULL, $edit, t('Save'));
  288. $this->assertFieldValues($entity_init, 'card_2', $langcode, array(0, 2));
  289. // Display form: check that the right options are selected.
  290. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
  291. $this->assertOptionSelected("edit-card-2-$langcode", 0);
  292. $this->assertNoOptionSelected("edit-card-2-$langcode", 1);
  293. $this->assertOptionSelected("edit-card-2-$langcode", 2);
  294. // Submit form: select only first option.
  295. $edit = array("card_2[$langcode][]" => array(0 => 0));
  296. $this->drupalPost(NULL, $edit, t('Save'));
  297. $this->assertFieldValues($entity_init, 'card_2', $langcode, array(0));
  298. // Display form: check that the right options are selected.
  299. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
  300. $this->assertOptionSelected("edit-card-2-$langcode", 0);
  301. $this->assertNoOptionSelected("edit-card-2-$langcode", 1);
  302. $this->assertNoOptionSelected("edit-card-2-$langcode", 2);
  303. // Submit form: select the three options while the field accepts only 2.
  304. $edit = array("card_2[$langcode][]" => array(0 => 0, 1 => 1, 2 => 2));
  305. $this->drupalPost(NULL, $edit, t('Save'));
  306. $this->assertText('this field cannot hold more than 2 values', 'Validation error was displayed.');
  307. // Submit form: uncheck all options.
  308. $edit = array("card_2[$langcode][]" => array());
  309. $this->drupalPost(NULL, $edit, t('Save'));
  310. $this->assertFieldValues($entity_init, 'card_2', $langcode, array());
  311. // Test the 'None' option.
  312. // Check that the 'none' option has no effect if actual options are selected
  313. // as well.
  314. $edit = array("card_2[$langcode][]" => array('_none' => '_none', 0 => 0));
  315. $this->drupalPost('test-entity/manage/' . $entity->ftid . '/edit', $edit, t('Save'));
  316. $this->assertFieldValues($entity_init, 'card_2', $langcode, array(0));
  317. // Check that selecting the 'none' option empties the field.
  318. $edit = array("card_2[$langcode][]" => array('_none' => '_none'));
  319. $this->drupalPost('test-entity/manage/' . $entity->ftid . '/edit', $edit, t('Save'));
  320. $this->assertFieldValues($entity_init, 'card_2', $langcode, array());
  321. // A required select list does not have an empty key.
  322. $instance['required'] = TRUE;
  323. field_update_instance($instance);
  324. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
  325. $this->assertFalse($this->xpath('//select[@id=:id]//option[@value=""]', array(':id' => 'edit-card-2-' . $langcode)), 'A required select list does not have an empty key.');
  326. // We do not have to test that a required select list with one option is
  327. // auto-selected because the browser does it for us.
  328. // Test optgroups.
  329. // Use a callback function defining optgroups.
  330. $this->card_2['settings']['allowed_values'] = array();
  331. $this->card_2['settings']['allowed_values_function'] = 'list_test_allowed_values_callback';
  332. field_update_field($this->card_2);
  333. $instance['required'] = FALSE;
  334. field_update_instance($instance);
  335. // Display form: with no field data, nothing is selected.
  336. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
  337. $this->assertNoOptionSelected("edit-card-2-$langcode", 0);
  338. $this->assertNoOptionSelected("edit-card-2-$langcode", 1);
  339. $this->assertNoOptionSelected("edit-card-2-$langcode", 2);
  340. $this->assertRaw('Some dangerous &amp; unescaped markup', 'Option text was properly filtered.');
  341. $this->assertRaw('Group 1', 'Option groups are displayed.');
  342. // Submit form: select first option.
  343. $edit = array("card_2[$langcode][]" => array(0 => 0));
  344. $this->drupalPost(NULL, $edit, t('Save'));
  345. $this->assertFieldValues($entity_init, 'card_2', $langcode, array(0));
  346. // Display form: check that the right options are selected.
  347. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
  348. $this->assertOptionSelected("edit-card-2-$langcode", 0);
  349. $this->assertNoOptionSelected("edit-card-2-$langcode", 1);
  350. $this->assertNoOptionSelected("edit-card-2-$langcode", 2);
  351. // Submit form: Unselect the option.
  352. $edit = array("card_2[$langcode][]" => array('_none' => '_none'));
  353. $this->drupalPost('test-entity/manage/' . $entity->ftid . '/edit', $edit, t('Save'));
  354. $this->assertFieldValues($entity_init, 'card_2', $langcode, array());
  355. }
  356. /**
  357. * Tests the 'options_onoff' widget.
  358. */
  359. function testOnOffCheckbox() {
  360. // Create an instance of the 'boolean' field.
  361. $instance = array(
  362. 'field_name' => $this->bool['field_name'],
  363. 'entity_type' => 'test_entity',
  364. 'bundle' => 'test_bundle',
  365. 'widget' => array(
  366. 'type' => 'options_onoff',
  367. ),
  368. );
  369. $instance = field_create_instance($instance);
  370. $langcode = LANGUAGE_NONE;
  371. // Create an entity.
  372. $entity_init = field_test_create_stub_entity();
  373. $entity = clone $entity_init;
  374. $entity->is_new = TRUE;
  375. field_test_entity_save($entity);
  376. // Display form: with no field data, option is unchecked.
  377. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
  378. $this->assertNoFieldChecked("edit-bool-$langcode");
  379. $this->assertRaw('Some dangerous &amp; unescaped <strong>markup</strong>', 'Option text was properly filtered.');
  380. // Submit form: check the option.
  381. $edit = array("bool[$langcode]" => TRUE);
  382. $this->drupalPost(NULL, $edit, t('Save'));
  383. $this->assertFieldValues($entity_init, 'bool', $langcode, array(0));
  384. // Display form: check that the right options are selected.
  385. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
  386. $this->assertFieldChecked("edit-bool-$langcode");
  387. // Submit form: uncheck the option.
  388. $edit = array("bool[$langcode]" => FALSE);
  389. $this->drupalPost(NULL, $edit, t('Save'));
  390. $this->assertFieldValues($entity_init, 'bool', $langcode, array(1));
  391. // Display form: with 'off' value, option is unchecked.
  392. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
  393. $this->assertNoFieldChecked("edit-bool-$langcode");
  394. // Create admin user.
  395. $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer taxonomy'));
  396. $this->drupalLogin($admin_user);
  397. // Create a test field instance.
  398. $fieldUpdate = $this->bool;
  399. $fieldUpdate['settings']['allowed_values'] = array(0 => 0, 1 => 'MyOnValue');
  400. field_update_field($fieldUpdate);
  401. $instance = array(
  402. 'field_name' => $this->bool['field_name'],
  403. 'entity_type' => 'node',
  404. 'bundle' => 'page',
  405. 'widget' => array(
  406. 'type' => 'options_onoff',
  407. 'module' => 'options',
  408. ),
  409. );
  410. field_create_instance($instance);
  411. // Go to the edit page and check if the default settings works as expected
  412. $fieldEditUrl = 'admin/structure/types/manage/page/fields/bool';
  413. $this->drupalGet($fieldEditUrl);
  414. $this->assertText(
  415. 'Use field label instead of the "On value" as label ',
  416. 'Display setting checkbox available.'
  417. );
  418. $this->assertFieldByXPath(
  419. '*//label[@for="edit-' . $this->bool['field_name'] . '-und" and text()="MyOnValue "]',
  420. TRUE,
  421. 'Default case shows "On value"'
  422. );
  423. // Enable setting
  424. $edit = array('instance[widget][settings][display_label]' => 1);
  425. // Save the new Settings
  426. $this->drupalPost($fieldEditUrl, $edit, t('Save settings'));
  427. // Go again to the edit page and check if the setting
  428. // is stored and has the expected effect
  429. $this->drupalGet($fieldEditUrl);
  430. $this->assertText(
  431. 'Use field label instead of the "On value" as label ',
  432. 'Display setting checkbox is available'
  433. );
  434. $this->assertFieldChecked(
  435. 'edit-instance-widget-settings-display-label',
  436. 'Display settings checkbox checked'
  437. );
  438. $this->assertFieldByXPath(
  439. '*//label[@for="edit-' . $this->bool['field_name'] . '-und" and text()="' . $this->bool['field_name'] . ' "]',
  440. TRUE,
  441. 'Display label changes label of the checkbox'
  442. );
  443. }
  444. }
  445. /**
  446. * Test an options select on a list field with a dynamic allowed values function.
  447. */
  448. class OptionsSelectDynamicValuesTestCase extends ListDynamicValuesTestCase {
  449. public static function getInfo() {
  450. return array(
  451. 'name' => 'Options select dynamic values',
  452. 'description' => 'Test an options select on a list field with a dynamic allowed values function.',
  453. 'group' => 'Field types',
  454. );
  455. }
  456. /**
  457. * Tests the 'options_select' widget (single select).
  458. */
  459. function testSelectListDynamic() {
  460. // Create an entity.
  461. $this->entity->is_new = TRUE;
  462. field_test_entity_save($this->entity);
  463. // Create a web user.
  464. $web_user = $this->drupalCreateUser(array('access field_test content', 'administer field_test content'));
  465. $this->drupalLogin($web_user);
  466. // Display form.
  467. $this->drupalGet('test-entity/manage/' . $this->entity->ftid . '/edit');
  468. $options = $this->xpath('//select[@id="edit-test-list-und"]/option');
  469. $this->assertEqual(count($options), count($this->test) + 1);
  470. foreach ($options as $option) {
  471. $value = (string) $option['value'];
  472. if ($value != '_none') {
  473. $this->assertTrue(array_search($value, $this->test));
  474. }
  475. }
  476. }
  477. }