1 node.test | public NodeLayoutRevisionTestCase::testNodeLayoutRevisions() |
Tests that the correct layout is used for node revisions.
File
- core/
modules/ node/ tests/ node.test, line 1039 - Tests for node.module.
Class
- NodeLayoutRevisionTestCase
- Tests that the correct layout is used for node revisions.
Code
public function testNodeLayoutRevisions() {
$nodes = $this->nodes;
// The node revision should use the 'custom_node' layout with path node/%.
// Confirm that our layout shows up on both the original node and its
// revision.
foreach ($nodes as $node) {
$body = $node->body[LANGUAGE_NONE][0]['value'];
$this->backdropGet("node/$node->nid/revisions/$node->vid/view");
$this->assertText($body, 'Correct body text displays for version.');
// Look for the taylor template (only exists in our layout).
$this->assertText('taylor', 'Layout template "taylor" found.');
// Look for the heading of the field body block that exists only in our
// layout.
$this->assertText('Node body field', '"Node body field" found.');
// Look for the body text, which appears only in that field if the context
// was set properly.
$this->assertText($body, "\"{$body}\" found.");
}
// Enable the node revision override layout 'custom_node_revision' with
// path node/%/revisions/%/view.
$layouts = layout_load_all();
$revision_layout = $layouts['custom_node_revision'];
$revision_layout->enable();
$revision_layout->save();
// Check the old revision to see that it uses our override layout.
$node = $nodes[0];
$body = $node->body[LANGUAGE_NONE][0]['value'];
$this->backdropGet("node/$node->nid/revisions/$node->vid/view");
$this->assertText($body, 'Correct body text displays for version.');
// Look for the sutro template (only exists in our layout).
$this->assertText('sutro', 'Layout template "sutro" found.');
// Look for the heading of the custom block that exists only in our
// layout.
$this->assertText('Custom Node Revision layout title', '"Custom Node Revision layout title" found.');
// Look for the body text, which appears only in that field if the context
// was set properly.
$this->assertText($body, "\"{$body}\" found.");
}