SchoppAx /
php-sleeper-api
| 1 | <?php |
||
| 2 | |||
| 3 | use PHPUnit\Framework\TestCase; |
||
| 4 | use SchoppAx\Sleeper\SleeperClient; |
||
| 5 | use SchoppAx\Sleeper\Api\Avatars; |
||
| 6 | |||
| 7 | class SleeperAvatarTest extends TestCase |
||
| 8 | { |
||
| 9 | |||
| 10 | private function remoteFileExists($url) { |
||
| 11 | $curl = curl_init($url); |
||
| 12 | |||
| 13 | //don't fetch the actual page, you only want to check the connection is ok |
||
| 14 | curl_setopt($curl, CURLOPT_NOBODY, true); |
||
| 15 | |||
| 16 | $result = curl_exec($curl); |
||
| 17 | $ret = false; |
||
| 18 | |||
| 19 | //if request did not fail |
||
| 20 | if ($result !== false) { |
||
| 21 | //if request was ok, check response code |
||
| 22 | $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); |
||
| 23 | |||
| 24 | if ($statusCode == 200) { |
||
| 25 | $ret = true; |
||
| 26 | } |
||
| 27 | } |
||
| 28 | |||
| 29 | curl_close($curl); |
||
| 30 | |||
| 31 | return $ret; |
||
| 32 | } |
||
| 33 | |||
| 34 | public function testAvatar() |
||
| 35 | { |
||
| 36 | $client = new SleeperClient(); |
||
| 37 | |||
| 38 | $url = $client->avatars()->find('79f5f8ecdd59fe94b668993366552b3a'); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 39 | $exists = $this->remoteFileExists($url); |
||
| 40 | |||
| 41 | $this->assertIsBool($exists); |
||
| 42 | $this->assertEquals($exists, true); |
||
| 43 | } |
||
| 44 | |||
| 45 | public function testThumbnailAvatar() |
||
| 46 | { |
||
| 47 | $client = new SleeperClient(); |
||
| 48 | |||
| 49 | $url = $client->avatars()->find('79f5f8ecdd59fe94b668993366552b3a', true); |
||
| 50 | $exists = $this->remoteFileExists($url); |
||
| 51 | |||
| 52 | $this->assertIsBool($exists); |
||
| 53 | $this->assertEquals($exists, true); |
||
| 54 | } |
||
| 55 | |||
| 56 | } |
||
| 57 |