summaryrefslogtreecommitdiff
path: root/modules/field_ui/field_ui.test
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-05-18 18:30:49 +0000
committerDries Buytaert <dries@buytaert.net>2010-05-18 18:30:49 +0000
commit5628bc2c9ba82570c63d491e1ee8ae7de6494508 (patch)
tree398d9c8c0ab80a26851ca43ab4aa23a674ea7fb8 /modules/field_ui/field_ui.test
parent09b0283675f938c89a2c541b6649deb10e7c5040 (diff)
downloadbrdo-5628bc2c9ba82570c63d491e1ee8ae7de6494508.tar.gz
brdo-5628bc2c9ba82570c63d491e1ee8ae7de6494508.tar.bz2
- Patch #680416 by Amitaibu, yched: allow defining fields that can not be added via UI.
Diffstat (limited to 'modules/field_ui/field_ui.test')
-rw-r--r--modules/field_ui/field_ui.test37
1 files changed, 36 insertions, 1 deletions
diff --git a/modules/field_ui/field_ui.test b/modules/field_ui/field_ui.test
index 171d4c4bc..a45e0bcca 100644
--- a/modules/field_ui/field_ui.test
+++ b/modules/field_ui/field_ui.test
@@ -125,7 +125,7 @@ class FieldUITestCase extends DrupalWebTestCase {
*/
function addExistingField() {
// Check "Add existing field" appears.
- $this->drupalGet(('admin/structure/types/manage/page/fields'));
+ $this->drupalGet('admin/structure/types/manage/page/fields');
$this->assertRaw(t('Add existing field'), t('"Add existing field" was found.'));
// Check that the list of options respects entity type restrictions on
@@ -264,6 +264,41 @@ class FieldUITestCase extends DrupalWebTestCase {
}
/**
+ * Test that Field UI respects the 'no_ui' option in hook_field_info().
+ */
+ function testHiddenFields() {
+ $bundle_path = 'admin/structure/types/manage/' . $this->hyphen_type . '/fields/';
+
+ // Check that the field type is not available in the 'add new field' row.
+ $this->drupalGet($bundle_path);
+ $this->assertFalse($this->xpath('//select[@id="edit--add-new-field-type"]//option[@value="hidden_test_field"]'), t("The 'add new field' select respects field types 'no_ui' property."));
+
+ // Create a field and an instance programmatically.
+ $field_name = 'hidden_test_field';
+ field_create_field(array('field_name' => $field_name, 'type' => $field_name));
+ $instance = array(
+ 'field_name' => $field_name,
+ 'bundle' => $this->type,
+ 'entity_type' => 'node',
+ 'label' => t('Hidden field'),
+ 'widget_type' => 'test_field_widget',
+ );
+ field_create_instance($instance);
+ $this->assertTrue(field_read_instance('node', $field_name, $this->type), t('An instance of the field %field was created programmatically.', array('%field' => $field_name)));
+
+ // Check that the newly added instance appears on the 'Manage Fields'
+ // screen.
+ $this->drupalGet($bundle_path);
+ $this->assertFieldByXPath('//table[@id="field-overview"]//span[@class="label-field"]', $instance['label'], t('Field was created and appears in the overview page.'));
+
+ // Check that the instance does not appear in the 'add existing field' row
+ // on other bundles.
+ $bundle_path = 'admin/structure/types/manage/article/fields/';
+ $this->drupalGet($bundle_path);
+ $this->assertFalse($this->xpath('//select[@id="edit--add-existing-field-field-name"]//option[@value=:field_name]', array(':field_name' => $field_name)), t("The 'add existing field' select respects field types 'no_ui' property."));
+ }
+
+ /**
* Create a new field through the Field UI.
*
* @param $bundle_path