示例#1
0
 public function test_it_can_be_instantiated_with_a_file_path()
 {
     $path = 'file-path-test';
     $image = Image::file($path);
     $this->assertTrue($image->isFile());
     $this->assertSame($path, $image->getData());
     $this->assertFalse($image->isBase64());
     $this->assertFalse($image->isUrl());
 }
示例#2
0
 /**
  * Create a pin on a board.
  *
  * @param string      $boardId The board id.
  * @param string      $note    The note.
  * @param Image       $image   The image.
  * @param string|null $link    The link (Optional).
  *
  * @return Response
  */
 public function createPin($boardId, $note, Image $image, $link = null)
 {
     if (empty($boardId)) {
         throw new InvalidArgumentException('The board id should not be empty.');
     }
     if (empty($note)) {
         throw new InvalidArgumentException('The note should not be empty.');
     }
     $params = array('board' => (int) $boardId, 'note' => (string) $note);
     if (!empty($link)) {
         $params['link'] = (string) $link;
     }
     $imageKey = $image->isUrl() ? 'image_url' : ($image->isBase64() ? 'image_base64' : 'image');
     if ($image->isFile()) {
         $params[$imageKey] = $image;
     } else {
         $params[$imageKey] = $image->getData();
     }
     $request = new Request('POST', 'pins/', $params);
     return $this->fetchPin($request);
 }
示例#3
0
 public function imageProvider()
 {
     $imageFixture = __DIR__ . '/fixtures/cat.jpg';
     return array(array(Image::url('http://lorempixel.com/g/400/200/cats/'), 'Test pin url'), array(Image::file($imageFixture), 'Test pin file'), array(Image::base64(base64_encode(file_get_contents($imageFixture))), 'Test pin base64'));
 }