Skip to content

Commit

Permalink
test: improve test oop
Browse files Browse the repository at this point in the history
  • Loading branch information
g105b committed Feb 10, 2024
1 parent f04807a commit 98cad4b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
4 changes: 4 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
colors="true"
cacheDirectory="test/phpunit/.phpunit.cache"
bootstrap="vendor/autoload.php"
displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
>
<coverage />

Expand Down
4 changes: 2 additions & 2 deletions test/phpunit/Connection/DefaultSettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ 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],
[Settings::DRIVER_SQLSERVER, 1433],
[Settings::DRIVER_SQLITE, 0],
];
}
}
}
4 changes: 2 additions & 2 deletions test/phpunit/Helper/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -163,4 +163,4 @@ private static function queryCollectionPathProvider(

return $data;
}
}
}
16 changes: 8 additions & 8 deletions test/phpunit/Migration/MigratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
);
Expand All @@ -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
);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/phpunit/Result/RowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down

0 comments on commit 98cad4b

Please sign in to comment.