Example #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"));
     }
 }
Example #2
0
 public function test_it_returns_only_unproccessed_favorites()
 {
     $user = $this->user();
     $imgurToken = $this->imgurToken($user);
     $this->imgurLog($user, "CBPafr2");
     // Mock Imgur Image Model
     $imageOne = Mockery::mock("Imgur\\Api\\Model\\Image");
     $imageOne->shouldReceive('getId')->andReturn("CBPafr2");
     $imageTwo = Mockery::mock("Imgur\\Api\\Model\\Image");
     $imageTwo->shouldReceive('getId')->andReturn("hN1p2");
     // Mock underlying Api/Account Class
     $apiAccount = Mockery::mock("Api\\Account");
     $apiAccount->shouldReceive('favorites')->andReturn([$imageOne, $imageTwo], null);
     // 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);
     $favorites = $client->favorites();
     $this->assertEquals(1, $favorites->getFavorites()->count());
     $this->assertInstanceOf(Favorites::class, $favorites);
     $this->assertNotEmpty($favorites);
 }