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

Creates a link field with a static title and an admin-entered token. Creates a node with a link and checks the title value.

File

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

Class

LinkTokenTest
Testing that tokens can be used in link titles

Code

function testStaticTokenLinkCreate() {
  $name = $this->randomName();
  $settings = array(
    'instance[settings][title]' => 'value',
    'instance[settings][title_value]' => $name . ' [node:title]');
  $field_name = $this->createLinkField('page', $settings);

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

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

  $this->backdropGet('node/add/page');

  $edit = array(
    'title' => $name,
    $field_name . '[und][0][url]' => $input['href'],
  );
  $this->backdropPost(NULL, $edit, t('Save'));
  $this->assertRaw(l($name . ' ' . $name, $input['href']));
}