From ebc927345d3e506a6ef12fc1a32f3e1e2ba7986f Mon Sep 17 00:00:00 2001 From: daitken Date: Thu, 18 Apr 2013 11:16:45 -0300 Subject: [PATCH] updates to web test case --- tests/web_test_case.inc | 110 ++++++---------------------------------- 1 file changed, 16 insertions(+), 94 deletions(-) diff --git a/tests/web_test_case.inc b/tests/web_test_case.inc index 0206d962..61d3e0a8 100755 --- a/tests/web_test_case.inc +++ b/tests/web_test_case.inc @@ -101,11 +101,10 @@ class IslandoraWebTestCase extends DrupalWebTestCase { } /** - * Creates a temporary Drupal user with administrative privileges. This is much simpler than the probably-unnecessary process of determining the correct permissions for most tests. - * - * @param $permissions - * An array of permissions which the temporary admin user will adopt; should be left blank, as this will just pull all the permissions currently assigned to the Administrator role. + * Creates a temporary Drupal user with administrative privileges. * + * @param array $permissions + * An optional set of different permissions to use (leave blank for all). */ public function createDrupalAdminUser(array $permissions = array()) { $roles = user_roles(); @@ -115,62 +114,6 @@ class IslandoraWebTestCase extends DrupalWebTestCase { return user_save($user); } - /** - * Creates a randomly generated child collection in the top-level collection through the testing interface. This should be used in lieu of throwing test objects into a standard collection, in case that collection has been deleted. - * - * @param $label - * The label that should be assigned to the collection - * @param $model - * The content model the collection should use - * @param $pid - * The PID that should be assigned to the collection (left blank by default, using a sequentially assigned number) - * @see IslandoraWebTestCase::deleteRootTestCollection() - */ - public function createRootTestCollection($label, $model, $pid = '') { - $this->drupalGet('islandora'); - $root = $this->url; - $path = $root . '/manage/collection'; - $this->clickLink(t('Manage')); - $this->clickLink(t('Collection')); - $edit = array('label' => $label, 'pid' => $pid, 'inherit_policy' => FALSE, 'content_models[' . $model . ']' => TRUE); - $this->drupalPost($path, $edit, t('Create collection'), $options = array(), $headers = array(), $form_html_id = 'islandora-basic-collection-create-child-collection-form'); - $this->assertText($label, t('Created collection %label using the content model %model', array('%label' => $label, '%model' => $model)), 'Islandora'); - } - - /** - * Deletes a child collection from the root collection by searching for a particular label. - * - * @param $label - * The label of the collection to be deleted - * @see IslandoraWebTestCase::createRootTestCollection() - */ - public function deleteRootTestCollectionByLabel($label) { - $collection = $this->openRootTestCollectionByLabel($label); - if ($collection != FALSE) { - $this->clickLink('Manage'); - $this->clickLink('Properties'); - $path = $this->url; - - $edit = array(); - $this->drupalPost($path, $edit, t('Delete Collection')); - $path = $this->url; - $this->drupalPost($path, $edit, t('Delete')); - $this->pass(t('Deleted collection %label by searching the root collection', array('%label' => $label)), t('Islandora')); - } - } - - /** - * Deletes a child collection from the root collection directly via PID - */ - public function deleteRootTestCollectionByPid($label, $pid) { - $path = 'islandora/object/' . $pid . '/manage/properties'; - $edit = array(); - $this->drupalPost($path, $edit, t('Delete Collection')); - $path = $this->url; - $this->drupalPost($path, $edit, t('Delete')); - $this->assertText('children from', t('Deleted collection %label directly via PID %pid', array('%label' => $label, '%pid' => $pid)), t('Islandora')); - } - /** * Stores the content of the Drupal Filter for later restoration. */ @@ -186,42 +129,21 @@ class IslandoraWebTestCase extends DrupalWebTestCase { } /** - * Searches through the pages inside the root collection and opens the one specified by its label. This is much slower than doing it directly by PID; use this in tests where the PID is unknown. - * @param $label - * The label of the collection + * Gets the list of object PIDs owned by a user from the test database. * + * @param string $user + * The user whose PIDs we want to grab + * + * @return array $objectpids + * Array storing PIDs found */ - public function openRootTestCollectionByLabel($label, $index = 0) { - $nexturls = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => 'next >')); - if (isset($nexturls[$index])) { - while (isset($nexturls[$index])) { - $urls = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label)); - - if (isset($urls[$index])) { - $url_target = $this->getAbsoluteUrl($urls[$index]['href']); - } - - if (isset($url_target)) { - $this->assertTrue(isset($urls[$index]), t('Found collection %label in root collection', array('%label' => $label)), t('Islandora')); - return $this->drupalGet($url_target); - } - } - return FALSE; - } - else { - $urls = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label)); - - if (isset($urls[$index])) { - $url_target = $this->getAbsoluteUrl($urls[$index]['href']); - } - - if (isset($url_target)) { - $this->assertTrue(isset($urls[$index]), t('Found collection %label in root collection', array('%label' => $label)), t('Islandora')); - return $this->drupalGet($url_target); - } - } - return FALSE; - } + public function getPidListFromUser($user) { + $connection_info = Database::getConnectionInfo('default'); + $dbname = $connection_info['default']['database']; + $query = "SELECT pid FROM $dbname.doFields WHERE ownerID = '$user'"; + $objectpids = db_query($query); + return $objectpids; + } /** * Restores the original Drupal filter, frees any allocated resources.