| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 | 
							- <?php
 
- /**
 
-  * @file
 
-  * Contains simpletests making sure token integration works.
 
-  */
 
- /**
 
-  * Testing that tokens can be used in link titles
 
-  */
 
- class LinkTokenTest extends LinkBaseTestClass {
 
-   public static function getInfo() {
 
-     return array(
 
-       'name' => 'Link tokens - browser test',
 
-       'description' => 'Tests including tokens in link titles, making sure they appear in node views.',
 
-       'group' => 'Link',
 
-       'dependencies' => array('token'),
 
-     );
 
-   }
 
-   function setUp($modules = array()) {
 
-     $modules[] = 'field_ui';
 
-     $modules[] = 'link';
 
-     $modules[] = 'token';
 
-     parent::setUp($modules);
 
-   }
 
-   /**
 
-    * 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.
 
-    */
 
-   function testUserTokenLinkCreate() {
 
-     /*$account = $this->drupalCreateUser(array('administer content types', 'access content', 'create page content'));
 
-     $this->drupalLogin($account);*/
 
-     // create field
 
-     $settings = array(
 
-       'instance[settings][enable_tokens]' => 1,
 
-     );
 
-     $field_name = $this->createLinkField('page',
 
-                                         $settings);
 
-     // create page form
 
-     $this->drupalGet('node/add/page');
 
-     //$field_name = 'field_' . $name;
 
-     $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(),
 
-     );
 
-     //$this->drupalLogin($account);
 
-     $this->drupalGet('node/add/page');
 
-     $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->drupalPost(NULL, $edit, t('Save'));
 
-     $url = $this->getUrl();
 
-     // change to anonymous user
 
-     $this->drupalLogout();
 
-     $this->drupalGet($url);
 
-     $this->assertRaw(l($input['label'] . ' page', $input['href']));
 
-   }
 
-   /**
 
-    * Creates a link field with a static title and an admin-entered token.
 
-    * Creates a node with a link and checks the title value.
 
-    */
 
-   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($account);
 
-     $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']));
 
-   }
 
-   /**
 
-    * 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.
 
-    */
 
-   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($account);
 
-     $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']));
 
-   }
 
-   // This test doesn't seem to actually work, due to lack of 'title' in url.
 
-   function _test_Link_With_Title_Attribute_token_url_form() {
 
-    /* $this->loginWithPermissions($this->permissions);
 
-     $this->acquireContentTypes(1);
 
-     $field_settings = array(
 
-       'type' => 'link',
 
-       'widget_type' => 'link',
 
-       'type_name' => $this->content_types[0]->name,
 
-       'attributes' => array(
 
-         'class' => '',
 
-         'target' => 'default',
 
-         'rel' => 'nofollow',
 
-         'title' => '',
 
-       ),
 
-     );
 
-     $field = $this->createField($field_settings, 0);
 
-     //$this->fail('<pre>'. print_r($field, TRUE) .'</pre>');
 
-     $field_name = $field['field_name'];
 
-     $field_db_info = content_database_info($field);
 
-     $url_type = str_replace('_', '-', $this->content_types[0]->type);
 
-     $edit = array('attributes[title]' => '['. $field_name .'-url]',
 
-                   'enable_tokens' => TRUE);
 
-     $this->drupalPost('admin/content/node-type/'. $url_type .'/fields/'. $field['field_name'],
 
-                       $edit, t('Save field settings'));
 
-     $this->assertText(t('Saved field @field_name', array('@field_name' => $field['field_name'])));*/
 
-     $name = $this->randomName();
 
-     $settings = array(
 
-       'instance[settings][attributes][rel]' => 'nofollow',
 
-     );
 
-     $field_name = $this->createLinkField('page', $settings);
 
-     // So, having saved this field_name, let's see if it works...
 
-     //$this->acquireNodes(1);
 
-     //$node = node_load($this->nodes[0]->nid);
 
-     //$this->drupalGet('node/'. $this->nodes[0]->nid);
 
-     $edit = array();
 
-     $test_link_url = 'http://www.example.com/test';
 
-     $edit[$field_name .'[und][0][url]'] = $test_link_url;
 
-     $title = 'title_'. $this->randomName(20);
 
-     $edit[$field_name .'[und][0][title]'] = $title;
 
-     $edit['title'] = $name;
 
-     $this->drupalGet('node/add/page');
 
-     $this->drupalPost(NULL, $edit, t('Save'));
 
-     // Make sure we get a new version!
 
-     //$node = node_load($this->nodes[0]->nid, NULL, TRUE);
 
-     $this->assertText(t('Basic page @title has been updated.',
 
-                         array('@title' => $name)));
 
-     //$this->drupalGet('node/'. $node->nid);
 
-     $this->assertText($title, 'Make sure the link title/text shows');
 
-     $this->assertRaw(' title="'. $test_link_url .'"', "Do we show the link url as the title attribute?");
 
-     $this->assertNoRaw(' title="['. $field_name .'-url]"');
 
-     $this->assertTrue(module_exists('token'), t('Assure that Token Module is enabled.'));
 
-     //$this->fail($this->content);
 
-   }
 
-   /**
 
-    * If the title of the link is set to the title attribute, then the title
 
-    * attribute isn't supposed to show.
 
-    */
 
-   function _test_Link_With_Title_Attribute_token_title_form() {
 
-     $this->loginWithPermissions($this->permissions);
 
-     $this->acquireContentTypes(1);
 
-     $field_settings = array(
 
-       'type' => 'link',
 
-       'widget_type' => 'link',
 
-       'type_name' => $this->content_types[0]->name,
 
-       'attributes' => array(
 
-         'class' => '',
 
-         'target' => 'default',
 
-         'rel' => 'nofollow',
 
-         'title' => '',
 
-       ),
 
-     );
 
-     $field = $this->createField($field_settings, 0);
 
-     $field_name = $field['field_name'];
 
-     $field_db_info = content_database_info($field);
 
-     $url_type = str_replace('_', '-', $this->content_types[0]->type);
 
-     $edit = array('attributes[title]' => '['. $field_name .'-title]',
 
-                   'enable_tokens' => TRUE);
 
-     $this->drupalPost('admin/content/node-type/'. $url_type .'/fields/'. $field['field_name'],
 
-                       $edit, t('Save field settings'));
 
-     $this->assertText(t('Saved field @field_name', array('@field_name' => $field['field_name'])));
 
-     // So, having saved this field_name, let's see if it works...
 
-     $this->acquireNodes(1);
 
-     $node = node_load($this->nodes[0]->nid);
 
-     $this->drupalGet('node/'. $this->nodes[0]->nid);
 
-     $edit = array();
 
-     $edit[$field['field_name'] .'[0][url]'] = 'http://www.example.com/test';
 
-     $title = 'title_'. $this->randomName(20);
 
-     $edit[$field['field_name'] .'[0][title]'] = $title;
 
-     $this->drupalPost('node/'. $this->nodes[0]->nid .'/edit', $edit, t('Save'));
 
-     // Make sure we get a new version!
 
-     $node = node_load($this->nodes[0]->nid, NULL, TRUE);
 
-     $this->assertText(t('@type @title has been updated.',
 
-                         array('@title' => $node->title,
 
-                               '@type' => $this->content_types[0]->name)));
 
-     $this->drupalGet('node/'. $node->nid);
 
-     $this->assertText($title, 'Make sure the link title/text shows');
 
-     $this->assertNoRaw(' title="'. $title .'"', "We should not show the link title as the title attribute?");
 
-     $this->assertNoRaw(' title="['. $field_name .'-title]"');
 
-     //$this->fail($this->content);
 
-   }
 
-   /**
 
-    *  Trying to set the url to contain a token.
 
-    */
 
-   function _testUserTokenLinkCreateInURL() {
 
-     $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' => 1), 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'] .'/page'));
 
-     //$this->fail($this->content);
 
-   }
 
-   /**
 
-    *  Trying to set the url to contain a token.
 
-    */
 
-   function _testUserTokenLinkCreateInURL2() {
 
-     $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' => 1), 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'] . "/[author-uid]",
 
-     );
 
-     $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'] .'/'. $account->uid));
 
-   }
 
- }
 
 
  |