public function LinkTokenTest::testStaticTokenLinkCreate2 in Link 7
Same name and namespace in other branches
- 6.2 tests/link.token.test \LinkTokenTest::testStaticTokenLinkCreate2()
Creates a link field with a static title and an admin-entered token.
Creates a node with a link and checks the title value.
Basically, I want to make sure the [title-raw] token works, because it's a token that changes from node to node, where [type]'s always going to be the same.
File
- tests/
LinkTokenTest.test, line 124 - Testing that tokens can be used in link titles.
Class
- LinkTokenTest
- Testing that tokens can be used in link titles.
Code
public function testStaticTokenLinkCreate2() {
// Create field.
$name = $this
->randomName();
$settings = array(
'instance[settings][title]' => 'value',
'instance[settings][title_value]' => $name . ' [node:title]',
);
$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 . ' ' . $name, $input['href']));
}