function LinkTokenTest::testUserTokenLinkCreateInURLFail in Link 6.2
If 'enable_tokens' is off, then the url shouldn't be filtered through the token module.
File
- tests/
link.token.test, line 377 - Contains simpletests making sure token integration works.
Class
- LinkTokenTest
- Testing that tokens can be used in link titles
Code
function testUserTokenLinkCreateInURLFail() {
$account = $this
->drupalCreateUser(array(
'administer content types',
'access content',
'create page content',
));
$this
->drupalLogin($account);
// create field
$name = strtolower($this
->randomName());
$edit = array(
'_add_new_field[label]' => $name,
'_add_new_field[field_name]' => $name,
'_add_new_field[type]' => 'link',
'_add_new_field[widget_type]' => 'link',
);
$this
->drupalPost('admin/content/node-type/page/fields', $edit, t('Save'));
$this
->drupalPost(NULL, array(
'title' => 'required',
'enable_tokens' => FALSE,
), t('Save field settings'));
// Is field created?
$this
->assertRaw(t('Added field %label.', array(
'%label' => $name,
)), 'Field added');
// create page form
$this
->drupalGet('node/add/page');
$field_name = 'field_' . $name;
$this
->assertField($field_name . '[0][title]', 'Title found');
$this
->assertField($field_name . '[0][url]', 'URL found');
$input = array(
'href' => 'http://example.com/' . $this
->randomName(),
'label' => $this
->randomName(),
);
$this
->drupalLogin($account);
$this
->drupalGet('node/add/page');
$edit = array(
'title' => $input['label'],
$field_name . '[0][title]' => $input['label'],
$field_name . '[0][url]' => $input['href'] . "/[type]",
);
$this
->drupalPost(NULL, $edit, t('Save'));
$url = $this
->getUrl();
// change to anonymous user
$this
->drupalLogout();
$this
->drupalGet($url);
$this
->assertRaw(l($input['label'], $input['href'] . '/[type]'));
//$this->fail($this->content);
}