From 2c8456b3db13214f7625c859c2b7146bea0b4e6f Mon Sep 17 00:00:00 2001 From: Laurynas Butkus Date: Fri, 16 Feb 2024 12:43:29 +0100 Subject: [PATCH 1/6] Enable testing with php8.3 --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 01ee669..43c3cf0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,6 +9,7 @@ jobs: - '5.6' - '7.0' - '7.4' + - '8.3' name: PHP ${{ matrix.php-version }} sample steps: - uses: actions/checkout@v3 From 005c7394470b576e09fef541f09303c43f89cd34 Mon Sep 17 00:00:00 2001 From: Laurynas Butkus Date: Fri, 16 Feb 2024 12:49:16 +0100 Subject: [PATCH 2/6] Update phpunit --- .github/workflows/main.yml | 2 -- composer.json | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 43c3cf0..31198a7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,8 +6,6 @@ jobs: strategy: matrix: php-version: - - '5.6' - - '7.0' - '7.4' - '8.3' name: PHP ${{ matrix.php-version }} sample diff --git a/composer.json b/composer.json index 9da6e1f..545fdf6 100644 --- a/composer.json +++ b/composer.json @@ -12,12 +12,12 @@ } ], "require": { - "php": ">=5.4.0", + "php": ">=7.3.0", "ext-curl": "*", "ext-json": "*" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "phpunit/phpunit": "~9.0" }, "config": { "bin-dir": "bin" From d3a6c1d2c6dffe9cc04e94b2f8837106c4bab00d Mon Sep 17 00:00:00 2001 From: Laurynas Butkus Date: Fri, 16 Feb 2024 13:23:32 +0100 Subject: [PATCH 3/6] Update phpunit --- .github/workflows/main.yml | 3 ++- .gitignore | 1 + composer.json | 4 ++-- phpunit.xml.dist | 24 ++++++++++++------------ tests/ConvertApi/ConvertApiTest.php | 20 ++++++++++---------- 5 files changed, 27 insertions(+), 25 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 31198a7..784edfb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,8 @@ jobs: strategy: matrix: php-version: - - '7.4' + - '8.1' + - '8.2' - '8.3' name: PHP ${{ matrix.php-version }} sample steps: diff --git a/.gitignore b/.gitignore index 460a86c..2009265 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ Icon .Spotlight-V100 .Trashes *.sublime-* +.phpunit.result.cache vendor composer.lock bin \ No newline at end of file diff --git a/composer.json b/composer.json index 545fdf6..dd0fa80 100644 --- a/composer.json +++ b/composer.json @@ -12,12 +12,12 @@ } ], "require": { - "php": ">=7.3.0", + "php": ">=8.1.0", "ext-curl": "*", "ext-json": "*" }, "require-dev": { - "phpunit/phpunit": "~9.0" + "phpunit/phpunit": "~10.0" }, "config": { "bin-dir": "bin" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 1010532..0891051 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,13 +1,13 @@ - - - - ./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()); } } From 7fbe05fbe7e1884575e3ed4f7e50a1ed9f380ebc Mon Sep 17 00:00:00 2001 From: Laurynas Butkus Date: Fri, 16 Feb 2024 13:34:58 +0100 Subject: [PATCH 4/6] Restrict deprecations --- composer.json | 2 +- phpunit.xml.dist | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index dd0fa80..740eba5 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": ">=8.1.0", + "php": ">=8.0", "ext-curl": "*", "ext-json": "*" }, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0891051..a870e98 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,11 +1,15 @@ - + ./tests/ConvertApi/ - + ./lib/ConvertApi/ From ba5a0e31208637e369f30edbe212154074d3e07d Mon Sep 17 00:00:00 2001 From: Laurynas Butkus Date: Fri, 16 Feb 2024 14:16:03 +0100 Subject: [PATCH 5/6] Add docker compose file --- .gitignore | 1 + docker-compose.yml | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore index 2009265..7cda81c 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ Icon .Trashes *.sublime-* .phpunit.result.cache +.env vendor composer.lock bin \ No newline at end of file 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 From 49a720cb54916063c1dd20f999afd1f91f6cab5c Mon Sep 17 00:00:00 2001 From: Laurynas Butkus Date: Fri, 16 Feb 2024 14:28:26 +0100 Subject: [PATCH 6/6] Display depreactions --- phpunit.xml.dist | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a870e98..0e55e53 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,6 +3,10 @@ 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" >