From 98cad4b71f67863ee64eaab2a4942937308fa331 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Sat, 10 Feb 2024 18:17:00 +0000 Subject: [PATCH] test: improve test oop --- phpunit.xml | 4 ++++ test/phpunit/Connection/DefaultSettingsTest.php | 4 ++-- test/phpunit/Helper/Helper.php | 4 ++-- test/phpunit/Migration/MigratorTest.php | 16 ++++++++-------- test/phpunit/Result/RowTest.php | 2 +- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 5e1b5d9..7208740 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -5,6 +5,10 @@ colors="true" cacheDirectory="test/phpunit/.phpunit.cache" bootstrap="vendor/autoload.php" + displayDetailsOnTestsThatTriggerWarnings="true" + displayDetailsOnTestsThatTriggerDeprecations="true" + displayDetailsOnTestsThatTriggerErrors="true" + displayDetailsOnTestsThatTriggerNotices="true" > diff --git a/test/phpunit/Connection/DefaultSettingsTest.php b/test/phpunit/Connection/DefaultSettingsTest.php index 7c8919b..e258eef 100644 --- a/test/phpunit/Connection/DefaultSettingsTest.php +++ b/test/phpunit/Connection/DefaultSettingsTest.php @@ -91,7 +91,7 @@ public function testGetDefaultCharset() { self::assertEquals(DefaultSettings::DEFAULT_COLLATION, $settings->getCollation()); } - public function getDrivers():array { + public static function getDrivers():array { return [ [Settings::DRIVER_MYSQL, 3306], [Settings::DRIVER_POSTGRES, 5432], @@ -99,4 +99,4 @@ public function getDrivers():array { [Settings::DRIVER_SQLITE, 0], ]; } -} \ No newline at end of file +} diff --git a/test/phpunit/Helper/Helper.php b/test/phpunit/Helper/Helper.php index 060afd6..6521d76 100644 --- a/test/phpunit/Helper/Helper.php +++ b/test/phpunit/Helper/Helper.php @@ -82,7 +82,7 @@ private static function queryPathProvider(bool $exists, $extension = "sql") { return $data; } - public function queryPathNestedProvider() { + public static function queryPathNestedProvider() { $data = []; $n = rand(2, 6); @@ -163,4 +163,4 @@ private static function queryCollectionPathProvider( return $data; } -} \ No newline at end of file +} diff --git a/test/phpunit/Migration/MigratorTest.php b/test/phpunit/Migration/MigratorTest.php index d0280d6..0619b74 100644 --- a/test/phpunit/Migration/MigratorTest.php +++ b/test/phpunit/Migration/MigratorTest.php @@ -108,7 +108,7 @@ public function testCheckFileListOrder(array $fileList) { /** @dataProvider dataMigrationFileListMissing */ public function testCheckFileListOrderMissing(array $fileList) { - $path = $this->getMigrationDirectory(); + $path = self::getMigrationDirectory(); $this->createFiles($fileList, $path); $settings = $this->createSettings($path); @@ -542,15 +542,15 @@ public function testMigrationErrorOutputToStream(array $fileList) { } } - public function dataMigrationFileList():array { - $fileList = $this->generateFileList(); + public static function dataMigrationFileList():array { + $fileList = self::generateFileList(); return [ [$fileList] ]; } - public function dataMigrationFileListMissing():array { - $fileList = $this->generateFileList( + public static function dataMigrationFileListMissing():array { + $fileList = self::generateFileList( true, false ); @@ -559,8 +559,8 @@ public function dataMigrationFileListMissing():array { ]; } - public function dataMigrationFileListDuplicate():array { - $fileList = $this->generateFileList( + public static function dataMigrationFileListDuplicate():array { + $fileList = self::generateFileList( false, true ); @@ -638,7 +638,7 @@ protected function hashMigrationToDb( } } - private function generateFileList($missingFiles = false, $duplicateFiles = false) { + private static function generateFileList($missingFiles = false, $duplicateFiles = false) { $fileList = []; $migLength = rand(10, 30); diff --git a/test/phpunit/Result/RowTest.php b/test/phpunit/Result/RowTest.php index f3df193..6edb409 100644 --- a/test/phpunit/Result/RowTest.php +++ b/test/phpunit/Result/RowTest.php @@ -123,7 +123,7 @@ public function testGetIntNullable() { self::assertNull($row->getInt("does_not_exist")); } - public function data_getTestRow():array { + public static function data_getTestRow():array { $data = []; $columns = ["id", "name", "example", "exampleFloat", "exampleDateTime", "exampleBool"];