Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Composer dependencies #986

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ phpunit.phar
tests/sessions
phpunit.xml
settings.json
.phpunit.result.cache
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This library is based on the Instagram web version. We develop it because nowadays it is hard to get an approved Instagram application. The purpose is to support every feature that the web desktop and mobile version support.

## Dependencies
- PHP >= 7.2
- PHP >= 8.0
- [PSR-16](http://www.php-fig.org/psr/psr-16/)
- [PSR-18](http://www.php-fig.org/psr/psr-18/)

Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
}
],
"require": {
"php": ">=7.2",
"php": ">=8.0",
"ext-curl": "*",
"ext-json": "*",
"psr/simple-cache": "~1.0",
"psr/simple-cache": "~3.0",
"psr/http-client": "~1.0",
"guzzlehttp/psr7": "^1.7"
"guzzlehttp/psr7": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"phpfastcache/phpfastcache": "^7.1",
"guzzlehttp/guzzle": "^7.2"
"phpunit/phpunit": "^9.0",
"phpfastcache/phpfastcache": "^9.0",
"guzzlehttp/guzzle": "^7.4"
},
"autoload": {
"psr-4": {
Expand Down
47 changes: 24 additions & 23 deletions tests/InstagramTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class InstagramTest extends TestCase
*/
private static $instagram;

public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
$sessionFolder = __DIR__ . DIRECTORY_SEPARATOR . 'sessions' . DIRECTORY_SEPARATOR;
$defaultDriver = 'Files';
Expand All @@ -34,7 +34,7 @@ public static function setUpBeforeClass()

}

public function testGetAccountByUsername()
public function testGetAccountByUsername(): void
{
$account = self::$instagram->getAccount('kevin');
$this->assertEquals('kevin', $account->getUsername());
Expand All @@ -44,7 +44,7 @@ public function testGetAccountByUsername()
/**
* @group getAccountById
*/
public function testGetAccountById()
public function testGetAccountById(): void
{

$account = self::$instagram->getAccountById(3);
Expand All @@ -60,61 +60,62 @@ public function testGetAccountByIdWithInvalidNumericId()
self::$instagram->getAccountById(PHP_INT_MAX);
}

public function testGetMedias()
public function testGetMedias(): void
{
$medias = self::$instagram->getMedias('kevin', 80);
$this->assertEquals(80, sizeof($medias));
}

public function testGet100Medias()
public function testGet100Medias(): void
{
$medias = self::$instagram->getMedias('kevin', 100);
$this->assertEquals(100, sizeof($medias));
}

public function testGetMediasByTag()
public function testGetMediasByTag(): void
{
$medias = self::$instagram->getMediasByTag('youneverknow', 20);
$this->assertEquals(20, sizeof($medias));
}

public function testGetMediaByCode()
public function testGetMediaByCode(): void
{
$media = self::$instagram->getMediaByCode('BHaRdodBouH');
$this->assertEquals('kevin', $media->getOwner()->getUsername());
}

public function testGetMediaByUrl()
public function testGetMediaByUrl(): void
{
$media = self::$instagram->getMediaByUrl('https://www.instagram.com/p/BHaRdodBouH');
$this->assertEquals('kevin', $media->getOwner()->getUsername());
}

public function testGetLocationTopMediasById()
public function testGetLocationTopMediasById(): void
{
$medias = self::$instagram->getCurrentTopMediasByTagName(1);
$this->assertEquals(9, count($medias));
}

public function testGetLocationMediasById()
public function testGetLocationMediasById(): void
{
$medias = self::$instagram->getMediasByLocationId(881442298, 56);
$this->assertEquals(56, count($medias));
}

public function testGetLocationById()
public function testGetLocationById(): void
{
$location = self::$instagram->getLocationById(881442298);
$this->assertEquals('Pendleberry Grove', $location->getName());
}

public function testGetMediaByTag()
public function testGetMediaByTag(): void
{
$medias = self::$instagram->getMediasByTag('hello');
echo json_encode($medias);
$this->assertIsArray($medias);
$this->assertIsIterable($medias);
}

public function testGetIdFromCode()
public function testGetIdFromCode(): void
{
$code = Media::getCodeFromId('1270593720437182847');
$this->assertEquals('BGiDkHAgBF_', $code);
Expand All @@ -124,13 +125,13 @@ public function testGetIdFromCode()
$this->assertEquals('BGiDkHAgBF_', $code);
}

public function testGetCodeFromId()
public function testGetCodeFromId(): void
{
$id = Media::getIdFromCode('BGiDkHAgBF_');
$this->assertEquals(1270593720437182847, $id);
}

public function testGeMediaCommentsByCode()
public function testGeMediaCommentsByCode(): void
{
$comments = self::$instagram->getMediaCommentsByCode('BR5Njq1gKmB', 40);
//TODO: check why returns less comments
Expand All @@ -140,7 +141,7 @@ public function testGeMediaCommentsByCode()
/**
* @group getUsernameById
*/
public function testGetUsernameById()
public function testGetUsernameById(): void
{
$username = self::$instagram->getUsernameById(3);
$this->assertEquals('kevin', $username);
Expand All @@ -149,28 +150,28 @@ public function testGetUsernameById()
/**
* @group getMediasByIserId
*/
public function testGetMediasByUserId()
public function testGetMediasByUserId(): void
{
$instagram = new Instagram(new Client());
$nonPrivateAccountMedias = $instagram->getMediasByUserId(3);
$this->assertEquals(12, count($nonPrivateAccountMedias));
}

public function testLikeMediaById()
public function testLikeMediaById(): void
{
// https://www.instagram.com/p/B910VxfgEIO/
self::$instagram->like('2266948182120350222');
$this->assertTrue(true, 'Return type ensures this assertion is never reached on failure');
}

public function testUnlikeMediaById()
public function testUnlikeMediaById(): void
{
// https://www.instagram.com/p/B910VxfgEIO/
self::$instagram->unlike('2266948182120350222');
$this->assertTrue(true, 'Return type ensures this assertion is never reached on failure');
}

public function testAddAndDeleteComment()
public function testAddAndDeleteComment(): void
{
// https://www.instagram.com/p/B910VxfgEIO/
$comment1 = self::$instagram->addComment('2266948182120350222', 'Cool!');
Expand All @@ -189,7 +190,7 @@ public function testAddAndDeleteComment()
/**
* @group getPaginateMediasByLocationId
*/
public function testGetPaginateMediasByLocationId()
public function testGetPaginateMediasByLocationId(): void
{
$medias = self::$instagram->getPaginateMediasByLocationId('201176299974017');
echo json_encode($medias);
Expand All @@ -198,7 +199,7 @@ public function testGetPaginateMediasByLocationId()
/**
* @group getHighlights
*/
public function testGetHighlights()
public function testGetHighlights(): void
{
$userId = self::$instagram->getAccount('instagram')->getId();
$highlights = self::$instagram->getHighlights($userId);
Expand Down