Skip to content

Commit 88db9e0

Browse files
Upgrade to php 8 (#50)
* Enable testing with php8.3 * Update phpunit * Update phpunit * Restrict deprecations * Add docker compose file * Display depreactions
1 parent 72dc773 commit 88db9e0

File tree

6 files changed

+63
-27
lines changed

6 files changed

+63
-27
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ jobs:
66
strategy:
77
matrix:
88
php-version:
9-
- '5.6'
10-
- '7.0'
11-
- '7.4'
9+
- '8.1'
10+
- '8.2'
11+
- '8.3'
1212
name: PHP ${{ matrix.php-version }} sample
1313
steps:
1414
- uses: actions/checkout@v3

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Icon
77
.Spotlight-V100
88
.Trashes
99
*.sublime-*
10+
.phpunit.result.cache
11+
.env
1012
vendor
1113
composer.lock
1214
bin

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
}
1313
],
1414
"require": {
15-
"php": ">=5.4.0",
15+
"php": ">=8.0",
1616
"ext-curl": "*",
1717
"ext-json": "*"
1818
},
1919
"require-dev": {
20-
"phpunit/phpunit": "~4.0"
20+
"phpunit/phpunit": "~10.0"
2121
},
2222
"config": {
2323
"bin-dir": "bin"

docker-compose.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: '3.8'
2+
3+
services:
4+
php81:
5+
image: php:8.1-cli
6+
env_file: .env
7+
volumes:
8+
- .:/app
9+
working_dir: /app
10+
command: bin/phpunit
11+
12+
php82:
13+
image: php:8.2-cli
14+
env_file: .env
15+
volumes:
16+
- .:/app
17+
working_dir: /app
18+
command: bin/phpunit
19+
20+
php83:
21+
image: php:8.3-cli
22+
env_file: .env
23+
volumes:
24+
- .:/app
25+
working_dir: /app
26+
command: bin/phpunit

phpunit.xml.dist

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1-
<phpunit bootstrap="vendor/autoload.php" colors="true">
2-
<testsuites>
3-
<testsuite name="ConvertApi Test Suite">
4-
<directory suffix="Test.php">./tests/ConvertApi/</directory>
5-
</testsuite>
6-
</testsuites>
7-
8-
<filter>
9-
<whitelist>
10-
<directory suffix=".php">./lib/ConvertApi/</directory>
11-
</whitelist>
12-
</filter>
1+
<?xml version="1.0"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
5+
bootstrap="vendor/autoload.php"
6+
displayDetailsOnTestsThatTriggerDeprecations="true"
7+
displayDetailsOnTestsThatTriggerErrors="true"
8+
displayDetailsOnTestsThatTriggerNotices="true"
9+
displayDetailsOnTestsThatTriggerWarnings="true"
10+
>
11+
<testsuites>
12+
<testsuite name="ConvertApi Test Suite">
13+
<directory suffix="Test.php">./tests/ConvertApi/</directory>
14+
</testsuite>
15+
</testsuites>
16+
<source restrictDeprecations="true">
17+
<include>
18+
<directory suffix=".php">./lib/ConvertApi/</directory>
19+
</include>
20+
</source>
1321
</phpunit>

tests/ConvertApi/ConvertApiTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
use \ConvertApi\ConvertApi;
66

7-
class ConvertApiTest extends \PHPUnit_Framework_TestCase
7+
class ConvertApiTest extends \PHPUnit\Framework\TestCase
88
{
99
protected $origApiSecret;
1010

11-
protected function setUp()
11+
protected function setUp(): void
1212
{
1313
// Save original values so that we can restore them after running tests
1414
$this->origApiSecret = ConvertApi::getApiSecret();
@@ -18,7 +18,7 @@ protected function setUp()
1818
ConvertApi::setApiSecret(getenv('CONVERT_API_SECRET'));
1919
}
2020

21-
protected function tearDown()
21+
protected function tearDown(): void
2222
{
2323
// Restore original values
2424
ConvertApi::setApiSecret($this->origApiSecret);
@@ -44,7 +44,7 @@ public function testGetUser()
4444
{
4545
$user_info = ConvertApi::getUser();
4646

47-
$this->assertInternalType('array', $user_info);
47+
$this->assertIsArray($user_info);
4848
$this->assertArrayHasKey('SecondsLeft', $user_info);
4949
}
5050

@@ -56,7 +56,7 @@ public function testConvertWithFileUrl()
5656

5757
$this->assertInstanceOf('\ConvertApi\Result', $result);
5858

59-
$this->assertInternalType('int', $result->getConversionCost());
59+
$this->assertIsInt($result->getConversionCost());
6060

6161
$files = $result->saveFiles(sys_get_temp_dir());
6262

@@ -65,7 +65,7 @@ public function testConvertWithFileUrl()
6565
foreach ($files as $file)
6666
unlink($file);
6767

68-
$this->assertInternalType('string', $result->getFile()->getContents());
68+
$this->assertIsString($result->getFile()->getContents());
6969
}
7070

7171
public function testConvertWithFilePath()
@@ -123,7 +123,7 @@ public function testConvertWithSpecifiedSourceFormatAndTimeout()
123123

124124
$result = ConvertApi::convert('pdf', $params, 'web', 100);
125125

126-
$this->assertInternalType('int', $result->getFile()->getFileSize());
126+
$this->assertIsInt($result->getFile()->getFileSize());
127127
}
128128

129129
public function testConvertWithMultipleFiles()
@@ -143,7 +143,7 @@ public function testConvertWithUrl()
143143

144144
$result = ConvertApi::convert('pdf', $params, 'web');
145145

146-
$this->assertInternalType('int', $result->getFile()->getFileSize());
146+
$this->assertIsInt($result->getFile()->getFileSize());
147147
}
148148

149149
public function testChainedConversion()
@@ -180,7 +180,7 @@ public function testApiError()
180180

181181
$this->fail('Expected exception has not been raised.');
182182
} catch (\ConvertApi\Error\Api $e) {
183-
$this->assertContains('Parameter validation error.', $e->getMessage());
183+
$this->assertStringContainsString('Parameter validation error.', $e->getMessage());
184184
$this->assertEquals(4000, $e->getCode());
185185
}
186186
}
@@ -196,7 +196,7 @@ public function testClientError()
196196

197197
$this->fail('Expected exception has not been raised.');
198198
} catch (\ConvertApi\Error\Client $e) {
199-
$this->assertContains('timed out', $e->getMessage());
199+
$this->assertStringContainsString('timed out', $e->getMessage());
200200
$this->assertEquals(28, $e->getCode());
201201
}
202202
}

0 commit comments

Comments
 (0)