public function ConflictTestCase::testNeedUpdateCase in Conflict 7
Test case for outdated values.
Emulates that title and body fields are outdated.
File
- ./
conflict.test, line 318 - Tests for conflict.module.
Class
Code
public function testNeedUpdateCase() {
$orig_title = $this
->randomName();
$orig_body = $this
->randomString();
$their_title = $this
->randomName();
$their_body = $this
->randomString();
// Create the node to work with.
$node = $this
->drupalCreateNode(array(
'title' => $orig_title,
'body' => array(
LANGUAGE_NONE => array(
array(
'value' => $orig_body,
'summary' => '',
),
),
),
));
// Load the edit page up.
$this
->drupalGet("node/{$node->nid}/edit");
// Before submitting the form, make changes to the node from somewhere else.
$conflict = clone $node;
$conflict->title = $their_title;
$conflict->body['und'][0]['value'] = $their_body;
node_save($conflict);
// Fudge the timestamps in the database.
db_query('UPDATE {node} SET changed = changed + 100 WHERE nid = :nid', array(
':nid' => $conflict->nid,
));
db_query('UPDATE {node_revision} SET timestamp = timestamp + 100 WHERE nid = :nid', array(
':nid' => $conflict->nid,
));
// Attempt to make changes.
$edit['title'] = $orig_title;
$edit['body[und][0][value]'] = $orig_body;
$this
->drupalPost(NULL, $edit, t('Save'));
$this
->assertText(t('The Title field was changed by another user. Please verify the updated value.'));
$this
->assertText(t('The Body field was changed by another user. Please verify the updated value.'));
$this
->assertFieldByXPath('//*[@id="edit-title" and contains(@class, "error")]', $their_title, 'Title field was highlighted with error and contains conflicted data.');
$this
->assertFieldByXPath('//*[@id="edit-body-und-0-value" and contains(@class, "error")]', $their_body, 'Body field was highlighted with error and contains conflicted data.');
}