You are here

public function DefaultFieldComparatorWebTestCase::testTitleNodeProperty in Changed Fields API 7.3

Same name and namespace in other branches
  1. 7.2 tests/default_field_comparator.test \DefaultFieldComparatorWebTestCase::testTitleNodeProperty()

Check comparison of title node property values.

File

tests/default_field_comparator.test, line 346
Test default field comparator.

Class

DefaultFieldComparatorWebTestCase
Class DefaultFieldComparatorWebTestCase.

Code

public function testTitleNodeProperty() {
  $node = $this
    ->drupalCreateNode([
    'type' => 'article',
    'promote' => 1,
    'title' => 'Title',
    'body' => [
      LANGUAGE_NONE => [
        [
          'value' => 'Body',
          'format' => filter_default_format(),
          'summary' => '',
        ],
      ],
    ],
  ]);
  $node->title .= ' changed';
  node_save($node);

  // Let's ensure that only title property was changed.
  $is_title_updated = !empty($node->changed_fields) && count($node->changed_fields) == 1 && !empty($node->changed_fields['title']);
  $this
    ->assertEqual($is_title_updated, TRUE, 'Only title property was changed after node updating.');
  if ($is_title_updated) {
    $this
      ->assertEqual($node->changed_fields['title']['old_value'], 'Title', 'Old title text is "Title".');
    $this
      ->assertEqual($node->changed_fields['title']['new_value'], 'Title changed', 'New title text is "Title changed".');
  }
}