Skip to content

Commit 8052aba

Browse files
author
Joel Butcher
committed
update required php versions. Update PHPUnit. Use Mockery and update tests
1 parent 6de3555 commit 8052aba

30 files changed

+194
-202
lines changed

composer.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
{
2-
"name": "facebook/graph-sdk",
2+
"name": "joelbutcher/facebook-graph-sdk",
33
"description": "Facebook SDK for PHP",
4-
"keywords": ["facebook", "sdk"],
4+
"keywords": ["facebook", "sdk", "php"],
55
"type": "library",
6-
"homepage": "https://github.com/facebook/php-graph-sdk",
6+
"homepage": "https://github.com/joelbutcher/facebook-graph-sdk",
77
"license": "Facebook Platform",
88
"authors": [
99
{
10-
"name": "Facebook",
11-
"homepage": "https://github.com/facebook/php-graph-sdk/contributors"
10+
"name": "Joel Butcher",
11+
"homepage": "https://github.com/joelbutcher/facebook-graph-sdk/contributors"
1212
}
1313
],
1414
"config": {
1515
"sort-packages": true
1616
},
1717
"require": {
18-
"php": "^7.1",
18+
"php": "^7.3 || ^8.0",
1919
"psr/http-message": "^1.0",
2020
"php-http/client-implementation": "^1.0",
2121
"php-http/httplug": "^1.0",
2222
"php-http/discovery": "^1.0",
23-
2423
"php-http/message": "^1.0"
2524
},
2625
"require-dev": {
27-
"phpunit/phpunit": "^6.2",
26+
"mockery/mockery": "^1.0",
27+
"phpunit/phpunit": "^9.3",
2828
"php-http/guzzle6-adapter": "^1.0"
2929
},
3030
"autoload": {

tests/ApplicationTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ApplicationTest extends TestCase
3333
*/
3434
private $app;
3535

36-
protected function setUp()
36+
protected function setUp(): void
3737
{
3838
$this->app = new Application('id', 'secret');
3939
}
@@ -65,11 +65,10 @@ public function testSerialization()
6565
$this->assertEquals('secret', $newApp->getSecret());
6666
}
6767

68-
/**
69-
* @expectedException \Facebook\Exception\SDKException
70-
*/
7168
public function testOverflowIntegersWillThrow()
7269
{
70+
$this->expectException(\Facebook\Exception\SDKException::class);
71+
7372
new Application(PHP_INT_MAX + 1, "foo");
7473
}
7574

tests/Authentication/AccessTokenMetadataTest.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,9 @@ public function testAllTheGettersReturnTheProperValue()
8080
$this->assertEquals('1337', $metadata->getUserId());
8181
}
8282

83-
/**
84-
* @expectedException \Facebook\Exception\SDKException
85-
*/
8683
public function testInvalidMetadataWillThrow()
8784
{
85+
$this->expectException(\Facebook\Exception\SDKException::class);
8886
new AccessTokenMetadata(['foo' => 'bar']);
8987
}
9088

@@ -96,11 +94,9 @@ public function testAnExpectedAppIdWillNotThrow()
9694
$this->assertTrue(true);
9795
}
9896

99-
/**
100-
* @expectedException \Facebook\Exception\SDKException
101-
*/
10297
public function testAnUnexpectedAppIdWillThrow()
10398
{
99+
$this->expectException(\Facebook\Exception\SDKException::class);
104100
$metadata = new AccessTokenMetadata($this->graphResponseData);
105101
$metadata->validateAppId('foo');
106102

@@ -115,11 +111,9 @@ public function testAnExpectedUserIdWillNotThrow()
115111
$this->assertTrue(true);
116112
}
117113

118-
/**
119-
* @expectedException \Facebook\Exception\SDKException
120-
*/
121114
public function testAnUnexpectedUserIdWillThrow()
122115
{
116+
$this->expectException(\Facebook\Exception\SDKException::class);
123117
$metadata = new AccessTokenMetadata($this->graphResponseData);
124118
$metadata->validateUserId('foo');
125119
}
@@ -133,11 +127,9 @@ public function testAnActiveAccessTokenWillNotThrow()
133127
$this->assertTrue(true);
134128
}
135129

136-
/**
137-
* @expectedException \Facebook\Exception\SDKException
138-
*/
139130
public function testAnExpiredAccessTokenWillThrow()
140131
{
132+
$this->expectException(\Facebook\Exception\SDKException::class);
141133
$this->graphResponseData['data']['expires_at'] = time() - 1000;
142134
$metadata = new AccessTokenMetadata($this->graphResponseData);
143135
$metadata->validateExpiration();

tests/Authentication/OAuth2ClientTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class OAuth2ClientTest extends TestCase
4747
*/
4848
protected $oauth;
4949

50-
protected function setUp()
50+
protected function setUp(): void
5151
{
5252
$app = new Application('123', 'foo_secret');
5353
$this->client = new FooClientForOAuth2Test();
@@ -81,7 +81,7 @@ public function testCanBuildAuthorizationUrl()
8181
$scope = ['email', 'base_foo'];
8282
$authUrl = $this->oauth->getAuthorizationUrl('https://foo.bar', 'foo_state', $scope, ['foo' => 'bar'], '*');
8383

84-
$this->assertContains('*', $authUrl);
84+
$this->assertStringContainsStringIgnoringCase('*', $authUrl);
8585

8686
$expectedUrl = 'https://www.facebook.com/' . static::TESTING_GRAPH_VERSION . '/dialog/oauth?';
8787
$this->assertStringStartsWith($expectedUrl, $authUrl, 'Unexpected base authorization URL returned from getAuthorizationUrl().');
@@ -95,7 +95,7 @@ public function testCanBuildAuthorizationUrl()
9595
'foo' => 'bar',
9696
];
9797
foreach ($params as $key => $value) {
98-
$this->assertContains($key . '=' . urlencode($value), $authUrl);
98+
$this->assertStringContainsStringIgnoringCase($key . '=' . urlencode($value), $authUrl);
9999
}
100100
}
101101

tests/BatchRequestTest.php

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class BatchRequestTest extends TestCase
3535
*/
3636
private $app;
3737

38-
protected function setUp()
38+
protected function setUp(): void
3939
{
4040
$this->app = new Application('123', 'foo_secret');
4141
}
@@ -79,31 +79,28 @@ public function testRequestWithAppOnlyWillFallbackToBatchDefaults()
7979
$this->assertRequestContainsAppAndToken($request, $customApp, 'foo_token');
8080
}
8181

82-
/**
83-
* @expectedException \Facebook\Exception\SDKException
84-
*/
8582
public function testWillThrowWhenNoThereIsNoAppFallback()
8683
{
84+
$this->expectException(\Facebook\Exception\SDKException::class);
85+
8786
$batchRequest = new BatchRequest();
8887

8988
$batchRequest->addFallbackDefaults(new Request(null, 'foo_token'));
9089
}
9190

92-
/**
93-
* @expectedException \Facebook\Exception\SDKException
94-
*/
9591
public function testWillThrowWhenNoThereIsNoAccessTokenFallback()
9692
{
93+
$this->expectException(\Facebook\Exception\SDKException::class);
94+
9795
$request = new BatchRequest();
9896

9997
$request->addFallbackDefaults(new Request($this->app));
10098
}
10199

102-
/**
103-
* @expectedException \InvalidArgumentException
104-
*/
105100
public function testAnInvalidTypeGivenToAddWillThrow()
106101
{
102+
$this->expectException(\InvalidArgumentException::class);
103+
107104
$request = new BatchRequest();
108105

109106
$request->add('foo');
@@ -167,21 +164,19 @@ public function testRequestsCanBeInjectedIntoConstructor()
167164
$this->assertRequestsMatch($requests, $formattedRequests);
168165
}
169166

170-
/**
171-
* @expectedException \Facebook\Exception\SDKException
172-
*/
173167
public function testAZeroRequestCountWithThrow()
174168
{
169+
$this->expectException(\Facebook\Exception\SDKException::class);
170+
175171
$batchRequest = new BatchRequest($this->app, [], 'foo_token');
176172

177173
$batchRequest->validateBatchRequestCount();
178174
}
179175

180-
/**
181-
* @expectedException \Facebook\Exception\SDKException
182-
*/
183176
public function testMoreThanFiftyRequestsWillThrow()
184177
{
178+
$this->expectException(\Facebook\Exception\SDKException::class);
179+
185180
$batchRequest = $this->createBatchRequest();
186181

187182
$this->createAndAppendRequestsTo($batchRequest, 51);

tests/BatchResponseTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class BatchResponseTest extends TestCase
4242
*/
4343
protected $request;
4444

45-
protected function setUp()
45+
protected function setUp(): void
4646
{
4747
$this->app = new Application('123', 'foo_secret');
4848
$this->request = new Request(

tests/ClientTest.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class ClientTest extends TestCase
6060
*/
6161
public static $testClient;
6262

63-
protected function setUp()
63+
protected function setUp(): void
6464
{
6565
$this->fbApp = new Application('id', 'shhhh!');
6666
$this->fbClient = new Client(new MyFooHttpClient());
@@ -163,12 +163,12 @@ public function testABatchRequestWillProperlyBatchFiles()
163163

164164
$this->assertEquals(Client::BASE_GRAPH_VIDEO_URL, $url);
165165
$this->assertEquals('POST', $method);
166-
$this->assertContains('multipart/form-data; boundary=', $headers['Content-Type']);
167-
$this->assertContains('Content-Disposition: form-data; name="batch"', $body);
168-
$this->assertContains('Content-Disposition: form-data; name="include_headers"', $body);
169-
$this->assertContains('"name":0,"attached_files":', $body);
170-
$this->assertContains('"name":1,"attached_files":', $body);
171-
$this->assertContains('"; filename="foo.txt"', $body);
166+
$this->assertStringContainsStringIgnoringCase('multipart/form-data; boundary=', $headers['Content-Type']);
167+
$this->assertStringContainsStringIgnoringCase('Content-Disposition: form-data; name="batch"', $body);
168+
$this->assertStringContainsStringIgnoringCase('Content-Disposition: form-data; name="include_headers"', $body);
169+
$this->assertStringContainsStringIgnoringCase('"name":0,"attached_files":', $body);
170+
$this->assertStringContainsStringIgnoringCase('"name":1,"attached_files":', $body);
171+
$this->assertStringContainsStringIgnoringCase('"; filename="foo.txt"', $body);
172172
}
173173

174174
public function testARequestOfParamsWillBeUrlEncoded()
@@ -189,14 +189,13 @@ public function testARequestWithFilesWillBeMultipart()
189189

190190
$headersSent = $response->getRequest()->getHeaders();
191191

192-
$this->assertContains('multipart/form-data; boundary=', $headersSent['Content-Type']);
192+
$this->assertStringContainsStringIgnoringCase('multipart/form-data; boundary=', $headersSent['Content-Type']);
193193
}
194194

195-
/**
196-
* @expectedException \Facebook\Exception\SDKException
197-
*/
198195
public function testARequestValidatesTheAccessTokenWhenOneIsNotProvided()
199196
{
197+
$this->expectException(\Facebook\Exception\SDKException::class);
198+
200199
$fbRequest = new Request($this->fbApp, null, 'GET', '/foo');
201200
$this->fbClient->sendRequest($fbRequest);
202201
}

tests/Exception/ResponseExceptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ResponseExceptionTest extends TestCase
4242
*/
4343
protected $request;
4444

45-
protected function setUp()
45+
protected function setUp(): void
4646
{
4747
$this->request = new Request(new Application('123', 'foo'));
4848
}

0 commit comments

Comments
 (0)