You are here

public function LinkTokenTest::testStaticTokenLinkCreate in Link 7

Same name and namespace in other branches
  1. 6.2 tests/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

tests/LinkTokenTest.test, line 80
Testing that tokens can be used in link titles.

Class

LinkTokenTest
Testing that tokens can be used in link titles.

Code

public function testStaticTokenLinkCreate() {

  // Create field.
  $name = $this
    ->randomName();
  $settings = array(
    'instance[settings][title]' => 'value',
    'instance[settings][title_value]' => $name . ' [node:content-type:machine-name]',
  );
  $field_name = $this
    ->createLinkField('page', $settings);

  // Create page form.
  $this
    ->drupalGet('node/add/page');
  $this
    ->assertField($field_name . '[und][0][url]', 'URL found');
  $input = array(
    'href' => 'http://example.com/' . $this
      ->randomName(),
  );

  // $this->drupalLogin($this->web_user);.
  $this
    ->drupalGet('node/add/page');
  $edit = array(
    'title' => $name,
    $field_name . '[und][0][url]' => $input['href'],
  );
  $this
    ->drupalPost(NULL, $edit, t('Save'));
  $url = $this
    ->getUrl();

  // Change to anonymous user.
  $this
    ->drupalLogout();
  $this
    ->drupalGet($url);
  $this
    ->assertRaw(l($name . ' page', $input['href']));
}