示例#1
0
 /**
  * Checks if a given image exists on the server already by specifying a local path
  *
  * @param string $path Path to the local image
  * @throws InvalidArgumentException Throws an exception if the specified file does not exist or
  *                                  is of zero length
  * @return boolean
  */
 public function imageExists($path)
 {
     $this->validateLocalFile($path);
     $checksum = md5_file($path);
     $query = new ImagesQuery();
     $query->originalChecksums(array($checksum))->limit(1);
     $response = $this->getImages($query);
     return (bool) $response['search']['hits'];
 }
 public function testCanSetAndGetOriginalChecksums()
 {
     $this->assertSame(array(), $this->query->originalChecksums());
     $this->assertSame($this->query, $this->query->originalChecksums(array('checksum1', 'checksum2')));
     $this->assertSame(array('checksum1', 'checksum2'), $this->query->originalChecksums());
 }
 public function testCanGetImagesUsingAQueryObject()
 {
     $this->setMockResponse($this->client, 'images_get');
     $query = new ImagesQuery();
     $query->page(2)->limit(5)->metadata(true)->from(123)->to(456)->fields(array('width'))->sort(array('size'))->ids(array('id1', 'id2'))->checksums(array('checksum1', 'checksum2'))->originalChecksums(array('checksum3', 'checksum4'));
     $response = $this->client->getImages($query);
     $requests = $this->getMockedRequests();
     $request = $requests[0];
     $this->assertSame('http://imbo/users/testuser/images.json?page=2&limit=5&metadata=1&from=123&to=456&fields[0]=width&sort[0]=size&ids[0]=id1&ids[1]=id2&checksums[0]=checksum1&checksums[1]=checksum2&originalChecksums[0]=checksum3&originalChecksums[1]=checksum4&accessToken=01b1aa98aefccd5a50e2325316401fb26976f4fe525b4f33de66f515f8ccd169', urldecode($request->getUrl()));
 }