Ejemplo n.º 1
0
 public function handle(Client $imgurClient)
 {
     $imgurClient->setUser($this->user);
     foreach ($imgurClient->favorites()->getFavorites() as $favorite) {
         $base64Favorite = base64_encode(serialize($favorite));
         $this->dispatch((new StoreImgurImages($this->user, $base64Favorite))->onQueue("high"));
     }
 }
Ejemplo n.º 2
0
 public function handle(StorageProvider $storageClient, StoreManager $manager, ImgurClient $imgurClient)
 {
     $imgurClient->setUser($this->user);
     $storageClient->setToken($this->user->dropboxToken);
     $manager->setProvider($storageClient);
     $manager->setUser($this->user);
     $manager->setImgurClient($imgurClient);
     if ($this->favorite->getIsAlbum()) {
         $manager->storeAlbum($this->favorite);
     } else {
         $manager->storeImage($this->favorite);
     }
 }
Ejemplo n.º 3
0
 public function test_it_returns_images_collection_for_an_album_id()
 {
     $user = $this->user();
     $imgurToken = $this->imgurToken($user);
     // Mock Imgur Image Model
     $imageOne = Mockery::mock("Imgur\\Api\\Model\\Image");
     $imageOne->shouldReceive('getId')->andReturn("vP4DQ4s");
     $imageTwo = Mockery::mock("Imgur\\Api\\Model\\Image");
     $imageTwo->shouldReceive('getId')->andReturn("2Sg3KmE");
     // Mock underlying Api/Account Class
     $apiAccount = Mockery::mock("Api\\Album");
     $apiAccount->shouldReceive('albumImages')->andReturn([$imageOne, $imageTwo]);
     // Mock underlying Imgur/Client
     $service = Mockery::mock('Imgur\\Client');
     $service->shouldReceive('setOption')->times(2);
     $service->shouldReceive('setAccessToken')->once();
     $service->shouldReceive('checkAccessTokenExpired')->once()->andReturn(false);
     $service->shouldReceive('api')->andReturn($apiAccount);
     $client = new Client($service);
     $client->setUser($user);
     $images = $client->albumImages("hN1p2");
     $this->assertEquals(2, $images->getFavorites()->count());
     $this->assertNotEmpty($images);
 }