You are here

public function DefaultFieldComparatorWebTestCase::testTitleNodeProperty in Changed Fields API 7.2

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

Check comparison of title node property values.

File

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

Class

DefaultFieldComparatorWebTestCase
Class DefaultFieldComparatorWebTestCase.

Code

public function testTitleNodeProperty() {
  $node = $this
    ->drupalCreateNode(array(
    'type' => 'article',
    'promote' => 1,
    'title' => 'Title',
    'body' => array(
      LANGUAGE_NONE => array(
        array(
          '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".');
  }
}