Beispiel #1
0
 public function testTotalResults()
 {
     $response = API::userHead(self::$config['userID'], "items?format=atom");
     $this->assert200($response);
     $this->assertTotalResults(sizeOf(self::$items), $response);
     $response = API::userGet(self::$config['userID'], "items?format=atom");
     $this->assert200($response);
     $xml = API::getXMLFromResponse($response);
     $this->assertTotalResults(sizeOf(self::$items), $response);
     // Make sure there's no totalResults tag
     $this->assertCount(0, $xml->xpath('/atom:feed/zapi:totalResults'));
 }
Beispiel #2
0
 private function _testMultiObjectGet($objectType)
 {
     $objectTypePlural = API::getPluralObjectType($objectType);
     $keyProp = $objectType . "Key";
     $keys = [];
     switch ($objectType) {
         case 'collection':
             $keys[] = API::createCollection("Name", false, $this, 'key');
             $keys[] = API::createCollection("Name", false, $this, 'key');
             API::createCollection("Name", false, $this, 'key');
             break;
         case 'item':
             $keys[] = API::createItem("book", array("title" => "Title"), $this, 'key');
             $keys[] = API::createItem("book", array("title" => "Title"), $this, 'key');
             API::createItem("book", array("title" => "Title"), $this, 'key');
             break;
         case 'search':
             $keys[] = API::createSearch("Name", 'default', $this, 'key');
             $keys[] = API::createSearch("Name", 'default', $this, 'key');
             API::createSearch("Name", 'default', $this, 'key');
             break;
     }
     // HEAD request should include Total-Results
     $response = API::userHead(self::$config['userID'], "{$objectTypePlural}?{$keyProp}=" . implode(',', $keys));
     $this->assert200($response);
     $this->assertTotalResults(sizeOf($keys), $response);
     $response = API::userGet(self::$config['userID'], "{$objectTypePlural}?{$keyProp}=" . implode(',', $keys));
     $this->assert200($response);
     $this->assertNumResults(sizeOf($keys), $response);
     // Trailing comma in itemKey parameter
     $response = API::userGet(self::$config['userID'], "{$objectTypePlural}?{$keyProp}=" . implode(',', $keys) . ",");
     $this->assert200($response);
     $this->assertNumResults(sizeOf($keys), $response);
 }