1 field.test FieldTokenTestCase::testFieldToken()

Test fields in token display mode.

File

core/modules/field/tests/field.test, line 3889
Tests for field.module.

Class

FieldTokenTestCase
Test fields with token display mode.

Code

function testFieldToken() {
  $edit = array();
  $edit['title'] = $this->randomName(8);
  $edit[$this->test_field_name . '[und][0][value]'] = 'foo';
  $edit[$this->test_date_field_name . '[und][0][value][date]'] = '10/07/2010 - 10:30am';

  // Create a dummy node.
  $this->backdropPost('node/add/post', $edit, t('Save'));
  $this->node = $this->backdropGetNodeByTitle($edit['title']);

  $this->backdropGet('node/' . $this->node->nid);

  $uri = entity_uri('node', $this->node);
  backdrop_clear_path_cache($uri['path']);
  $alias = backdrop_get_path_alias($uri['path'], LANGUAGE_NONE);
  $expected_alias = 'posts/2010/' . $edit[$this->test_field_name . '[und][0][value]'] . '/' . backdrop_strtolower($this->node->title);
  $this->assertIdentical($alias, $expected_alias, format_string("Alias for %source was %actual, expected %expected.", array('%source' => $uri['path'], '%actual' => $alias, '%expected' => $expected_alias)));
}