1 node.test NodeTypeTestCase::testNodeTypeEditing()

Tests editing a node type using the UI.

File

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

Class

NodeTypeTestCase
Tests related to node types.

Code

function testNodeTypeEditing() {
  $web_user = $this->backdropCreateUser(array('bypass node access', 'administer content types', 'administer fields'));
  $this->backdropLogin($web_user);

  $instance = field_info_instance('node', 'body', 'page');
  $this->assertEqual($instance['label'], 'Body', 'Body field was found.');

  // Verify that title and body fields are displayed.
  $this->backdropGet('node/add/page');
  $this->assertRaw('<label for="edit-title">Title', 'Title field was found.');
  $this->assertRaw('<label for="edit-body-und-0-value">Body', 'Body field was found.');

  // Rename the title field.
  $edit = array(
    'title_label' => 'Foo',
  );
  $this->backdropPost('admin/structure/types/manage/page', $edit, t('Save content type'));
  // Refresh the field information for the rest of the test.
  field_info_cache_clear();

  $this->backdropGet('node/add/page');
  $this->assertRaw('<label for="edit-title">Foo', 'New title label was displayed.');
  $this->assertNoRaw('<label for="edit-title">Title', 'Old title label was not displayed.');

  // Change the name, machine name and description.
  $edit = array(
    'name' => 'Bar',
    'type' => 'bar',
    'description' => 'Lorem ipsum.',
  );
  $this->backdropPost('admin/structure/types/manage/page', $edit, t('Save content type'));
  field_info_cache_clear();

  $this->backdropGet('node/add');
  $this->assertRaw('Bar', 'New name was displayed.');
  $this->assertRaw('Lorem ipsum', 'New description was displayed.');
  $this->clickLink('Bar');
  $this->assertEqual(url('node/add/bar', array('absolute' => TRUE)), $this->getUrl(), 'New machine name was used in URL.');
  $this->assertRaw('<label for="edit-title">Foo', 'Title field was found.');
  $this->assertRaw('<label for="edit-body-und-0-value">Body', 'Body field was found.');

  // Remove the body field.
  $this->backdropPost('admin/structure/types/manage/bar/fields/body/delete', NULL, t('Delete'));
  // Resave the settings for this type.
  $this->backdropPost('admin/structure/types/manage/bar', array(), t('Save content type'));
  // Check that the body field doesn't exist.
  $this->backdropGet('node/add/bar');
  $this->assertNoRaw('Body', 'Body field was not found.');
}