From 7e6a674fc5e09547173539faca3f54a947511d95 Mon Sep 17 00:00:00 2001 From: Pierre Grimaud Date: Fri, 19 Jun 2020 21:32:21 +0200 Subject: [PATCH] Add tests for #77 - data needed --- README.md | 4 +-- tests/ApiTest.php | 26 +++++++++++++++++++ .../instagram-profile-additional-data.html | 1 + 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 tests/fixtures/instagram-profile-additional-data.html diff --git a/README.md b/README.md index 33f387f..1a0603a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/pgrimaud/instagram-user-feed.svg?branch=master)](https://travis-ci.org/pgrimaud/instagram-user-feed) [![Packagist](https://img.shields.io/badge/packagist-install-brightgreen.svg)](https://packagist.org/packages/pgrimaud/instagram-user-feed) -[![Coverage Status](https://coveralls.io/repos/github/pgrimaud/instagram-user-feed/badge.svg)](https://coveralls.io/github/pgrimaud/instagram-user-feed) +[![Coverage Status](https://coveralls.io/repos/github/pgrimaud/instagram-user-feed/badge.svg?branch=6.x)](https://coveralls.io/github/pgrimaud/instagram-user-feed?branch=6.x) [![Minimum PHP Version](https://img.shields.io/packagist/php-v/pgrimaud/instagram-user-feed.svg?maxAge=3600)](https://packagist.org/packages/pgrimaud/instagram-user-feed) [![Last version](https://img.shields.io/packagist/v/pgrimaud/instagram-user-feed?maxAge=3600)](https://packagist.org/packages/pgrimaud/instagram-user-feed) @@ -22,7 +22,7 @@ If you like or use this package, please share your love by starring this reposit - Fetch highlights stories of user - Fetch detailed post of user -**⚠️ Version ^5.0 is no more maintained.** +**⚠️ Version ^5.0 is no more maintained. ⚠️** ## Version ^6.0 This version can retrieve **ANY** Instagram feed using **web scrapping**. diff --git a/tests/ApiTest.php b/tests/ApiTest.php index cbca24b..198a3b9 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -352,6 +352,32 @@ public function testGetMediaDetailed() $this->assertCount(3, $mediaDetailed->getDisplayResources()); + $api->logout(); + } + + public function testProfileFetchWithContentInAdditionalData() + { + $cachePool = new FilesystemAdapter('Instagram', 0, __DIR__ . '/cache'); + + $mock = new MockHandler([ + new Response(200, ['Set-Cookie' => 'cookie'], file_get_contents(__DIR__ . '/fixtures/instagram-home.html')), + new Response(200, [], file_get_contents(__DIR__ . '/fixtures/instagram-login-success.json')), + new Response(200, [], file_get_contents(__DIR__ . '/fixtures/instagram-profile-additional-data.html')), + ]); + + $handlerStack = HandlerStack::create($mock); + $client = new Client(['handler' => $handlerStack]); + + $api = new Api($cachePool, $client); + + // clear cache + $api->logout(); + + $api->login('username', 'password'); + $profile = $api->getProfile('robertdowneyjr'); + + $this->assertSame('robertdowneyjr', $profile->getUserName()); + $api->logout(); } } diff --git a/tests/fixtures/instagram-profile-additional-data.html b/tests/fixtures/instagram-profile-additional-data.html new file mode 100644 index 0000000..f8e9c66 --- /dev/null +++ b/tests/fixtures/instagram-profile-additional-data.html @@ -0,0 +1 @@ +NEED DATA