public function DefaultFieldComparatorWebTestCase::testTextWithSummaryField in Changed Fields API 7.3
Same name and namespace in other branches
- 7.2 tests/default_field_comparator.test \DefaultFieldComparatorWebTestCase::testTextWithSummaryField()
Check comparison of text_with_summary field.
File
- tests/
default_field_comparator.test, line 379 - Test default field comparator.
Class
- DefaultFieldComparatorWebTestCase
- Class DefaultFieldComparatorWebTestCase.
Code
public function testTextWithSummaryField() {
$node = $this
->drupalCreateNode([
'type' => 'article',
'promote' => 1,
'title' => 'Title',
'body' => [
LANGUAGE_NONE => [
[
'value' => 'Body',
'format' => filter_default_format(),
'summary' => 'Summary',
],
],
],
]);
$node->body[LANGUAGE_NONE][0]['value'] .= ' changed';
$node->body[LANGUAGE_NONE][0]['summary'] .= ' changed';
node_save($node);
// Let's ensure that only body field was changed.
$is_body_updated = !empty($node->changed_fields) && count($node->changed_fields) == 1 && !empty($node->changed_fields['body']);
$this
->assertEqual($is_body_updated, TRUE, 'Only body field was changed after node updating.');
if ($is_body_updated) {
$this
->assertEqual($node->changed_fields['body']['old_value'][0]['value'], 'Body', 'Old body text is "Body".');
$this
->assertEqual($node->changed_fields['body']['new_value'][0]['value'], 'Body changed', 'New body text is "Body changed".');
$this
->assertEqual($node->changed_fields['body']['old_value'][0]['summary'], 'Summary', 'Old body summary text is "Summary".');
$this
->assertEqual($node->changed_fields['body']['new_value'][0]['summary'], 'Summary changed', 'New body summary text is "Summary changed".');
}
}