Skip to content

Commit fdb33a4

Browse files
authored
Merge pull request #86 from GetStream/feature/replace-abandoned-packages
upgrade dependencies, drop php5.x support, update tests
2 parents 979325b + 00cf81c commit fdb33a4

10 files changed

Lines changed: 59 additions & 67 deletions

File tree

.travis.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,17 @@ sudo: false
33

44
matrix:
55
include:
6-
- php: 5.6
7-
env: TEST_SUITE="Unit Test Suite"
8-
- php: 7.0
6+
- php: 7.2
97
env: TEST_SUITE="Unit Test Suite"
10-
- php: 7.1
8+
- php: 7.3
119
env: TEST_SUITE="Unit Test Suite"
12-
- php: 7.2
13-
env: TEST_SUITE="Unit Test Suite" COLLECT_COVERAGE=true
14-
- php: 7.2
10+
- php: 7.3
1511
env: TEST_SUITE="Integration Test Suite"
1612
allow_failures:
17-
- php: 7.2
13+
- php: 7.3
1814
env: TEST_SUITE="Integration Test Suite"
1915

2016
before_script:
2117
- travis_retry composer install --no-interaction
2218
script:
2319
- vendor/bin/phpunit --testsuite "$TEST_SUITE"
24-
after_script:
25-
- if [[ "$COLLECT_COVERAGE" == "true" ]]; then vendor/bin/coveralls; fi

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Composer will install our latest version automatically.
2323

2424
#### PHP compatibility
2525

26-
Current releases require PHP `5.5` or higher, and depends on Guzzle version 6.
26+
Current releases require PHP `7.2` or higher, and depends on Guzzle version 6.
2727

2828
If you need to use the client with PHP 5.4 or earlier versions of Guzzle, you can grab an earlier version of this package:
2929

composer.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111
}
1212
],
1313
"require": {
14-
"php": ">=5.5",
15-
"guzzlehttp/guzzle": "^6.0",
16-
"firebase/php-jwt": "~3.0|~4.0|~5.0"
14+
"php": ">=7.2",
15+
"guzzlehttp/guzzle": "^6.3.3",
16+
"firebase/php-jwt": "^v5.0.0"
1717
},
1818
"require-dev": {
19-
"phpunit/phpunit": "^4.3",
20-
"satooshi/php-coveralls": "^1.0",
21-
"ramsey/uuid": "^3.7"
19+
"phpunit/phpunit": "^8.2.1",
20+
"ramsey/uuid": "^3.8"
2221
},
2322
"autoload": {
2423
"psr-0": {

phpunit.xml.dist

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,17 @@
77
processIsolation="false"
88
bootstrap="vendor/autoload.php"
99
>
10-
<logging>
11-
<log type="coverage-clover" target="build/logs/clover.xml"/>
12-
</logging>
13-
<filter>
14-
<whitelist processUncoveredFilesFromWhitelist="true">
15-
<directory suffix=".php">lib/</directory>
16-
</whitelist>
17-
</filter>
18-
<testsuites>
19-
<testsuite name="Unit Test Suite">
20-
<directory>tests/unit</directory>
21-
</testsuite>
22-
<testsuite name="Integration Test Suite">
23-
<directory>tests/integration</directory>
24-
</testsuite>
25-
</testsuites>
10+
<filter>
11+
<whitelist processUncoveredFilesFromWhitelist="true">
12+
<directory suffix=".php">lib/</directory>
13+
</whitelist>
14+
</filter>
15+
<testsuites>
16+
<testsuite name="Unit Test Suite">
17+
<directory>tests/unit</directory>
18+
</testsuite>
19+
<testsuite name="Integration Test Suite">
20+
<directory>tests/integration</directory>
21+
</testsuite>
22+
</testsuites>
2623
</phpunit>

tests/integration/CollectionTest.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class CollectionTest extends TestCase
5353
*/
5454
protected $collections;
5555

56-
protected function setUp()
56+
protected function setUp():void
5757
{
5858
$this->client = new Client(
5959
getenv('STREAM_API_KEY'),
@@ -78,9 +78,10 @@ public function cleanUp(){
7878

7979
public function testUpsert()
8080
{
81-
$collection = $this->collections->upsert('animals', ['id' => '1', 'name' => 'bear', 'color' => 'blue']);
82-
$collection = $this->collections->upsert('items', ['id' => '42', 'name' => 'towel']);
83-
81+
$collection = $this->collections->upsert('animals', [['id' => '1', 'name' => 'bear', 'color' => 'blue']]);
82+
$this->assertSame($collection['data']['animals'][0]['name'], 'bear');
83+
$collection = $this->collections->upsert('items', [['id' => '42', 'name' => 'towel']]);
84+
$this->assertSame($collection['data']['items'][0]['name'], 'towel');
8485
}
8586

8687
public function testAddCollection()
@@ -105,12 +106,10 @@ public function testAddCollectionWithId()
105106
$this->assertSame($response['data']['name'], 'Cheese Burger');
106107
}
107108

108-
/**
109-
* @expectedException \GetStream\Stream\StreamFeedException
110-
*/
111109
public function testAddCollectionAgain()
112110
{
113111
// Adding again should throw error
112+
$this->expectException(\GetStream\Stream\StreamFeedException::class);
114113
$response = $this->collections->add(
115114
"food", ["name" => "Cheese Burger", "rating" => "4 stars"], "cheese-burger"
116115
);
@@ -119,13 +118,12 @@ public function testAddCollectionAgain()
119118
public function testDeleteCollection()
120119
{
121120
$response = $this->collections->delete("food","cheese-burger");
121+
$this->assertTrue(array_key_exists("duration", $response));
122122
}
123123

124-
/**
125-
* @expectedException \GetStream\Stream\StreamFeedException
126-
*/
127124
public function testDeleteCollectionAgain()
128125
{
126+
$this->expectException(\GetStream\Stream\StreamFeedException::class);
129127
$response = $this->collections->delete("food","cheese-burger");
130128
}
131129

@@ -174,7 +172,7 @@ public function testDeleteManyCollection()
174172
"food", ["name" => "Cheese Burger", "rating" => "4 stars"], "cheese-burger-2"
175173
);
176174
$response = $this->collections->deleteMany("food",["cheese-burger-1", "cheese-burger-2"]);
177-
175+
$this->assertTrue(array_key_exists("duration", $response));
178176
}
179177

180178
}

tests/integration/FeedTest.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class FeedTest extends TestCase
3737
*/
3838
protected $flat3;
3939

40-
protected function setUp()
40+
protected function setUp():void
4141
{
4242
$this->client = new Client(
4343
getenv('STREAM_API_KEY'),
@@ -72,6 +72,9 @@ public function testRedirectUrl()
7272
];
7373
$events = [$impression, $engagement];
7474
$finalUrl = $this->client->createRedirectUrl($targetUrl, $events);
75+
$this->assertTrue(strpos($finalUrl, "google.com") > 0);
76+
$this->assertTrue(strpos($finalUrl, "feed_id") > 0);
77+
$this->assertTrue(strpos($finalUrl, "flat%3Atommaso") > 0);
7578
}
7679

7780
public function testUpdateActivity()
@@ -86,9 +89,12 @@ public function testUpdateActivity()
8689
'popularity' => 100
8790
];
8891

89-
$this->client->updateActivity($activity);
92+
$response = $this->client->updateActivity($activity);
9093
$activity['popularity'] = 10;
9194
$this->client->updateActivity($activity);
95+
$response = $this->client->getActivities(null, [[$activity['foreign_id'], $now]]);
96+
$check = $response['results'][0];
97+
$this->assertSame($activity['popularity'], $check['popularity']);
9298
}
9399

94100
public function testBatchPartialUpdateActivity()
@@ -524,8 +530,13 @@ public function testGet()
524530

525531
public function testVerifyOff()
526532
{
533+
$activities_before = $this->user1->getActivities(0, 2);
527534
$this->user1->setGuzzleDefaultOption('verify', true);
528-
$activities = $this->user1->getActivities(0, 2);
535+
$activities_after = $this->user1->getActivities(0, 2);
536+
$this->assertSame(
537+
$activities_before['results'][0]['id'],
538+
$activities_after['results'][0]['id'],
539+
);
529540
}
530541

531542
public function testMarkRead()
@@ -781,7 +792,8 @@ public function testUpdateActivitiesToReplaceTargets()
781792

782793
public function testUpdateActivitiesWithZeroActivitiesShouldNotFail()
783794
{
784-
$this->client->updateActivities([]);
795+
$response = $this->client->updateActivities([]);
796+
$this->assertNull($response);
785797
}
786798

787799
public function testEnrichment(){
@@ -796,7 +808,7 @@ public function testEnrichment(){
796808
$feed->addActivity($activity);
797809
$response = $feed->getActivities(0, 3, [], $enrich=true);
798810
$this->assertSame($response["results"][0]["actor"], $user);
799-
$bear = ["id" => "1", "type" => "bear", "color" => "blue"];
811+
$bear = [["id" => "1", "type" => "bear", "color" => "blue"]];
800812
$respone = $this->client->collections()->upsert("animals", $bear);
801813
unset($bear['duration']);
802814
$activity = [
@@ -806,9 +818,7 @@ public function testEnrichment(){
806818
];
807819
$feed->addActivity($activity);
808820
$response = $feed->getActivities(0, 1, [], $enrich=true);
809-
$this->assertSame($response["results"][0]["object"]['id'], $bear['id']);
810-
unset($bear['id']);
811-
$this->assertEquals($response["results"][0]["object"]['data'], $bear, $canonicalize=true);
821+
$this->assertSame($response["results"][0]["object"]['id'], $bear[0]['id']);
812822
}
813823

814824
public function testGetActivities(){

tests/integration/ReactionTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class ReactionTest extends TestCase
5252
*/
5353
protected $reactions;
5454

55-
protected function setUp()
55+
protected function setUp():void
5656
{
5757
$this->client = new Client(
5858
getenv('STREAM_API_KEY'),
@@ -139,10 +139,8 @@ public function testGetReaction(){
139139
$this->assertSame($created_reaction['created_at'], $retrieved_reaction['created_at']);
140140
}
141141

142-
/**
143-
* @expectedException \GetStream\Stream\StreamFeedException
144-
*/
145142
public function testDeleteReaction(){
143+
$this->expectException(\GetStream\Stream\StreamFeedException::class);
146144
$created_reaction = $this->reactions->add('like', $this->activity_id, 'bob');
147145
$retrieved_reaction = $this->reactions->get($created_reaction['id']);
148146
$this->reactions->delete($created_reaction['id']);

tests/integration/UsersTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class UserTest extends TestCase
5252
*/
5353
protected $users;
5454

55-
protected function setUp()
55+
protected function setUp():void
5656
{
5757
$this->client = new Client(
5858
getenv('STREAM_API_KEY'),
@@ -110,10 +110,8 @@ public function testGetUser(){
110110
$this->assertSame($created_user['data'], array());
111111
}
112112

113-
/**
114-
* @expectedException \GetStream\Stream\StreamFeedException
115-
*/
116113
public function testDeleteUser(){
114+
$this->expectException(\GetStream\Stream\StreamFeedException::class);
117115
$uuid = Uuid::uuid4()->toString();
118116
$created_user = $this->users->add($uuid);
119117
$retrieved_user = $this->users->get($created_user['id']);

tests/unit/BaseFeedTest.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,25 @@ public function testClientFeedAddActivity()
1717
$this->assertSame('feed/feed/1/', $response['uri']);
1818
}
1919

20-
/**
21-
* @expectedException \GetStream\Stream\StreamFeedException
22-
*/
2320
public function testValidateSlug()
2421
{
22+
$this->expectException(\GetStream\Stream\StreamFeedException::class);
2523
$client = $this->createClientMock();
2624
new BaseFeedStub($client, 'feed-ko', '1', 'api', 'token');
2725
}
2826

29-
/**
30-
* @expectedException \GetStream\Stream\StreamFeedException
31-
*/
3227
public function testValidateUserId()
3328
{
29+
$this->expectException(\GetStream\Stream\StreamFeedException::class);
3430
$client = $this->createClientMock();
3531
new BaseFeedStub($client, 'feed_ko', 'ko:1', 'api', 'token');
3632
}
3733

3834
public function testDashIsOkUserId()
3935
{
4036
$client = $this->createClientMock();
41-
new BaseFeedStub($client, 'feed_ko', 'ko-1', 'api', 'token');
37+
$feed = new BaseFeedStub($client, 'feed_ko', 'ko-1', 'api', 'token');
38+
$this->assertSame($feed->getUserId(), 'ko-1');
4239
}
4340

4441
public function testGetToken()

tests/unit/ClientTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function testClientFeed()
4545
{
4646
$client = new Client('key', 'secret', $location='qa');
4747
$feed1 = $client->feed('flat', '1');
48+
$this->assertSame($feed1->getId(), 'flat:1');
4849
}
4950

5051
public function testCreateReference()

0 commit comments

Comments
 (0)