1 node.test NodeAccessFieldTestCase::testNodeAccessAdministerField()

Tests administering fields when node access is restricted.


core/modules/node/tests/node.test, line 3624
Tests for node.module.




function testNodeAccessAdministerField() {
  // Create a page node.
  $langcode = LANGUAGE_NONE;
  $field_data = array();
  $value = $field_data[$langcode][0]['value'] = $this->randomName();
  $node = $this->backdropCreateNode(array($this->field_name => $field_data));

  // Log in as the administrator and confirm that the field value is present.
  $this->assertText($value, 'The saved field value is visible to an administrator.');

  // Log in as the content admin and try to view the node.
  $this->assertText('Access denied', 'Access is denied for the content admin.');

  // Modify the field default as the content admin.
  $edit = array();
  $default = 'Sometimes words have two meanings';
  $edit["{$this->field_name}[$langcode][0][value]"] = $default;
  t('Save settings')

  // Log in as the administrator.

  // Confirm that the existing node still has the correct field value.
  $this->assertText($value, 'The original field value is visible to an administrator.');

  // Confirm that the new default value appears when creating a new node.
  $this->assertRaw($default, 'The updated default value is displayed when creating a new node.');