function NodeTypeTest::testNodeTypeEditing in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/node/src/Tests/NodeTypeTest.php \Drupal\node\Tests\NodeTypeTest::testNodeTypeEditing()
Tests editing a node type using the UI.
File
- core/
modules/ node/ src/ Tests/ NodeTypeTest.php, line 91 - Contains \Drupal\node\Tests\NodeTypeTest.
Class
- NodeTypeTest
- Ensures that node type functions work correctly.
Namespace
Drupal\node\TestsCode
function testNodeTypeEditing() {
$web_user = $this
->drupalCreateUser(array(
'bypass node access',
'administer content types',
'administer node fields',
));
$this
->drupalLogin($web_user);
$field = FieldConfig::loadByName('node', 'page', 'body');
$this
->assertEqual($field
->getLabel(), 'Body', 'Body field was found.');
// Verify that title and body fields are displayed.
$this
->drupalGet('node/add/page');
$this
->assertRaw('Title', 'Title field was found.');
$this
->assertRaw('Body', 'Body field was found.');
// Rename the title field.
$edit = array(
'title_label' => 'Foo',
);
$this
->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type'));
$this
->drupalGet('node/add/page');
$this
->assertRaw('Foo', 'New title label was displayed.');
$this
->assertNoRaw('Title', 'Old title label was not displayed.');
// Change the name and the description.
$edit = array(
'name' => 'Bar',
'description' => 'Lorem ipsum.',
);
$this
->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type'));
$this
->drupalGet('node/add');
$this
->assertRaw('Bar', 'New name was displayed.');
$this
->assertRaw('Lorem ipsum', 'New description was displayed.');
$this
->clickLink('Bar');
$this
->assertRaw('Foo', 'Title field was found.');
$this
->assertRaw('Body', 'Body field was found.');
// Remove the body field.
$this
->drupalPostForm('admin/structure/types/manage/page/fields/node.page.body/delete', array(), t('Delete'));
// Resave the settings for this type.
$this
->drupalPostForm('admin/structure/types/manage/page', array(), t('Save content type'));
// Check that the body field doesn't exist.
$this
->drupalGet('node/add/page');
$this
->assertNoRaw('Body', 'Body field was not found.');
}