function FieldCrudTestCase::testUpdateFieldForbid

Test field type modules forbidding an update.

File

modules/field/tests/field.test, line 2792

Class

FieldCrudTestCase

Code

function testUpdateFieldForbid() {
    $field = array(
        'field_name' => 'forbidden',
        'type' => 'test_field',
        'settings' => array(
            'changeable' => 0,
            'unchangeable' => 0,
        ),
    );
    $field = field_create_field($field);
    $field['settings']['changeable']++;
    try {
        field_update_field($field);
        $this->pass(t("A changeable setting can be updated."));
    } catch (FieldException $e) {
        $this->fail(t("An unchangeable setting cannot be updated."));
    }
    $field['settings']['unchangeable']++;
    try {
        field_update_field($field);
        $this->fail(t("An unchangeable setting can be updated."));
    } catch (FieldException $e) {
        $this->pass(t("An unchangeable setting cannot be updated."));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.