Skip to content

Commit

Permalink
Add test for update code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrimaud committed May 29, 2019
1 parent 43d1ac9 commit b149b13
Show file tree
Hide file tree
Showing 2 changed files with 381 additions and 3 deletions.
35 changes: 32 additions & 3 deletions tests/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ class ApiTest extends \PHPUnit_Framework_TestCase
*/
private $validHtmlClient;

/**
* @var Client
*/
private $validStatementHtmlClient;

/**
* @var Client
*/
Expand Down Expand Up @@ -71,9 +76,10 @@ public function setUp()

copy(__DIR__ . '/cache/invalid/demo.cache', __DIR__ . '/cache/invalid/pgrimaud.cache');

$validHtmlFixtures = file_get_contents(__DIR__ . '/fixtures/pgrimaud.html');
$invalidHtmlJsonFixtures = file_get_contents(__DIR__ . '/fixtures/invalid_pgrimaud.html');
$invalidHtmlFixtures = '<html></html>';
$validHtmlFixtures = file_get_contents(__DIR__ . '/fixtures/pgrimaud.html');
$validStatementHtmlFixtures = file_get_contents(__DIR__ . '/fixtures/statement.paris.html');
$invalidHtmlJsonFixtures = file_get_contents(__DIR__ . '/fixtures/invalid_pgrimaud.html');
$invalidHtmlFixtures = '<html></html>';

$validJsonFixtures = file_get_contents(__DIR__ . '/fixtures/pgrimaud.json');
$invalidJsonFixtures = '<html></html>';
Expand All @@ -87,6 +93,11 @@ public function setUp()
$handler = HandlerStack::create($mock);
$this->validHtmlClient = new Client(['handler' => $handler]);

$response = new Response(200, $headers, $validStatementHtmlFixtures);
$mock = new MockHandler([$response]);
$handler = HandlerStack::create($mock);
$this->validStatementHtmlClient = new Client(['handler' => $handler]);

$response = new Response(200, [], $invalidHtmlFixtures);
$mock = new MockHandler([$response]);
$handler = HandlerStack::create($mock);
Expand Down Expand Up @@ -350,4 +361,22 @@ public function testHtmlFeedWithNoCacheManager()
$api->setEndCursor('endCursor');
$api->getFeed();
}

/**
* @throws CacheException
* @throws InstagramException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function testStatementHtmlFeedWithVideoPost()
{
$api = new Api($this->validCacheManager, $this->validStatementHtmlClient);
$api->setUserName('statement.paris');

$feed = $api->getFeed();

// fist media is a video
/** @var Media $post */
$media = $feed->getMedias()[0];
$this->assertSame(199, $media->getVideoViewCount());
}
}
Loading

0 comments on commit b149b13

Please sign in to comment.