diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index b738581..cde0745 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -16,7 +16,7 @@ jobs: git config --global core.eol lf - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -26,7 +26,7 @@ jobs: coverage: none - name: Install PHP dependencies - uses: ramsey/composer-install@v1 + uses: ramsey/composer-install@v3 with: dependency-versions: highest composer-options: "--prefer-dist" @@ -45,7 +45,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -53,8 +53,11 @@ jobs: php-version: 8.2 coverage: none - - name: Install Dependencies - run: composer update --prefer-stable --no-interaction --prefer-dist --no-progress --ansi + - name: Install PHP dependencies + uses: ramsey/composer-install@v3 + with: + dependency-versions: highest + composer-options: "--prefer-dist" - name: Run PHPStan run: vendor/bin/phpstan analyse --no-progress --ansi diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2bfc0ad..44a8dbd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,14 +8,14 @@ jobs: strategy: matrix: os: [ubuntu-latest] - php: ['8.1', '8.2'] - dependency-version: [prefer-lowest, prefer-stable] + php: ['8.4', '8.3', '8.2'] + dependency-version: [highest, lowest] name: PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -29,7 +29,10 @@ jobs: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - name: Install PHP dependencies - run: composer update --${{ matrix.dependency-version }} --no-interaction --no-progress --ansi + uses: ramsey/composer-install@v3 + with: + dependency-versions: ${{ matrix.dependency-version }} + composer-options: --prefer-dist - name: Unit Tests run: ./vendor/bin/phpunit --colors=always diff --git a/composer.json b/composer.json index 8996831..bfd05b5 100644 --- a/composer.json +++ b/composer.json @@ -17,13 +17,13 @@ } ], "require": { - "php": "^8.1" + "php": "^8.2" }, "require-dev": { "ext-json": "*", - "laravel/pint": "^1.15.1", - "phpstan/phpstan": "^1.10.67", - "phpunit/phpunit": "^9.6.19" + "laravel/pint": "^1.21", + "phpstan/phpstan": "^2.0", + "phpunit/phpunit": "^11.0" }, "autoload": { "psr-4": { "Humbug\\SelfUpdate\\": "src/" } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..6c94331 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,19 @@ +parameters: + ignoreErrors: + - + message: '#^Method Humbug\\SelfUpdate\\Strategy\\Sha256Strategy\:\:getCurrentRemoteVersion\(\) never returns bool so it can be removed from the return type\.$#' + identifier: return.unusedType + count: 1 + path: src/Strategy/Sha256Strategy.php + + - + message: '#^Method Humbug\\SelfUpdate\\Strategy\\Sha512Strategy\:\:getCurrentRemoteVersion\(\) never returns bool so it can be removed from the return type\.$#' + identifier: return.unusedType + count: 1 + path: src/Strategy/Sha512Strategy.php + + - + message: '#^Call to function is_bool\(\) with bool will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: src/Updater.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 33c01a5..4b1e170 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,8 +1,7 @@ +includes: + - phpstan-baseline.neon + parameters: level: 5 paths: - src/ - - checkMissingIterableValueType: true - checkGenericClassInNonGenericObjectType: false - reportUnmatchedIgnoredErrors: true diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 54b2cce..dfc60fe 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,16 +3,15 @@ tests - + src - + diff --git a/src/Exception/ExceptionInterface.php b/src/Exception/ExceptionInterface.php index a8375ae..47038ca 100644 --- a/src/Exception/ExceptionInterface.php +++ b/src/Exception/ExceptionInterface.php @@ -1,4 +1,5 @@ getDownloadUrl()); restore_error_handler(); - if (false === $result) { + if ($result === false) { throw new HttpRequestException(sprintf( 'Request to URL failed: %s', $this->getDownloadUrl() diff --git a/src/Strategy/GithubStrategy.php b/src/Strategy/GithubStrategy.php index cf84ef2..3d2d619 100644 --- a/src/Strategy/GithubStrategy.php +++ b/src/Strategy/GithubStrategy.php @@ -1,4 +1,5 @@ remoteUrl); restore_error_handler(); - if (false === $result) { + if ($result === false) { throw new HttpRequestException(sprintf( 'Request to URL failed: %s', $this->remoteUrl @@ -81,11 +78,7 @@ public function download(Updater $updater) file_put_contents($updater->getTempPharFile(), $result); } - /** - * Retrieve the current version available remotely. - * - * @return string|bool - */ + /** {@inheritdoc} */ public function getCurrentRemoteVersion(Updater $updater) { /** Switch remote request errors to HttpRequestExceptions */ @@ -94,7 +87,7 @@ public function getCurrentRemoteVersion(Updater $updater) $package = json_decode(file_get_contents($packageUrl), true); restore_error_handler(); - if (null === $package || json_last_error() !== JSON_ERROR_NONE) { + if ($package === null || json_last_error() !== JSON_ERROR_NONE) { throw new JsonParsingException( 'Error parsing JSON package data' .(function_exists('json_last_error_msg') ? ': '.json_last_error_msg() : '') @@ -126,11 +119,7 @@ public function getCurrentRemoteVersion(Updater $updater) return $this->remoteVersion; } - /** - * Retrieve the current version of the local phar file. - * - * @return string - */ + /** {@inheritdoc} */ public function getCurrentLocalVersion(Updater $updater) { return $this->localVersion; diff --git a/src/Strategy/Sha256Strategy.php b/src/Strategy/Sha256Strategy.php index cc5517d..53d263e 100644 --- a/src/Strategy/Sha256Strategy.php +++ b/src/Strategy/Sha256Strategy.php @@ -1,4 +1,5 @@ getVersionUrl()); restore_error_handler(); - if (false === $version) { + if ($version === false) { throw new HttpRequestException(sprintf( 'Request to URL failed: %s', $this->getVersionUrl() @@ -50,11 +47,7 @@ public function getCurrentRemoteVersion(Updater $updater) return $matches[0]; } - /** - * Retrieve the current version of the local phar file. - * - * @return string - */ + /** {@inheritdoc} */ public function getCurrentLocalVersion(Updater $updater) { return hash_file('sha256', $updater->getLocalPharFile()); diff --git a/src/Strategy/Sha512Strategy.php b/src/Strategy/Sha512Strategy.php index 5278b8d..288a901 100644 --- a/src/Strategy/Sha512Strategy.php +++ b/src/Strategy/Sha512Strategy.php @@ -9,18 +9,14 @@ final class Sha512Strategy extends ShaStrategyAbstract { - /** - * Retrieve the current version available remotely. - * - * @return string|bool - */ + /** {@inheritdoc} */ public function getCurrentRemoteVersion(Updater $updater) { /** Switch remote request errors to HttpRequestExceptions */ set_error_handler([$updater, 'throwHttpRequestException']); $version = file_get_contents($this->getVersionUrl()); restore_error_handler(); - if (false === $version) { + if ($version === false) { throw new HttpRequestException(sprintf( 'Request to URL failed: %s', $this->getVersionUrl() @@ -40,11 +36,7 @@ public function getCurrentRemoteVersion(Updater $updater) return $matches[0]; } - /** - * Retrieve the current version of the local phar file. - * - * @return string - */ + /** {@inheritdoc} */ public function getCurrentLocalVersion(Updater $updater) { return hash_file('sha512', $updater->getLocalPharFile()); diff --git a/src/Strategy/ShaStrategy.php b/src/Strategy/ShaStrategy.php index f2e2a07..8a91996 100644 --- a/src/Strategy/ShaStrategy.php +++ b/src/Strategy/ShaStrategy.php @@ -1,4 +1,5 @@ getVersionUrl()); restore_error_handler(); - if (false === $version) { + if ($version === false) { throw new HttpRequestException(sprintf( 'Request to URL failed: %s', $this->getVersionUrl() @@ -53,11 +50,7 @@ public function getCurrentRemoteVersion(Updater $updater) return $matches[0]; } - /** - * Retrieve the current version of the local phar file. - * - * @return string - */ + /** {@inheritdoc} */ public function getCurrentLocalVersion(Updater $updater) { return sha1_file($updater->getLocalPharFile()); diff --git a/src/Strategy/ShaStrategyAbstract.php b/src/Strategy/ShaStrategyAbstract.php index 2f74039..6213440 100644 --- a/src/Strategy/ShaStrategyAbstract.php +++ b/src/Strategy/ShaStrategyAbstract.php @@ -1,4 +1,5 @@ getPharUrl()); restore_error_handler(); - if (false === $result) { + if ($result === false) { throw new HttpRequestException(sprintf( 'Request to URL failed: %s', $this->getPharUrl() diff --git a/src/Strategy/StrategyInterface.php b/src/Strategy/StrategyInterface.php index 016d17f..e916039 100644 --- a/src/Strategy/StrategyInterface.php +++ b/src/Strategy/StrategyInterface.php @@ -1,4 +1,5 @@ getBackupPath()) { + if ($this->getBackupPath() !== null) { return $this->getBackupPath(); } @@ -444,7 +445,7 @@ protected function getBackupPharFile() protected function getRestorePharFile() { - if (null !== $this->getRestorePath()) { + if ($this->getRestorePath() !== null) { return $this->getRestorePath(); } @@ -536,7 +537,7 @@ protected function validatePhar($phar) protected function cleanupAfterError() { - //@unlink($this->getBackupPharFile()); + // @unlink($this->getBackupPharFile()); @unlink($this->getTempPharFile()); @unlink($this->getTempPubKeyFile()); } diff --git a/src/VersionParser.php b/src/VersionParser.php index 99e76b7..63d28ed 100644 --- a/src/VersionParser.php +++ b/src/VersionParser.php @@ -1,4 +1,5 @@ tmp = sys_get_temp_dir(); $this->files = __DIR__.'/_files'; $this->updater = new Updater($this->files.'/test.phar', false, Updater::STRATEGY_GITHUB); } - public function tearDown(): void + protected function tearDown(): void { $this->deleteTempPhars(); } - public function testConstruction(): void + public function test_construction(): void { $updater = new Updater(null, false, Updater::STRATEGY_GITHUB); $this->assertInstanceOf(GithubStrategy::class, $updater->getStrategy()); } - public function testSetCurrentLocalVersion(): void + public function test_set_current_local_version(): void { $this->updater->getStrategy()->setCurrentLocalVersion('1.0'); $this->assertEquals( @@ -51,7 +52,7 @@ public function testSetCurrentLocalVersion(): void ); } - public function testSetPharName(): void + public function test_set_phar_name(): void { $this->updater->getStrategy()->setPharName('foo.phar'); $this->assertEquals( @@ -60,7 +61,7 @@ public function testSetPharName(): void ); } - public function testSetPackageName(): void + public function test_set_package_name(): void { $this->updater->getStrategy()->setPackageName('foo/bar'); $this->assertEquals( @@ -69,7 +70,7 @@ public function testSetPackageName(): void ); } - public function testSetStability(): void + public function test_set_stability(): void { $this->assertEquals( 'stable', @@ -82,7 +83,7 @@ public function testSetStability(): void ); } - public function testSetStabilityThrowsExceptionOnInvalidStabilityValue(): void + public function test_set_stability_throws_exception_on_invalid_stability_value(): void { $this->expectException(InvalidArgumentException::class); $this->updater->getStrategy()->setStability('foo'); @@ -91,7 +92,7 @@ public function testSetStabilityThrowsExceptionOnInvalidStabilityValue(): void /** * @runInSeparateProcess */ - public function testUpdatePhar(): void + public function test_update_phar(): void { if (! extension_loaded('openssl')) { $this->markTestSkipped('This test requires the openssl extension to run.'); diff --git a/tests/Humbug/Test/SelfUpdate/UpdaterSha256StrategyTest.php b/tests/Humbug/Test/SelfUpdate/UpdaterSha256StrategyTest.php index 6887815..966cd20 100644 --- a/tests/Humbug/Test/SelfUpdate/UpdaterSha256StrategyTest.php +++ b/tests/Humbug/Test/SelfUpdate/UpdaterSha256StrategyTest.php @@ -1,4 +1,5 @@ tmp = sys_get_temp_dir(); $this->files = __DIR__.'/_files'; $this->updater = new Updater($this->files.'/test.phar', true, Updater::STRATEGY_SHA256); } - public function teardown(): void + protected function teardown(): void { $this->deleteTempPhars(); } - public function testConstruction(): void + public function test_construction(): void { $updater = new Updater(null, false, Updater::STRATEGY_SHA256); $this->assertInstanceOf(Sha256Strategy::class, $updater->getStrategy()); } - public function testGetCurrentLocalVersion(): void + public function test_get_current_local_version(): void { $this->assertEquals( 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', @@ -51,7 +52,7 @@ public function testGetCurrentLocalVersion(): void ); } - public function testSetPharUrlWithUrl(): void + public function test_set_phar_url_with_url(): void { $this->updater->getStrategy()->setPharUrl('http://www.example.com'); $this->assertEquals('http://www.example.com', $this->updater->getStrategy()->getPharUrl()); @@ -60,13 +61,13 @@ public function testSetPharUrlWithUrl(): void $this->assertEquals('https://www.example.com', $this->updater->getStrategy()->getPharUrl()); } - public function testSetPharUrlThrowsExceptionOnInvalidUrl(): void + public function test_set_phar_url_throws_exception_on_invalid_url(): void { $this->expectException(InvalidArgumentException::class); $this->updater->getStrategy()->setPharUrl('silly:///home/padraic'); } - public function testSetVersionUrlWithUrl(): void + public function test_set_version_url_with_url(): void { $this->updater->getStrategy()->setVersionUrl('http://www.example.com'); $this->assertEquals('http://www.example.com', $this->updater->getStrategy()->getVersionUrl()); @@ -75,13 +76,13 @@ public function testSetVersionUrlWithUrl(): void $this->assertEquals('https://www.example.com', $this->updater->getStrategy()->getVersionUrl()); } - public function testSetVersionUrlThrowsExceptionOnInvalidUrl(): void + public function test_set_version_url_throws_exception_on_invalid_url(): void { $this->expectException(InvalidArgumentException::class); $this->updater->getStrategy()->setVersionUrl('silly:///home/padraic'); } - public function testCanDetectNewRemoteVersionAndStoreVersions(): void + public function test_can_detect_new_remote_version_and_store_versions(): void { $this->updater->getStrategy()->setVersionUrl('file://'.$this->files.'/good.sha256.version'); $this->assertTrue($this->updater->hasUpdate()); @@ -90,12 +91,12 @@ public function testCanDetectNewRemoteVersionAndStoreVersions(): void $this->updater->getOldVersion() ); $this->assertEquals( - 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b858', //5 => 8 + 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b858', // 5 => 8 $this->updater->getNewVersion() ); } - public function testThrowsExceptionOnEmptyRemoteVersion(): void + public function test_throws_exception_on_empty_remote_version(): void { $this->expectException(HttpRequestException::class); $this->expectExceptionMessage('Version request returned empty response'); @@ -103,7 +104,7 @@ public function testThrowsExceptionOnEmptyRemoteVersion(): void $this->assertTrue($this->updater->hasUpdate()); } - public function testThrowsExceptionOnInvalidRemoteVersion(): void + public function test_throws_exception_on_invalid_remote_version(): void { $this->expectException(HttpRequestException::class); $this->expectExceptionMessage('Version request returned incorrectly formatted response'); @@ -114,7 +115,7 @@ public function testThrowsExceptionOnInvalidRemoteVersion(): void /** * @runInSeparateProcess */ - public function testUpdatePhar(): void + public function test_update_phar(): void { $this->createTestPharAndKey(); $this->assertEquals('old', $this->getPharOutput($this->tmp.'/old.phar')); diff --git a/tests/Humbug/Test/SelfUpdate/UpdaterSha512StrategyTest.php b/tests/Humbug/Test/SelfUpdate/UpdaterSha512StrategyTest.php index dbf520c..e2d0aed 100644 --- a/tests/Humbug/Test/SelfUpdate/UpdaterSha512StrategyTest.php +++ b/tests/Humbug/Test/SelfUpdate/UpdaterSha512StrategyTest.php @@ -1,4 +1,5 @@ tmp = sys_get_temp_dir(); $this->files = __DIR__.'/_files'; $this->updater = new Updater($this->files.'/test.phar', true, Updater::STRATEGY_SHA512); } - public function teardown(): void + protected function teardown(): void { $this->deleteTempPhars(); } - public function testConstruction(): void + public function test_construction(): void { $updater = new Updater(null, false, Updater::STRATEGY_SHA512); $this->assertInstanceOf(Sha512Strategy::class, $updater->getStrategy()); } - public function testGetCurrentLocalVersion(): void + public function test_get_current_local_version(): void { $this->assertEquals( 'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e', @@ -51,7 +52,7 @@ public function testGetCurrentLocalVersion(): void ); } - public function testSetPharUrlWithUrl(): void + public function test_set_phar_url_with_url(): void { $this->updater->getStrategy()->setPharUrl('http://www.example.com'); $this->assertEquals('http://www.example.com', $this->updater->getStrategy()->getPharUrl()); @@ -60,13 +61,13 @@ public function testSetPharUrlWithUrl(): void $this->assertEquals('https://www.example.com', $this->updater->getStrategy()->getPharUrl()); } - public function testSetPharUrlThrowsExceptionOnInvalidUrl(): void + public function test_set_phar_url_throws_exception_on_invalid_url(): void { $this->expectException(InvalidArgumentException::class); $this->updater->getStrategy()->setPharUrl('silly:///home/padraic'); } - public function testSetVersionUrlWithUrl(): void + public function test_set_version_url_with_url(): void { $this->updater->getStrategy()->setVersionUrl('http://www.example.com'); $this->assertEquals('http://www.example.com', $this->updater->getStrategy()->getVersionUrl()); @@ -75,13 +76,13 @@ public function testSetVersionUrlWithUrl(): void $this->assertEquals('https://www.example.com', $this->updater->getStrategy()->getVersionUrl()); } - public function testSetVersionUrlThrowsExceptionOnInvalidUrl(): void + public function test_set_version_url_throws_exception_on_invalid_url(): void { $this->expectException(InvalidArgumentException::class); $this->updater->getStrategy()->setVersionUrl('silly:///home/padraic'); } - public function testCanDetectNewRemoteVersionAndStoreVersions(): void + public function test_can_detect_new_remote_version_and_store_versions(): void { $this->updater->getStrategy()->setVersionUrl('file://'.$this->files.'/good.sha512.version'); $this->assertTrue($this->updater->hasUpdate()); @@ -95,7 +96,7 @@ public function testCanDetectNewRemoteVersionAndStoreVersions(): void ); } - public function testThrowsExceptionOnEmptyRemoteVersion(): void + public function test_throws_exception_on_empty_remote_version(): void { $this->expectException(HttpRequestException::class); $this->expectExceptionMessage('Version request returned empty response'); @@ -103,7 +104,7 @@ public function testThrowsExceptionOnEmptyRemoteVersion(): void $this->assertTrue($this->updater->hasUpdate()); } - public function testThrowsExceptionOnInvalidRemoteVersion(): void + public function test_throws_exception_on_invalid_remote_version(): void { $this->expectException(HttpRequestException::class); $this->expectExceptionMessage('Version request returned incorrectly formatted response'); @@ -114,7 +115,7 @@ public function testThrowsExceptionOnInvalidRemoteVersion(): void /** * @runInSeparateProcess */ - public function testUpdatePhar(): void + public function test_update_phar(): void { $this->createTestPharAndKey(); $this->assertEquals('old', $this->getPharOutput($this->tmp.'/old.phar')); diff --git a/tests/Humbug/Test/SelfUpdate/UpdaterTest.php b/tests/Humbug/Test/SelfUpdate/UpdaterTest.php index e14425b..8098d7f 100644 --- a/tests/Humbug/Test/SelfUpdate/UpdaterTest.php +++ b/tests/Humbug/Test/SelfUpdate/UpdaterTest.php @@ -1,4 +1,5 @@ tmp = sys_get_temp_dir(); $this->files = __DIR__.'/_files'; @@ -35,12 +36,12 @@ public function setUp(): void $this->updater = new Updater($this->files.'/test.phar'); } - public function tearDown(): void + protected function tearDown(): void { $this->deleteTempPhars(); } - public function testConstruction(): void + public function test_construction(): void { // with key $updater = new Updater($this->files.'/test.phar'); @@ -60,19 +61,19 @@ public function testConstruction(): void ); } - public function testConstructorThrowsExceptionIfPubKeyNotExistsButFlagTrue(): void + public function test_constructor_throws_exception_if_pub_key_not_exists_but_flag_true(): void { $this->expectException(RuntimeException::class); new Updater($this->files.'/test-nopubkey.phar'); } - public function testConstructorAncilliaryValues(): void + public function test_constructor_ancilliary_values(): void { $this->assertEquals('test', $this->updater->getLocalPharFileBasename()); $this->assertEquals($this->updater->getTempDirectory(), $this->files); } - public function testSetPharUrlWithUrl(): void + public function test_set_phar_url_with_url(): void { $this->updater->getStrategy()->setPharUrl('http://www.example.com'); $this->assertEquals('http://www.example.com', $this->updater->getStrategy()->getPharUrl()); @@ -81,13 +82,13 @@ public function testSetPharUrlWithUrl(): void $this->assertEquals('https://www.example.com', $this->updater->getStrategy()->getPharUrl()); } - public function testSetPharUrlThrowsExceptionOnInvalidUrl(): void + public function test_set_phar_url_throws_exception_on_invalid_url(): void { $this->expectException(InvalidArgumentException::class); $this->updater->getStrategy()->setPharUrl('silly:///home/padraic'); } - public function testSetVersionUrlWithUrl(): void + public function test_set_version_url_with_url(): void { $this->updater->getStrategy()->setVersionUrl('http://www.example.com'); $this->assertEquals('http://www.example.com', $this->updater->getStrategy()->getVersionUrl()); @@ -96,13 +97,13 @@ public function testSetVersionUrlWithUrl(): void $this->assertEquals('https://www.example.com', $this->updater->getStrategy()->getVersionUrl()); } - public function testSetVersionUrlThrowsExceptionOnInvalidUrl(): void + public function test_set_version_url_throws_exception_on_invalid_url(): void { $this->expectException(InvalidArgumentException::class); $this->updater->getStrategy()->setVersionUrl('silly:///home/padraic'); } - public function testCanDetectNewRemoteVersionAndStoreVersions(): void + public function test_can_detect_new_remote_version_and_store_versions(): void { $this->updater->getStrategy()->setVersionUrl('file://'.$this->files.'/good.version'); $this->assertTrue($this->updater->hasUpdate()); @@ -110,7 +111,7 @@ public function testCanDetectNewRemoteVersionAndStoreVersions(): void $this->assertEquals('1af1b9c94dea1ff337587bfa9109f1dad1ec7b9b', $this->updater->getNewVersion()); } - public function testThrowsExceptionOnEmptyRemoteVersion(): void + public function test_throws_exception_on_empty_remote_version(): void { $this->expectException(HttpRequestException::class); $this->expectExceptionMessage('Version request returned empty response'); @@ -118,7 +119,7 @@ public function testThrowsExceptionOnEmptyRemoteVersion(): void $this->assertTrue($this->updater->hasUpdate()); } - public function testThrowsExceptionOnInvalidRemoteVersion(): void + public function test_throws_exception_on_invalid_remote_version(): void { $this->expectException(HttpRequestException::class); $this->expectExceptionMessage('Version request returned incorrectly formatted response'); @@ -129,7 +130,7 @@ public function testThrowsExceptionOnInvalidRemoteVersion(): void /** * @runInSeparateProcess */ - public function testUpdatePhar(): void + public function test_update_phar(): void { if (! extension_loaded('openssl')) { $this->markTestSkipped('This test requires the openssl extension to run.'); @@ -148,9 +149,9 @@ public function testUpdatePhar(): void /** * @runInSeparateProcess */ - public function testUpdatePharFailsIfCurrentPublicKeyEmpty(): void + public function test_update_phar_fails_if_current_public_key_empty(): void { - //$this->markTestSkipped('Segmentation fault at present under PHP'); + // $this->markTestSkipped('Segmentation fault at present under PHP'); copy($this->files.'/build/badkey.phar', $this->tmp.'/old.phar'); chmod($this->tmp.'/old.phar', 0755); copy($this->files.'/build/badkey.phar.pubkey', $this->tmp.'/old.phar.pubkey'); @@ -166,7 +167,7 @@ public function testUpdatePharFailsIfCurrentPublicKeyEmpty(): void /** * @runInSeparateProcess */ - public function testUpdatePharFailsIfCurrentPublicKeyInvalid(): void + public function test_update_phar_fails_if_current_public_key_invalid(): void { $this->markTestIncomplete('Segmentation fault at present under PHP'); /** Should be similar to testUpdatePharFailsIfCurrentPublicKeyEmpty with @@ -176,7 +177,7 @@ public function testUpdatePharFailsIfCurrentPublicKeyInvalid(): void /** * @runInSeparateProcess */ - public function testUpdatePharFailsOnExpectedSignatureMismatch(): void + public function test_update_phar_fails_on_expected_signature_mismatch(): void { if (! extension_loaded('openssl')) { $this->markTestSkipped('This test requires the openssl extension to run.'); @@ -197,7 +198,7 @@ public function testUpdatePharFailsOnExpectedSignatureMismatch(): void /** * @runInSeparateProcess */ - public function testUpdatePharFailsIfDownloadPharIsUnsignedWhenExpected(): void + public function test_update_phar_fails_if_download_phar_is_unsigned_when_expected(): void { $this->createTestPharAndKey(); $updater = new Updater($this->tmp.'/old.phar'); @@ -209,7 +210,7 @@ public function testUpdatePharFailsIfDownloadPharIsUnsignedWhenExpected(): void $updater->update(); } - public function testSetBackupPathSetsThePathWhenTheDirectoryExistsAndIsWriteable(): void + public function test_set_backup_path_sets_the_path_when_the_directory_exists_and_is_writeable(): void { $this->createTestPharAndKey(); $updater = new Updater($this->tmp.'/old.phar'); @@ -218,7 +219,7 @@ public function testSetBackupPathSetsThePathWhenTheDirectoryExistsAndIsWriteable $this->assertEquals($this->tmp.'/backup.phar', $res); } - public function testSetRestorePathSetsThePathWhenTheDirectoryExistsAndIsWriteable(): void + public function test_set_restore_path_sets_the_path_when_the_directory_exists_and_is_writeable(): void { $this->createTestPharAndKey(); $updater = new Updater($this->tmp.'/old.phar'); @@ -230,7 +231,7 @@ public function testSetRestorePathSetsThePathWhenTheDirectoryExistsAndIsWriteabl /** * Custom Strategies. */ - public function testCanSetCustomStrategyObjects(): void + public function test_can_set_custom_strategy_objects(): void { $this->updater->setStrategyObject(new FooStrategy); $this->assertInstanceOf(FooStrategy::class, $this->updater->getStrategy()); @@ -263,15 +264,9 @@ private function createTestPharAndKey(): void class FooStrategy implements StrategyInterface { - public function download(Updater $updater) - { - } + public function download(Updater $updater) {} - public function getCurrentRemoteVersion(Updater $updater) - { - } + public function getCurrentRemoteVersion(Updater $updater) {} - public function getCurrentLocalVersion(Updater $updater) - { - } + public function getCurrentLocalVersion(Updater $updater) {} } diff --git a/tests/Humbug/Test/SelfUpdate/VersionParserTest.php b/tests/Humbug/Test/SelfUpdate/VersionParserTest.php index 034d95f..ab8f363 100644 --- a/tests/Humbug/Test/SelfUpdate/VersionParserTest.php +++ b/tests/Humbug/Test/SelfUpdate/VersionParserTest.php @@ -1,4 +1,5 @@ assertFalse($parser->getMostRecentStable()); } - public function testShouldSelectMostRecentVersionFromStandardSelection(): void + public function test_should_select_most_recent_version_from_standard_selection(): void { $versions = ['1.0.0', '1.0.1', '1.1.0']; $parser = new VersionParser($versions); $this->assertSame('1.1.0', $parser->getMostRecentStable()); } - public function testShouldSelectMostRecentVersionFromMixedSelection(): void + public function test_should_select_most_recent_version_from_mixed_selection(): void { $versions = ['1.0.0', '1.0.1', '1.1.0', '1.2.0a', '1.2.0b', '1.1.0rc']; $parser = new VersionParser($versions); $this->assertSame('1.1.0', $parser->getMostRecentStable()); } - public function testShouldSelectMostRecentVersionFromPrefixedSelection(): void + public function test_should_select_most_recent_version_from_prefixed_selection(): void { $versions = ['v1.0.0', 'v1.0.1', 'v1.1.0']; $parser = new VersionParser($versions); $this->assertSame('v1.1.0', $parser->getMostRecentStable()); } - public function testShouldSelectMostRecentVersionFromPartlyPrefixedSelection(): void + public function test_should_select_most_recent_version_from_partly_prefixed_selection(): void { $versions = ['v1.0.0', 'v1.0.1', '1.1.0']; $parser = new VersionParser($versions); $this->assertSame('1.1.0', $parser->getMostRecentStable()); } - public function testShouldSelectMostRecentVersionFromPatchLevels(): void + public function test_should_select_most_recent_version_from_patch_levels(): void { $versions = ['1.0.0', '1.0.0-pl2', '1.0.0-pl3', '1.0.0-pl1']; $parser = new VersionParser($versions); $this->assertSame('1.0.0-pl3', $parser->getMostRecentStable()); } - public function testShouldSelectMostRecentVersionFromPatchLevels2(): void + public function test_should_select_most_recent_version_from_patch_levels2(): void { $versions = ['1.0.0', '1.0.0pl2', '1.0.0pl3', '1.0.0pl1']; $parser = new VersionParser($versions); @@ -69,21 +70,21 @@ public function testShouldSelectMostRecentVersionFromPatchLevels2(): void // Unstable - public function testShouldSelectNothingFromUnstablesIfUnstableRequested(): void + public function test_should_select_nothing_from_unstables_if_unstable_requested(): void { $versions = ['1.0.0', '1.0.1', '1.1.0']; $parser = new VersionParser($versions); $this->assertFalse($parser->getMostRecentUnstable()); } - public function testShouldSelectNothingFromStablesOrDevsIfUnstableRequested(): void + public function test_should_select_nothing_from_stables_or_devs_if_unstable_requested(): void { $versions = ['1.0.0', '1.0.1', '1.1.0-dev', 'dev-1.1.1']; $parser = new VersionParser($versions); $this->assertFalse($parser->getMostRecentUnstable()); } - public function testShouldSelectMostRecentUnstableVersionFromStandardSelection(): void + public function test_should_select_most_recent_unstable_version_from_standard_selection(): void { $versions = ['1.0.0a', '1.0.0alpha', '1.0.0-dev', 'dev-1.0.0', '1.0.0b', '1.0.0beta', '1.0.0rc', '1.0.0RC', ]; @@ -91,28 +92,28 @@ public function testShouldSelectMostRecentUnstableVersionFromStandardSelection() $this->assertSame('1.0.0rc', $parser->getMostRecentUnstable()); } - public function testShouldSelectMostRecentUnstableVersionFromMixedSelection(): void + public function test_should_select_most_recent_unstable_version_from_mixed_selection(): void { $versions = ['1.0.0', '1.0.1', '1.1.0', '1.2.0a', '1.2.0b', '1.1.0rc']; $parser = new VersionParser($versions); $this->assertSame('1.2.0b', $parser->getMostRecentUnstable()); } - public function testShouldSelectMostRecentUnstableVersionFromPrefixedSelection(): void + public function test_should_select_most_recent_unstable_version_from_prefixed_selection(): void { $versions = ['v1.0.0b', 'v1.0.1', 'v1.1.0']; $parser = new VersionParser($versions); $this->assertSame('v1.0.0b', $parser->getMostRecentUnstable()); } - public function testShouldSelectMostRecentUnstableVersionFromPartlyPrefixedSelection(): void + public function test_should_select_most_recent_unstable_version_from_partly_prefixed_selection(): void { $versions = ['v1.0.0b', 'v1.0.0a', '1.1.0a']; $parser = new VersionParser($versions); $this->assertSame('1.1.0a', $parser->getMostRecentUnstable()); } - public function testShouldSelectMostRecentUnstableFromVaryingNumeralCounts(): void + public function test_should_select_most_recent_unstable_from_varying_numeral_counts(): void { $versions = ['1.0-dev', '1.0.0-alpha1']; $parser = new VersionParser($versions); @@ -121,7 +122,7 @@ public function testShouldSelectMostRecentUnstableFromVaryingNumeralCounts(): vo // All versions (ignoring stability) - public function testShouldSelectMostRecentIgnoringStabilityExceptDevFromPrefixedSelection(): void + public function test_should_select_most_recent_ignoring_stability_except_dev_from_prefixed_selection(): void { $versions = ['v1.0.0b', 'v1.0.1', 'v1.1.0a', 'v1.2.0-dev']; $parser = new VersionParser($versions); @@ -130,7 +131,7 @@ public function testShouldSelectMostRecentIgnoringStabilityExceptDevFromPrefixed // Basic Version Category Checks - public function testIsStable(): void + public function test_is_stable(): void { $parser = new VersionParser; $this->assertTrue($parser->isStable('1.0.0')); @@ -139,7 +140,7 @@ public function testIsStable(): void $this->assertFalse($parser->isStable('1.0.0-alpha1-5-g5b46ad8')); } - public function testIsPreRelease(): void + public function test_is_pre_release(): void { $parser = new VersionParser; $this->assertFalse($parser->isPreRelease('1.0.0')); @@ -148,7 +149,7 @@ public function testIsPreRelease(): void $this->assertFalse($parser->isPreRelease('1.0.0-alpha1-5-g5b46ad8')); } - public function testIsUnstable(): void + public function test_is_unstable(): void { $parser = new VersionParser; $this->assertFalse($parser->isUnstable('1.0.0')); @@ -157,7 +158,7 @@ public function testIsUnstable(): void $this->assertTrue($parser->isUnstable('1.0.0-alpha1-5-g5b46ad8')); } - public function testIsDevelopment(): void + public function test_is_development(): void { $parser = new VersionParser; $this->assertFalse($parser->isDevelopment('1.0.0')); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 6abcefb..47a2608 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,4 +1,5 @@