1 link.token.test LinkTokenTest::testUserTokenLinkCreate()

Creates a link field with a required title enabled for user-entered tokens. Creates a node with a token in the link title and checks the value.

File

core/modules/link/tests/link.token.test, line 17
Contains simpletests making sure token integration works.

Class

LinkTokenTest
Testing that tokens can be used in link titles

Code

function testUserTokenLinkCreate() {
  $settings = array(
    'instance[settings][enable_tokens]' => 1,
  );
  $field_name = $this->createLinkField('page', $settings);

  $this->backdropGet('node/add/page');
  $this->assertField($field_name . '[und][0][title]', 'Title found');
  $this->assertField($field_name . '[und][0][url]', 'URL found');

  $input = array(
    'href' => 'http://example.com/' . $this->randomName(),
    'label' => $this->randomName(),
  );

  $edit = array(
    'title' => $input['label'],
    $field_name . '[und][0][title]' => $input['label'] . " [node:content-type:machine-name]",
    $field_name . '[und][0][url]' => $input['href'],
  );
  $this->backdropPost('node/add/page', $edit, t('Save'));
  $this->assertRaw(l($input['label'] . ' page', $input['href']));
}