diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 01ee669..784edfb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/.gitignore b/.gitignore index 460a86c..7cda81c 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ Icon .Spotlight-V100 .Trashes *.sublime-* +.phpunit.result.cache +.env vendor composer.lock bin \ No newline at end of file diff --git a/composer.json b/composer.json index 9da6e1f..740eba5 100644 --- a/composer.json +++ b/composer.json @@ -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" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..192fe03 --- /dev/null +++ b/docker-compose.yml @@ -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 diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 1010532..0e55e53 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,13 +1,21 @@ - - - - ./tests/ConvertApi/ - - - - - - ./lib/ConvertApi/ - - + + + + + ./tests/ConvertApi/ + + + + + ./lib/ConvertApi/ + + diff --git a/tests/ConvertApi/ConvertApiTest.php b/tests/ConvertApi/ConvertApiTest.php index 3cb76f5..0525798 100644 --- a/tests/ConvertApi/ConvertApiTest.php +++ b/tests/ConvertApi/ConvertApiTest.php @@ -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(); @@ -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); @@ -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); } @@ -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()); @@ -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() @@ -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() @@ -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() @@ -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()); } } @@ -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()); } }