diff options
| author | 2023-04-17 08:30:21 +0200 | |
|---|---|---|
| committer | 2023-04-17 08:30:21 +0200 | |
| commit | f3760f138dcbaf7a2190336a0378cf1b2190c9f5 (patch) | |
| tree | 6fac8fbf9efd7aa74a8e3970ab70ccf85287b2cd /tests/lib | |
| parent | 41fa4e746df8c2e2399ed753b4994ca85cb21358 (diff) | |
Complete PHPStan Level 6 (#5305)
* Complete PHPStan Level 6
Fix https://github.com/FreshRSS/FreshRSS/issues/4112
And initiate PHPStan Level 7
* PHPStan Level 6 for tests
* Use phpstan/phpstan-phpunit
* Update to PHPStan version 1.10
* Fix mixed bug
* Fix mixed return bug
* Fix paginator bug
* Fix FreshRSS_UserConfiguration
* A couple more Minz_Configuration bug fixes
* A few trivial PHPStan Level 7 fixes
* A few more simple PHPStan Level 7
* More files passing PHPStan Level 7
Add interface to replace removed class from https://github.com/FreshRSS/FreshRSS/pull/5251
* A few more PHPStan Level 7 preparations
* A few last details
Diffstat (limited to 'tests/lib')
| -rw-r--r-- | tests/lib/CssXPath/CssXPathTest.php | 2 | ||||
| -rw-r--r-- | tests/lib/Minz/MigratorTest.php | 46 | ||||
| -rw-r--r-- | tests/lib/PHPMailer/PHPMailerTest.php | 2 |
3 files changed, 25 insertions, 25 deletions
diff --git a/tests/lib/CssXPath/CssXPathTest.php b/tests/lib/CssXPath/CssXPathTest.php index c6fe24fc8..8d5a943ec 100644 --- a/tests/lib/CssXPath/CssXPathTest.php +++ b/tests/lib/CssXPath/CssXPathTest.php @@ -2,7 +2,7 @@ class CssXPathTest extends PHPUnit\Framework\TestCase { - public function testCssXPathTranslatorClassExists() { + public function testCssXPathTranslatorClassExists(): void { $this->assertTrue(class_exists('Gt\\CssXPath\\Translator')); } } diff --git a/tests/lib/Minz/MigratorTest.php b/tests/lib/Minz/MigratorTest.php index bcee45204..bd30ba87e 100644 --- a/tests/lib/Minz/MigratorTest.php +++ b/tests/lib/Minz/MigratorTest.php @@ -4,7 +4,7 @@ use PHPUnit\Framework\TestCase; class MigratorTest extends TestCase { - public function testAddMigration() { + public function testAddMigration(): void { $migrator = new Minz_Migrator(); $migrator->addMigration('foo', function () { @@ -17,7 +17,7 @@ class MigratorTest extends TestCase $this->assertTrue($result); } - public function testAddMigrationFailsIfUncallableMigration() { + public function testAddMigrationFailsIfUncallableMigration(): void { $this->expectException(BadFunctionCallException::class); $this->expectExceptionMessage('foo migration cannot be called.'); @@ -25,7 +25,7 @@ class MigratorTest extends TestCase $migrator->addMigration('foo', null); } - public function testMigrationsIsSorted() { + public function testMigrationsIsSorted(): void { $migrator = new Minz_Migrator(); $migrator->addMigration('2_foo', function () { return true; @@ -43,7 +43,7 @@ class MigratorTest extends TestCase $this->assertSame($expected_versions, array_keys($migrations)); } - public function testSetAppliedVersions() { + public function testSetAppliedVersions(): void { $migrator = new Minz_Migrator(); $migrator->addMigration('foo', function () { return true; @@ -54,7 +54,7 @@ class MigratorTest extends TestCase $this->assertSame(['foo'], $migrator->appliedVersions()); } - public function testSetAppliedVersionsTrimArgument() { + public function testSetAppliedVersionsTrimArgument(): void { $migrator = new Minz_Migrator(); $migrator->addMigration('foo', function () { return true; @@ -65,7 +65,7 @@ class MigratorTest extends TestCase $this->assertSame(['foo'], $migrator->appliedVersions()); } - public function testSetAppliedVersionsFailsIfMigrationDoesNotExist() { + public function testSetAppliedVersionsFailsIfMigrationDoesNotExist(): void { $this->expectException(DomainException::class); $this->expectExceptionMessage('foo migration does not exist.'); @@ -74,7 +74,7 @@ class MigratorTest extends TestCase $migrator->setAppliedVersions(['foo']); } - public function testVersions() { + public function testVersions(): void { $migrator = new Minz_Migrator(); $migrator->addMigration('foo', function () { return true; @@ -88,7 +88,7 @@ class MigratorTest extends TestCase $this->assertSame(['bar', 'foo'], $versions); } - public function testMigrate() { + public function testMigrate(): void { $migrator = new Minz_Migrator(); $spy = false; $migrator->addMigration('foo', function () use (&$spy) { @@ -106,7 +106,7 @@ class MigratorTest extends TestCase ], $result); } - public function testMigrateCallsMigrationsInSortedOrder() { + public function testMigrateCallsMigrationsInSortedOrder(): void { $migrator = new Minz_Migrator(); $spy_foo_1_is_called = false; $migrator->addMigration('2_foo', function () use (&$spy_foo_1_is_called) { @@ -126,7 +126,7 @@ class MigratorTest extends TestCase ], $result); } - public function testMigrateDoesNotCallAppliedMigrations() { + public function testMigrateDoesNotCallAppliedMigrations(): void { $migrator = new Minz_Migrator(); $spy = false; $migrator->addMigration('1_foo', function () use (&$spy) { @@ -141,7 +141,7 @@ class MigratorTest extends TestCase $this->assertSame([], $result); } - public function testMigrateCallNonAppliedBetweenTwoApplied() { + public function testMigrateCallNonAppliedBetweenTwoApplied(): void { $migrator = new Minz_Migrator(); $migrator->addMigration('1_foo', function () { return true; @@ -162,7 +162,7 @@ class MigratorTest extends TestCase ], $result); } - public function testMigrateWithMigrationReturningFalseDoesNotApplyVersion() { + public function testMigrateWithMigrationReturningFalseDoesNotApplyVersion(): void { $migrator = new Minz_Migrator(); $migrator->addMigration('1_foo', function () { return true; @@ -180,7 +180,7 @@ class MigratorTest extends TestCase ], $result); } - public function testMigrateWithMigrationReturningFalseDoesNotExecuteNextMigrations() { + public function testMigrateWithMigrationReturningFalseDoesNotExecuteNextMigrations(): void { $migrator = new Minz_Migrator(); $migrator->addMigration('1_foo', function () { return false; @@ -200,7 +200,7 @@ class MigratorTest extends TestCase ], $result); } - public function testMigrateWithFailingMigration() { + public function testMigrateWithFailingMigration(): void { $migrator = new Minz_Migrator(); $migrator->addMigration('foo', function () { throw new \Exception('Oops, it failed.'); @@ -214,7 +214,7 @@ class MigratorTest extends TestCase ], $result); } - public function testUpToDate() { + public function testUpToDate(): void { $migrator = new Minz_Migrator(); $migrator->addMigration('foo', function () { return true; @@ -226,7 +226,7 @@ class MigratorTest extends TestCase $this->assertTrue($upToDate); } - public function testUpToDateIfRemainingMigration() { + public function testUpToDateIfRemainingMigration(): void { $migrator = new Minz_Migrator(); $migrator->addMigration('1_foo', function () { return true; @@ -241,7 +241,7 @@ class MigratorTest extends TestCase $this->assertFalse($upToDate); } - public function testUpToDateIfNoMigrations() { + public function testUpToDateIfNoMigrations(): void { $migrator = new Minz_Migrator(); $upToDate = $migrator->upToDate(); @@ -249,7 +249,7 @@ class MigratorTest extends TestCase $this->assertTrue($upToDate); } - public function testConstructorLoadsDirectory() { + public function testConstructorLoadsDirectory(): void { $migrations_path = TESTS_PATH . '/fixtures/migrations/'; $migrator = new Minz_Migrator($migrations_path); $expected_versions = ['2019_12_22_FooBar', '2019_12_23_Baz']; @@ -259,7 +259,7 @@ class MigratorTest extends TestCase $this->assertSame($expected_versions, array_keys($migrations)); } - public function testExecute() { + public function testExecute(): void { $migrations_path = TESTS_PATH . '/fixtures/migrations/'; $applied_migrations_path = tempnam('/tmp', 'applied_migrations.txt'); @@ -271,7 +271,7 @@ class MigratorTest extends TestCase @unlink($applied_migrations_path); } - public function testExecuteWithAlreadyAppliedMigration() { + public function testExecuteWithAlreadyAppliedMigration(): void { $migrations_path = TESTS_PATH . '/fixtures/migrations/'; $applied_migrations_path = tempnam('/tmp', 'applied_migrations.txt'); file_put_contents($applied_migrations_path, '2019_12_22_FooBar'); @@ -284,7 +284,7 @@ class MigratorTest extends TestCase @unlink($applied_migrations_path); } - public function testExecuteWithAppliedMigrationInDifferentOrder() { + public function testExecuteWithAppliedMigrationInDifferentOrder(): void { $migrations_path = TESTS_PATH . '/fixtures/migrations/'; $applied_migrations_path = tempnam('/tmp', 'applied_migrations.txt'); file_put_contents($applied_migrations_path, "2019_12_23_Baz\n2019_12_22_FooBar"); @@ -299,7 +299,7 @@ class MigratorTest extends TestCase @unlink($applied_migrations_path); } - public function testExecuteFailsIfVersionPathDoesNotExist() { + public function testExecuteFailsIfVersionPathDoesNotExist(): void { $migrations_path = TESTS_PATH . '/fixtures/migrations/'; $applied_migrations_path = tempnam('/tmp', 'applied_migrations.txt'); $expected_result = "Cannot open the {$applied_migrations_path} file"; @@ -311,7 +311,7 @@ class MigratorTest extends TestCase @unlink($applied_migrations_path); } - public function testExecuteFailsIfAMigrationIsFailing() { + public function testExecuteFailsIfAMigrationIsFailing(): void { $migrations_path = TESTS_PATH . '/fixtures/migrations_with_failing/'; $applied_migrations_path = tempnam('/tmp', 'applied_migrations.txt'); $expected_result = 'A migration failed to be applied, please see previous logs.'; diff --git a/tests/lib/PHPMailer/PHPMailerTest.php b/tests/lib/PHPMailer/PHPMailerTest.php index 8fc14b815..b39cf2cb0 100644 --- a/tests/lib/PHPMailer/PHPMailerTest.php +++ b/tests/lib/PHPMailer/PHPMailerTest.php @@ -2,7 +2,7 @@ class PHPMailerTest extends PHPUnit\Framework\TestCase { - public function testPHPMailerClassExists() { + public function testPHPMailerClassExists(): void { $this->assertTrue(class_exists('PHPMailer\\PHPMailer\\PHPMailer')); } } |
