Browse Source

Existing test doesn't take user permissions into account -setting them to fix the test.

Reynold Tan 5 years ago
parent
commit
d4a887e1e8
1 changed files with 11 additions and 3 deletions
  1. 11 3
      tests/tripal_ws/http/TripalWebServicesContentTest.php

+ 11 - 3
tests/tripal_ws/http/TripalWebServicesContentTest.php

@@ -38,10 +38,18 @@ class TripalWebServicesContentTest extends TripalTestCase {
    */
   public function testGettingListOfEntitiesInABundle() {
     // Get bundle label
-    $label = db_query('SELECT label FROM tripal_bundle LIMIT 1')->fetchField();
+    $label = db_query('SELECT label, name FROM tripal_bundle LIMIT 1')->fetchObject();
+
+    // Grant user permission to view bundle.
+    $bundle_name = 'view ' . $label->name;
+    if (!user_access($bundle_name)) {
+      // Either the user is anonymous or registered.
+      $role_id = (user_is_anonymous()) ? DRUPAL_ANONYMOUS_RID : DRUPAL_AUTHENTICATED_RID;
+      user_role_grant_permissions($role_id, array($bundle_name));
+    }
 
     // Call /web-services/content/v0.1/[label]
-    $response = $this->get("web-services/content/v0.1/$label");
+    $response = $this->get("web-services/content/v0.1/$label->label");
 
     // Verify the returned JSON matches the structure
     $response->assertSuccessful();
@@ -56,6 +64,6 @@ class TripalWebServicesContentTest extends TripalTestCase {
 
     // Verify the collection is of the correct type
     $json = $response->json();
-    $this->assertEquals($json['label'], "$label Collection");
+    $this->assertEquals($json['label'], "$label->label Collection");
   }
 }