8000 Upgrade to php 8 by laurynas-convertapi · Pull Request #50 · ConvertAPI/convertapi-library-php · GitHub
[go: up one dir, main page]

Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ jobs:
strategy:
matrix:
php-version:
- '5.6'
- '7.0'
- '7.4'
- '8.1'
- '8.2'
- '8.3'
name: PHP ${{ matrix.php-version }} sample
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Icon
.Spotlight-V100
.Trashes
*.sublime-*
.phpunit.result.cache
.env
vendor
composer.lock
bin
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
}
],
"require": {
"php": ">=5.4.0",
"php": ">=8.0",
"ext-curl": "*",
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
"phpunit/phpunit": "~10.0"
},
"config": {
"bin-dir": "bin"
Expand Down
26 changes: 26 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: '3.8'

services:
php81:
image: php:8.1-cli
env_file: .env
volumes:
- .:/app
working_dir: /app
command: bin/phpunit

php82:
image: php:8.2-cli
env_file: .env
volumes:
- .:/app
working_dir: /app
command: bin/phpunit

php83:
image: php:8.3-cli
env_file: .env
volumes:
- .:/app
working_dir: /app
command: bin/phpunit
32 changes: 20 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
<phpunit bootstrap="vendor/autoload.php" colors="true">
<testsuites>
<testsuite name="ConvertApi Test Suite">
<directory suffix="Test.php">./tests/ConvertApi/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">./lib/ConvertApi/</directory>
</whitelist>
</filter>
<?xml version="1.0"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
>
<testsuites>
<testsuite name="ConvertApi Test Suite">
<directory suffix="Test.php">./tests/ConvertApi/</directory>
</testsuite>
</testsuites>
<source restrictDeprecations="true">
<include>
<directory suffix=".php">./lib/ConvertApi/</directory>
</include>
</source>
</phpunit>
20 changes: 10 additions & 10 deletions tests/ConvertApi/ConvertApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

use \ConvertApi\ConvertApi;

class ConvertApiTest extends \PHPUnit_Framework_TestCase
class ConvertApiTest extends \PHPUnit\Framework\TestCase
{
protected $origApiSecret;

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

protected function tearDown()
protected function tearDown(): void
{
// Restore original values
ConvertApi::setApiSecret($this->origApiSecret);
Expand All @@ -44,7 +44,7 @@ public function testGetUser()
{
$user_info = ConvertApi::getUser();

$this->assertInternalType('array', $user_info);
$this->assertIsArray($user_info);
$this->assertArrayHasKey('SecondsLeft', $user_info);
}

Expand All @@ -56,7 +56,7 @@ public function testConvertWithFileUrl()

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

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

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

Expand All @@ -65,7 +65,7 @@ public function testConvertWithFileUrl()
foreach ($files as $file)
unlink($file);

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

public function testConvertWithFilePath()
Expand Down Expand Up @@ -123,7 +123,7 @@ public function testConvertWithSpecifiedSourceFormatAndTimeout()

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

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

public function testConvertWithMultipleFiles()
Expand All @@ -143,7 +143,7 @@ public function testConvertWithUrl()

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

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

public function testChainedConversion()
Expand Down Expand Up @@ -180,7 +180,7 @@ public function testApiError()

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

$this->fail('Expected exception has not been raised.');
} catch (\ConvertApi\Error\Client $e) {
$this->assertContains('timed out', $e->getMessage());
$this->assertStringContainsString('timed out', $e->getMessage());
$this->assertEquals(28, $e->getCode());
}
}
Expand Down
0