t('Check Access to Help pages'), 'desc' => 'Check to see if user with/without admin rights can access the tracker help page', 'group' => 'Tracker'); } function tearDown() { parent::tearDown(); } function testracker_check_access_help_page () {; $web_user = $this->drupalCreateUserRolePerm(array ( 0 => 'administer menu', 1 => 'access content', 2 => 'access administration pages', )); $web_user1 = $this->drupalCreateUserRolePerm(array ( 0 => 'access content', )); //Logs in the user with admin rights. $this->drupalLoginUser($web_user); $this->drupalModuleEnable('tracker'); //Goes to the admin help page. $this->drupalGet('admin/help'); //Looks for the help text. $this->assertText('Help'); //Clicks the Tracker link on the help page. $this->clickLink('Tracker', '0'); $this->assertText('Tracker'); //Logs out the user with admin rights. $url = url('logout', array('absolute' => TRUE)); $this->get($url); //Logs in a user with no admin rights. $this->drupalLoginUser($web_user1); $this->drupalModuleEnable('tracker'); //Checks to see if the links Administer or Help are available. $this->assertNoLink('Administer'); $this->assertNoLink('Help'); //Goes to the admin/help page and checks to see that no help text is there. $this->drupalGet('admin/help'); $this->assertNoText('Help'); } } /* * Checks to see that the tracker module creates the tracker page and creates the Track link on the user page. */ class tracker_page extends DrupalTestCase { /** * Implementation of get_info() for information */ function get_info() { return array('name' => t('Ensures tracker page is created.'), 'desc' => 'Checks to see if Tracker page exisits.', 'group' => 'Tracker'); } function tearDown() { parent::tearDown(); } function testracker_page () {; $web_user = $this->drupalCreateUserRolePerm(array ( 0 => 'access content', 1 => 'access user profiles', )); $this->drupalLoginUser($web_user); $this->drupalModuleEnable('tracker'); $this->drupalGet('tracker'); //Checks to see that the links All recent posts and my recent posts are present on the tracker page. $this->assertLink('All recent posts'); $this->assertLink('My recent posts'); //Goes to the user id 1 page and checks to see if the track link is available. $this->drupalGet('user/1'); $this->assertLink('Track'); $this->clickLink('Track', '0'); } } /* * Creates a page node and checks to see if * the node is available on the user page of * the logged in user. Also checks to see if it * is available on the tracker page. */ class tracker_create_page extends DrupalTestCase { /** * Implementation of get_info() for information */ function get_info() { return array('name' => t('Checks for posting on user/uid and tracker page'), 'desc' => 'Creates a node type page and ensures it shows on the user/uid and tracker pages.', 'group' => 'Tracker'); } function tearDown() { parent::tearDown(); } function testracker_create_node () {; $web_user = $this->drupalCreateUserRolePerm(array ( 0 => 'access content', 1 => 'create page content', 2 => 'access user profiles', )); $this->drupalLoginUser($web_user); $this->drupalModuleEnable('tracker'); $edit = array(); $edit['title'] = '!SimpleTest test node! ' . $this->randomName(10); $edit['body'] = '!SimpleTest test body! ' . $this->randomName(32) . ' ' . $this->randomName(32); //Creates teh new page node. $this->drupalPost('node/add/page', $edit, 'Save'); $this->assertWantedRaw(t('!post %title has been created.', array ('!post' => 'Page', '%title' => $edit['title'])), 'Page created'); //Goes to the user page specific tracker page. $this->drupalGet('user/'. $web_user->uid .'/track'); //Checks to see if the new node that was created is on the user page. $this->assertLink($edit['title']); //Goes to the node page. $this->clickLink($edit['title'], '0'); //Gets the current url. $url = $this->getUrl(); //Breaks the current url into an array to get the nid. $url_array = explode("/", $url); //Does a node load by the title of the node that was created. $node = node_load(array('title' => $edit['title'])); //Checks to see if the node load nid and the url nid are the same. $this->assertEqual($url_array[5],$node->nid); $this->drupalGet('tracker'); //Checks to see if the node is present on the tracker page. $this->assertLink($edit['title']); $this->clickLink('My recent posts'); //Checks to see if the node is present on the my recent tracker page. $this->assertLink($edit['title']); } } /* * Creates two nodes, one that is published and one that * is unpublished. It checks to see that the published node * is veiwable on the tracker page and the unpublished node is * not viewable. */ class tracker_check_unpublished_nodes extends DrupalTestCase { /** * Implementation of get_info() for information */ function get_info() { return array('name' => t('Checks unpublished nodes'), 'desc' => 'Ensures that unpublished nodes are not displaying on the tracker page or user/uid/track', 'group' => 'Tracker'); } function tearDown() { parent::tearDown(); } function testracker_unpublished_nodes () {; $web_user = $this->drupalCreateUserRolePerm(array ( 0 => 'access content', 1 => 'create page content', 2 => 'access user profiles', )); $options = array( 'promote', ); $published_options = array( 'status', ); //Sets the node type page to unpublished. $this->drupalVariableSet('node_options_page', $options); $this->drupalLoginUser($web_user); $this->drupalModuleEnable('tracker'); $edit = array(); $title1 = '!SimpleTest test node! ' . $this->randomName(10); $title2 = '!SimpleTest test node! ' . $this->randomName(10); $edit['title'] = $title1; $edit['body'] = '!SimpleTest test body! ' . $this->randomName(32) . ' ' . $this->randomName(32); //Creates the new unpublished page node. $this->drupalPost('node/add/page', $edit, 'Save'); $this->assertWantedRaw(t('!post %title has been created.', array ('!post' => 'Page', '%title' => $edit['title'])), 'Page created'); $node1 = $node = node_load(array('title' => $title1)); //Sets the page node to published. $this->drupalVariableSet('node_options_page', $published_options); $edit['title'] = $title2; $edit['body'] = '!SimpleTest test body! ' . $this->randomName(32) . ' ' . $this->randomName(32); //Publishes the new page node. $this->drupalPost('node/add/page', $edit, 'Save'); $node2 = $node = node_load(array('title' => $title2)); $this->assertWantedRaw(t('!post %title has been created.', array ('!post' => 'Page', '%title' => $edit['title'])), 'Page created'); //Logs out the current user. $url = url('logout', array('absolute' => TRUE)); $this->get($url); $this->drupalGet('tracker'); //Checks to see if the unpublished node is on the tracker page. $this->assertNoLink($title); //Checks to see if the published node is on the tracker page. $this->assertLink($title2); } }