diff --git a/.travis.yml b/.travis.yml index 63caca0..a4cabaf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ before_script: - composer install --prefer-dist --no-interaction -o script: - - ./vendor/bin/simple-phpunit -v --coverage-clover=coverage.clover + - XDEBUG_MODE=coverage ./vendor/bin/simple-phpunit -v --coverage-clover=coverage.clover - if [ "$CS_FIXER" = "run" ]; then php vendor/bin/php-cs-fixer fix --verbose --dry-run ; fi; after_script: diff --git a/lib/Imgur/Api/Album.php b/lib/Imgur/Api/Album.php index a30ceed..f96d8ff 100644 --- a/lib/Imgur/Api/Album.php +++ b/lib/Imgur/Api/Album.php @@ -122,7 +122,6 @@ public function favoriteAlbum($albumId) * (Not available for anonymous albums.). * * @param string $albumId - * @param array $imageIds * * @see https://api.imgur.com/endpoints/album#album-set-to * @@ -138,7 +137,6 @@ public function setAlbumImages($albumId, array $imageIds) * (Not available for anonymous albums. Adding images to an anonymous album is only available during image uploading.). * * @param string $albumId - * @param array $imageIds * * @see https://api.imgur.com/endpoints/album#album-add-to * @@ -154,7 +152,6 @@ public function addImages($albumId, array $imageIds) * For anonymous albums, $deletehashOrAlbumId should be the deletehash that is returned at creation. * * @param string $deletehashOrAlbumId - * @param array $imageIds * * @see https://api.imgur.com/endpoints/album#album-remove-from * diff --git a/lib/Imgur/Api/CustomGallery.php b/lib/Imgur/Api/CustomGallery.php index f20a92d..77a6967 100644 --- a/lib/Imgur/Api/CustomGallery.php +++ b/lib/Imgur/Api/CustomGallery.php @@ -64,8 +64,6 @@ public function image($imageId) /** * Add tags to a user's custom gallery. * - * @param array $tags - * * @see https://api.imgur.com/endpoints/custom_gallery#custom-gallery-add * * @return bool @@ -78,8 +76,6 @@ public function addTags(array $tags) /** * Remove tags from a custom gallery. * - * @param array $tags - * * @see https://api.imgur.com/endpoints/custom_gallery#custom-gallery-remove * * @return bool diff --git a/lib/Imgur/Api/Image.php b/lib/Imgur/Api/Image.php index fdbbe35..50e8ae2 100644 --- a/lib/Imgur/Api/Image.php +++ b/lib/Imgur/Api/Image.php @@ -49,7 +49,7 @@ public function upload($data) } if ('file' === $data['type']) { - $data['image'] = '@' . $data['image']; + $data['image'] = fopen($data['image'], 'r'); } return $this->post('image', $data); diff --git a/lib/Imgur/Auth/OAuth2.php b/lib/Imgur/Auth/OAuth2.php index 54302c3..55a1d6b 100644 --- a/lib/Imgur/Auth/OAuth2.php +++ b/lib/Imgur/Auth/OAuth2.php @@ -62,9 +62,8 @@ class OAuth2 implements AuthInterface /** * Instantiates the OAuth2 class, but does not trigger the authentication process. * - * @param HttpClientInterface $httpClient - * @param string $clientId - * @param string $clientSecret + * @param string $clientId + * @param string $clientSecret */ public function __construct(HttpClientInterface $httpClient, $clientId, $clientSecret) { diff --git a/lib/Imgur/Client.php b/lib/Imgur/Client.php index b762f7f..02acb04 100644 --- a/lib/Imgur/Client.php +++ b/lib/Imgur/Client.php @@ -81,9 +81,6 @@ public function getHttpClient() return $this->httpClient; } - /** - * @param HttpClientInterface $httpClient - */ public function setHttpClient(HttpClientInterface $httpClient) { $this->httpClient = $httpClient; diff --git a/lib/Imgur/HttpClient/HttpClient.php b/lib/Imgur/HttpClient/HttpClient.php index 12eddc3..585ac83 100644 --- a/lib/Imgur/HttpClient/HttpClient.php +++ b/lib/Imgur/HttpClient/HttpClient.php @@ -36,7 +36,6 @@ class HttpClient implements HttpClientInterface protected $stack; /** - * @param array $options * @param ClientInterface $client */ public function __construct(array $options = [], ClientInterface $client = null) @@ -108,7 +107,20 @@ public function performRequest($url, $parameters, $httpMethod = 'GET') } if ('POST' === $httpMethod || 'PUT' === $httpMethod || 'DELETE' === $httpMethod) { - $options['form_params'] = $parameters; + if ('POST' === $httpMethod && isset($parameters['type']) && 'file' === $parameters['type']) { + $options['multipart'] = [ + [ + 'name' => 'type', + 'contents' => $parameters['type'], + ], + [ + 'name' => 'image', + 'contents' => $parameters['image'], + ], + ]; + } else { + $options['form_params'] = $parameters; + } } // will throw an Imgur\Exception\ExceptionInterface if sth goes wrong diff --git a/lib/Imgur/Middleware/AuthMiddleware.php b/lib/Imgur/Middleware/AuthMiddleware.php index 5b25476..0ee9326 100644 --- a/lib/Imgur/Middleware/AuthMiddleware.php +++ b/lib/Imgur/Middleware/AuthMiddleware.php @@ -23,8 +23,6 @@ public function __construct($token, $clientId) /** * Add Authorization header to the request. - * - * @param RequestInterface $request */ public function addAuthHeader(RequestInterface $request) { diff --git a/lib/Imgur/Middleware/ErrorMiddleware.php b/lib/Imgur/Middleware/ErrorMiddleware.php index b812dfb..d2506fa 100644 --- a/lib/Imgur/Middleware/ErrorMiddleware.php +++ b/lib/Imgur/Middleware/ErrorMiddleware.php @@ -21,9 +21,6 @@ public function __construct(callable $nextHandler) } /** - * @param RequestInterface $request - * @param array $options - * * @return PromiseInterface */ public function __invoke(RequestInterface $request, array $options) @@ -50,8 +47,6 @@ public static function error() /** * Check for an error. - * - * @param ResponseInterface $response */ public function checkError(ResponseInterface $response) { @@ -96,8 +91,6 @@ public function checkError(ResponseInterface $response) /** * Check if user hit limit. - * - * @param ResponseInterface $response */ private function checkUserRateLimit(ResponseInterface $response) { @@ -111,8 +104,6 @@ private function checkUserRateLimit(ResponseInterface $response) /** * Check if client hit limit. - * - * @param ResponseInterface $response */ private function checkClientRateLimit(ResponseInterface $response) { @@ -129,8 +120,6 @@ private function checkClientRateLimit(ResponseInterface $response) /** * Check if client hit post limit. - * - * @param ResponseInterface $response */ private function checkPostRateLimit(ResponseInterface $response) { diff --git a/tests/Api/AccountTest.php b/tests/Api/AccountTest.php index a2d22c5..af32fde 100644 --- a/tests/Api/AccountTest.php +++ b/tests/Api/AccountTest.php @@ -73,7 +73,7 @@ public function testBase() $api->expects($this->once()) ->method('get') ->with('account/me') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->base()); } @@ -90,7 +90,7 @@ public function testDeleteAccount() $api->expects($this->once()) ->method('delete') ->with('account/imgur') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->deleteAccount('imgur')); } @@ -111,7 +111,7 @@ public function testGalleryFavorites() $api->expects($this->once()) ->method('get') ->with('account/me/gallery_favorites/0/newest') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->galleryFavorites()); } @@ -141,7 +141,7 @@ public function testFavorites() $api->expects($this->once()) ->method('get') ->with('account/me/favorites') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->favorites()); } @@ -162,7 +162,7 @@ public function testSubmissions() $api->expects($this->once()) ->method('get') ->with('account/me/submissions/0') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->submissions()); } @@ -183,7 +183,7 @@ public function testSettings() $api->expects($this->once()) ->method('get') ->with('account/me/settings') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->settings()); } @@ -200,7 +200,7 @@ public function testChangeAccountSettings() $api->expects($this->once()) ->method('post') ->with('account/me/settings') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->changeAccountSettings([ 'show_mature' => true, @@ -223,7 +223,7 @@ public function testAccountStats() $api->expects($this->once()) ->method('get') ->with('account/me/stats') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->accountStats()); } @@ -244,7 +244,7 @@ public function testAccountGalleryProfile() $api->expects($this->once()) ->method('get') ->with('account/me/gallery_profile') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->accountGalleryProfile()); } @@ -265,7 +265,7 @@ public function testVerifyUsersEmail() $api->expects($this->once()) ->method('get') ->with('account/me/verifyemail') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->verifyUsersEmail()); } @@ -282,7 +282,7 @@ public function testSendVerificationEmail() $api->expects($this->once()) ->method('post') ->with('account/me/verifyemail') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->sendVerificationEmail()); } @@ -303,7 +303,7 @@ public function testAlbums() $api->expects($this->once()) ->method('get') ->with('account/me/albums/0') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->albums()); } @@ -324,7 +324,7 @@ public function testAlbum() $api->expects($this->once()) ->method('get') ->with('account/me/album/Arn5NUt') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->album('Arn5NUt')); } @@ -345,7 +345,7 @@ public function testAlbumIds() $api->expects($this->once()) ->method('get') ->with('account/me/albums/ids/0') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->albumIds()); } @@ -366,7 +366,7 @@ public function testAlbumCount() $api->expects($this->once()) ->method('get') ->with('account/me/albums/count') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->albumCount()); } @@ -383,7 +383,7 @@ public function testAlbumDelete() $api->expects($this->once()) ->method('delete') ->with('account/me/album/Arn5NUt') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->albumDelete('Arn5NUt')); } @@ -404,7 +404,7 @@ public function testComments() $api->expects($this->once()) ->method('get') ->with('account/me/comments/newest/0') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->comments()); } @@ -434,7 +434,7 @@ public function testComment() $api->expects($this->once()) ->method('get') ->with('account/me/comment/726305564') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->comment('726305564')); } @@ -455,7 +455,7 @@ public function testCommentIds() $api->expects($this->once()) ->method('get') ->with('account/me/comments/ids/newest/0') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->commentIds()); } @@ -485,7 +485,7 @@ public function testCommentCount() $api->expects($this->once()) ->method('get') ->with('account/me/comments/count') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->commentCount()); } @@ -502,7 +502,7 @@ public function testCommentDelete() $api->expects($this->once()) ->method('delete') ->with('account/me/comment/726305564') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->commentDelete('726305564')); } @@ -523,7 +523,7 @@ public function testImages() $api->expects($this->once()) ->method('get') ->with('account/me/images/0') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->images()); } @@ -544,7 +544,7 @@ public function testImage() $api->expects($this->once()) ->method('get') ->with('account/me/image/iCMrM1P') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->image('iCMrM1P')); } @@ -565,7 +565,7 @@ public function testImageIds() $api->expects($this->once()) ->method('get') ->with('account/me/images/ids/0') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->imageIds()); } @@ -586,7 +586,7 @@ public function testImageCount() $api->expects($this->once()) ->method('get') ->with('account/me/images/count') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->imageCount()); } @@ -603,7 +603,7 @@ public function testImageDelete() $api->expects($this->once()) ->method('delete') ->with('account/me/image/iCMrM1P') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->imageDelete('iCMrM1P')); } @@ -624,7 +624,7 @@ public function testReplies() $api->expects($this->once()) ->method('get') ->with('account/me/notifications/replies', ['new' => 'false']) - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->replies()); } diff --git a/tests/Api/AlbumTest.php b/tests/Api/AlbumTest.php index b97e28f..151698e 100644 --- a/tests/Api/AlbumTest.php +++ b/tests/Api/AlbumTest.php @@ -128,7 +128,7 @@ public function testAlbum() $api->expects($this->once()) ->method('get') ->with('album/VOMXz') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->album('VOMXz')); } @@ -147,7 +147,7 @@ public function testAlbumImages() $api->expects($this->once()) ->method('get') ->with('album/VOMXz/images') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->albumImages('VOMXz')); } @@ -166,7 +166,7 @@ public function testAlbumImage() $api->expects($this->once()) ->method('get') ->with('album/VOMXz/image/POvvB') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->albumImage('VOMXz', 'POvvB')); } @@ -183,7 +183,7 @@ public function testCreate() $api->expects($this->once()) ->method('post') ->with('album') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->create('VOMXz')); } @@ -200,7 +200,7 @@ public function testUpdate() $api->expects($this->once()) ->method('post') ->with('album/VOMXz') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->update('VOMXz', [ 'title' => 'New title', @@ -221,7 +221,7 @@ public function testDeleteAlbum() $api->expects($this->once()) ->method('delete') ->with('album/VOMXz') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->deleteAlbum('VOMXz')); } @@ -238,7 +238,7 @@ public function testFavoriteAlbum() $api->expects($this->once()) ->method('post') ->with('album/VOMXz/favorite') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->favoriteAlbum('VOMXz')); } @@ -255,7 +255,7 @@ public function testSetAlbumImages() $api->expects($this->once()) ->method('post') ->with('album/VOMXz') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->setAlbumImages('VOMXz', ['POvvB', 'P1vvB'])); } @@ -272,7 +272,7 @@ public function testAddImages() $api->expects($this->once()) ->method('post') ->with('album/VOMXz/add') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->addImages('VOMXz', ['POvvB', 'P1vvB'])); } @@ -289,7 +289,7 @@ public function testRemoveImages() $api->expects($this->once()) ->method('delete') ->with('album/VOMXz/remove_images') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->removeImages('VOMXz', ['POvvB', 'P1vvB'])); } diff --git a/tests/Api/CommentTest.php b/tests/Api/CommentTest.php index 6ac8a2f..b1c0978 100644 --- a/tests/Api/CommentTest.php +++ b/tests/Api/CommentTest.php @@ -93,7 +93,7 @@ public function testComment() $api->expects($this->once()) ->method('get') ->with('comment/726305564') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->comment('726305564')); } @@ -110,7 +110,7 @@ public function testCreate() $api->expects($this->once()) ->method('post') ->with('comment') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->create(['image_id' => 'ZOY11VC', 'comment' => 'I agree'])); } @@ -136,7 +136,7 @@ public function testDeleteComment() $api->expects($this->once()) ->method('delete') ->with('comment/726305564') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->deleteComment('726305564')); } @@ -155,7 +155,7 @@ public function testReplies() $api->expects($this->once()) ->method('get') ->with('comment/726305564/replied') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->replies('726305564')); } @@ -172,7 +172,7 @@ public function testCreateReply() $api->expects($this->once()) ->method('post') ->with('comment/726305565') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->createReply('726305565', ['image_id' => 'ZOY11VC', 'comment' => 'I agree'])); } @@ -198,7 +198,7 @@ public function testVote() $api->expects($this->once()) ->method('post') ->with('comment/726305564/vote/up') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->vote('726305564', 'up')); } @@ -224,7 +224,7 @@ public function testReport() $api->expects($this->once()) ->method('post') ->with('comment/726305564/report') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->report('726305564')); } diff --git a/tests/Api/ConversationTest.php b/tests/Api/ConversationTest.php index a09ecdb..2a26eab 100644 --- a/tests/Api/ConversationTest.php +++ b/tests/Api/ConversationTest.php @@ -77,7 +77,7 @@ public function testConversations() $api->expects($this->once()) ->method('get') ->with('conversations') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->conversations()); } @@ -96,7 +96,7 @@ public function testConversation() $api->expects($this->once()) ->method('get') ->with('conversations/11247233') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->conversation('11247233')); } @@ -113,7 +113,7 @@ public function testMessageCreate() $api->expects($this->once()) ->method('post') ->with('conversations/imgur') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->messageCreate(['recipient' => 'imgur', 'body' => 'YO !'])); } @@ -139,7 +139,7 @@ public function testConversationDelete() $api->expects($this->once()) ->method('delete') ->with('conversations/11247233') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->conversationDelete('11247233')); } @@ -156,7 +156,7 @@ public function testReportSender() $api->expects($this->once()) ->method('post') ->with('conversations/report/imgur') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->reportSender('imgur')); } @@ -173,7 +173,7 @@ public function testBlockSender() $api->expects($this->once()) ->method('post') ->with('conversations/block/imgur') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->blockSender('imgur')); } diff --git a/tests/Api/CustomGalleryTest.php b/tests/Api/CustomGalleryTest.php index c4bcb7a..11bd6bc 100644 --- a/tests/Api/CustomGalleryTest.php +++ b/tests/Api/CustomGalleryTest.php @@ -104,7 +104,7 @@ public function testCustomGallery() $api->expects($this->once()) ->method('get') ->with('g/custom/viral/week/0') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->customGallery()); } @@ -141,7 +141,7 @@ public function testFiltered() $api->expects($this->once()) ->method('get') ->with('g/filtered/viral/week/0') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->filtered()); } @@ -178,7 +178,7 @@ public function testImage() $api->expects($this->once()) ->method('get') ->with('g/custom/ccWiaRJ') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->image('ccWiaRJ')); } @@ -195,7 +195,7 @@ public function testAddTags() $api->expects($this->once()) ->method('put') ->with('g/add_tags', ['tags' => 'cats,funny']) - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->addTags(['cats', 'funny'])); } @@ -212,7 +212,7 @@ public function testRemoveTags() $api->expects($this->once()) ->method('delete') ->with('g/remove_tags', ['tags' => 'cats,funny']) - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->removeTags(['cats', 'funny'])); } @@ -229,7 +229,7 @@ public function testBlockTag() $api->expects($this->once()) ->method('post') ->with('g/block_tag', ['tag' => 'funny']) - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->blockTag('funny')); } @@ -246,7 +246,7 @@ public function testUnBlockTag() $api->expects($this->once()) ->method('post') ->with('g/unblock_tag', ['tag' => 'funny']) - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->unBlockTag('funny')); } diff --git a/tests/Api/GalleryTest.php b/tests/Api/GalleryTest.php index 6531cf5..8b7d12e 100644 --- a/tests/Api/GalleryTest.php +++ b/tests/Api/GalleryTest.php @@ -121,7 +121,7 @@ public function testGallery() $api->expects($this->once()) ->method('get') ->with('gallery/hot/viral/day/0', ['showViral' => 'true']) - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->gallery()); } @@ -169,7 +169,7 @@ public function testMemesSubgallery() $api->expects($this->once()) ->method('get') ->with('g/memes/viral/day/0') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->memesSubgallery()); } @@ -206,7 +206,7 @@ public function testMemeSubgalleryImage() $api->expects($this->once()) ->method('get') ->with('g/memes/MPx6ZXr') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->memeSubgalleryImage('MPx6ZXr')); } @@ -227,7 +227,7 @@ public function testSubredditGalleries() $api->expects($this->once()) ->method('get') ->with('gallery/r/pics/time/day/0') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->subredditGalleries('pics')); } @@ -266,7 +266,7 @@ public function testSubredditImage() $api->expects($this->once()) ->method('get') ->with('gallery/r/pics/yB1PpjL') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->subredditImage('pics', 'yB1PpjL')); } @@ -285,7 +285,7 @@ public function testGalleryTag() $api->expects($this->once()) ->method('get') ->with('gallery/t/funny/viral/week/0') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->galleryTag('funny')); } @@ -322,7 +322,7 @@ public function testGalleryTagImage() $api->expects($this->once()) ->method('get') ->with('gallery/t/funny/yB1PpjL') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->galleryTagImage('funny', 'yB1PpjL')); } @@ -341,7 +341,7 @@ public function testGalleryItemTags() $api->expects($this->once()) ->method('get') ->with('gallery/y1Od4/tags') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->galleryItemTags('y1Od4')); } @@ -358,7 +358,7 @@ public function testGalleryVoteTag() $api->expects($this->once()) ->method('post') ->with('gallery/y1Od4/vote/tag/funny/up') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->galleryVoteTag('y1Od4', 'funny', 'up')); } @@ -388,7 +388,7 @@ public function testSearch() $api->expects($this->once()) ->method('get') ->with('gallery/search/time/0', ['q' => '20minutes']) - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->search('20minutes')); } @@ -418,7 +418,7 @@ public function testRandomGalleryImages() $api->expects($this->once()) ->method('get') ->with('gallery/random/random/0') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->randomGalleryImages()); } @@ -435,7 +435,7 @@ public function testSubmitToGallery() $api->expects($this->once()) ->method('post') ->with('gallery/y1Od4') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->submitToGallery('y1Od4', ['title' => 'yo'])); } @@ -461,7 +461,7 @@ public function testRemoveFromGallery() $api->expects($this->once()) ->method('delete') ->with('gallery/ccWiaRJ') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->removeFromGallery('ccWiaRJ')); } @@ -480,7 +480,7 @@ public function testAlbum() $api->expects($this->once()) ->method('get') ->with('gallery/album/VOMXz') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->album('VOMXz')); } @@ -499,7 +499,7 @@ public function testImage() $api->expects($this->once()) ->method('get') ->with('gallery/image/ccWiaRJ') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->image('ccWiaRJ')); } @@ -516,7 +516,7 @@ public function testReport() $api->expects($this->once()) ->method('post') ->with('gallery/VOMXz/report') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->report('VOMXz')); } @@ -535,7 +535,7 @@ public function testVotes() $api->expects($this->once()) ->method('get') ->with('gallery/VOMXz/votes') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->votes('VOMXz')); } @@ -552,7 +552,7 @@ public function testVote() $api->expects($this->once()) ->method('post') ->with('gallery/VOMXz/vote/up') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->vote('VOMXz', 'up')); } @@ -582,7 +582,7 @@ public function testComments() $api->expects($this->once()) ->method('get') ->with('gallery/VOMXz/comments/best') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->comments('VOMXz')); } @@ -610,7 +610,7 @@ public function testComment() $api->expects($this->once()) ->method('get') ->with('gallery/VOMXz/comment/1234') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->comment('VOMXz', '1234')); } @@ -627,7 +627,7 @@ public function testCreateComment() $api->expects($this->once()) ->method('post') ->with('gallery/VOMXz/comment') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->createComment('VOMXz', ['comment' => 'yo'])); } @@ -653,7 +653,7 @@ public function testCreateReply() $api->expects($this->once()) ->method('post') ->with('gallery/VOMXz/comment/123') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->createReply('VOMXz', '123', ['comment' => 'yo'])); } @@ -683,7 +683,7 @@ public function testCommentIds() $api->expects($this->once()) ->method('get') ->with('gallery/VOMXz/comments/ids') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->commentIds('VOMXz')); } @@ -700,7 +700,7 @@ public function testCommentCount() $api->expects($this->once()) ->method('get') ->with('gallery/VOMXz/comments/count') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->commentCount('VOMXz')); } diff --git a/tests/Api/ImageTest.php b/tests/Api/ImageTest.php index 77e8032..5a44775 100644 --- a/tests/Api/ImageTest.php +++ b/tests/Api/ImageTest.php @@ -105,7 +105,7 @@ public function testImage() $api->expects($this->once()) ->method('get') ->with('image/ZOY11VC') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->image('ZOY11VC')); } @@ -122,7 +122,7 @@ public function testUploadWithUrl() $api->expects($this->once()) ->method('post') ->with('image') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->upload(['type' => 'url', 'image' => 'http://i.imgur.com/ZOY11VC.png'])); } @@ -139,9 +139,9 @@ public function testUploadWithFile() $api->expects($this->once()) ->method('post') ->with('image') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); - $this->assertSame($expectedValue, $api->upload(['type' => 'file', 'image' => './ZOY11VC.png'])); + $this->assertSame($expectedValue, $api->upload(['type' => 'file', 'image' => __DIR__ . '/ZOY11VC.png'])); } /** @@ -174,7 +174,7 @@ public function testDeleteImage() $api->expects($this->once()) ->method('delete') ->with('image/ZOY11VC') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->deleteImage('ZOY11VC')); } @@ -191,7 +191,7 @@ public function testUpdate() $api->expects($this->once()) ->method('post') ->with('image/ZOY11VC') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->update('ZOY11VC', ['title' => 'hihihi'])); } @@ -208,7 +208,7 @@ public function testFavorite() $api->expects($this->once()) ->method('post') ->with('image/ZOY11VC/favorite') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->favorite('ZOY11VC')); } diff --git a/tests/Api/MemegenTest.php b/tests/Api/MemegenTest.php index cd71b59..66dae2f 100644 --- a/tests/Api/MemegenTest.php +++ b/tests/Api/MemegenTest.php @@ -103,7 +103,7 @@ public function testMemegen() $api->expects($this->once()) ->method('get') ->with('memegen/defaults') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->defaultMemes()); } diff --git a/tests/Api/NotificationTest.php b/tests/Api/NotificationTest.php index e1e6efd..849f806 100644 --- a/tests/Api/NotificationTest.php +++ b/tests/Api/NotificationTest.php @@ -98,7 +98,7 @@ public function testNotifications() $api->expects($this->once()) ->method('get') ->with('notification', ['new' => 'true']) - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->notifications()); } @@ -117,7 +117,7 @@ public function testNotification() $api->expects($this->once()) ->method('get') ->with('notification/76878181') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->notification('76878181')); } @@ -134,7 +134,7 @@ public function testNotificationViewed() $api->expects($this->once()) ->method('post') ->with('notification/76878181') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->notificationViewed('76878181')); } diff --git a/tests/Api/TopicTest.php b/tests/Api/TopicTest.php index 2598366..42a9d6d 100644 --- a/tests/Api/TopicTest.php +++ b/tests/Api/TopicTest.php @@ -139,7 +139,7 @@ public function testTopic() $api->expects($this->once()) ->method('get') ->with('topics/defaults') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->defaultTopics()); } @@ -158,7 +158,7 @@ public function testGalleryTopic() $api->expects($this->once()) ->method('get') ->with('topics/155/viral/week/0') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->galleryTopic(155)); } @@ -195,7 +195,7 @@ public function testGalleryTopicItem() $api->expects($this->once()) ->method('get') ->with('topics/155/Fbae9SG') - ->will($this->returnValue($expectedValue)); + ->willReturn($expectedValue); $this->assertSame($expectedValue, $api->galleryTopicItem(155, 'Fbae9SG')); } diff --git a/tests/Api/ZOY11VC.png b/tests/Api/ZOY11VC.png new file mode 100644 index 0000000..cd74edf Binary files /dev/null and b/tests/Api/ZOY11VC.png differ