Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"require-dev": {
"ext-sqlite3": "*",
"phpstan/phpstan": "^v1.10",
"phpunit/phpunit": "^10.1",
"phpunit/phpunit": "^10.1 || ^12.0",
"phpmd/phpmd": "^2.13",
"squizlabs/php_codesniffer": "^3.7 || ^4.0"
},
Expand Down
711 changes: 388 additions & 323 deletions composer.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions test/phpunit/Connection/DefaultSettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testDefaults() {
);
}

/** @dataProvider getDrivers */
#[\PHPUnit\Framework\Attributes\DataProvider("getDrivers")]
public function testDefaultPort(string $dsn, int $port) {
// NOTE: Have to use a Settings object here as it's not possible to use anything other
// than the default_driver otherwise
Expand All @@ -64,7 +64,7 @@ public function testDefaultPort(string $dsn, int $port) {
], $settings->getConnectionSettings());
}

/** @dataProvider getDrivers */
#[\PHPUnit\Framework\Attributes\DataProvider("getDrivers")]
public function testGetConnectionSettings(string $dsn, int $port) {
$settings = new DefaultSettings();
$connectionSettings = $settings->getConnectionSettings();
Expand Down
11 changes: 6 additions & 5 deletions test/phpunit/DatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function testInterface() {
static::assertInstanceOf(Database::class, $db);
}

/** @dataProvider \GT\Database\Test\Helper\Helper::queryCollectionPathExistsProvider */
#[\PHPUnit\Framework\Attributes\DataProviderExternal(\GT\Database\Test\Helper\Helper::class, "queryCollectionPathExistsProvider")]
public function testQueryCollectionPathExists(string $name, string $path) {
$basePath = dirname($path);
$settings = new Settings(
Expand All @@ -59,8 +59,8 @@ public function testQueryCollectionPathExists(string $name, string $path) {
static::assertInstanceOf(QueryCollection::class, $queryCollection);
}

/** @dataProvider \GT\Database\Test\Helper\Helper::queryPathNotExistsProvider */
public function testQueryCollectionPathNotExists(string $name, string $path) {
#[\PHPUnit\Framework\Attributes\DataProviderExternal(\GT\Database\Test\Helper\Helper::class, "queryPathNotExistsProvider")]
public function testQueryCollectionPathNotExists(string $name, string $path, string $queryBase) {
$basePath = dirname($path);

$settings = new Settings(
Expand All @@ -74,7 +74,7 @@ public function testQueryCollectionPathNotExists(string $name, string $path) {
$db->queryCollection($name);
}

/** @dataProvider \GT\Database\Test\Helper\Helper::queryPathNestedProvider */
#[\PHPUnit\Framework\Attributes\DataProviderExternal(\GT\Database\Test\Helper\Helper::class, "queryPathNestedProvider")]
public function testQueryCollectionDots(
array $nameParts,
string $path,
Expand All @@ -93,7 +93,8 @@ public function testQueryCollectionDots(
self::assertInstanceOf(QueryCollection::class, $queryCollection);
}

/** @dataProvider \GT\Database\Test\Helper\Helper::queryCollectionPathNotExistsProvider() */
/* */
#[\PHPUnit\Framework\Attributes\DataProviderExternal(\GT\Database\Test\Helper\Helper::class, "queryCollectionPathNotExistsProvider")]
public function testQueryCollectionPhp(
string $name,
string $path,
Expand Down
52 changes: 22 additions & 30 deletions test/phpunit/Migration/MigratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function testMigrationZeroAtStartWithTable() {
self::assertEquals(0, $migrator->getMigrationCount());
}

/** @dataProvider dataMigrationFileList */
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileList")]
public function testGetMigrationFileList(array $fileList) {
$path = $this->getMigrationDirectory();
$this->createFiles($fileList, $path);
Expand All @@ -85,7 +85,7 @@ public function testGetMigrationFileListNotExists() {
$migrator->getMigrationFileList();
}

/** @dataProvider dataMigrationFileList */
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileList")]
public function testCheckFileListOrder(array $fileList) {
$path = $this->getMigrationDirectory();
$this->createFiles($fileList, $path);
Expand All @@ -106,7 +106,7 @@ public function testCheckFileListOrder(array $fileList) {
);
}

/** @dataProvider dataMigrationFileListMissing */
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileListMissing")]
public function testCheckFileListOrderMissing(array $fileList) {
$path = self::getMigrationDirectory();
$this->createFiles($fileList, $path);
Expand All @@ -119,7 +119,7 @@ public function testCheckFileListOrderMissing(array $fileList) {
$migrator->checkFileListOrder($actualFileList);
}

/** @dataProvider dataMigrationFileListDuplicate */
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileListDuplicate")]
public function testCheckFileListOrderDuplicate(array $fileList) {
$path = $this->getMigrationDirectory();
$this->createFiles($fileList, $path);
Expand Down Expand Up @@ -176,7 +176,7 @@ public function testCheckFileListOrderIgnoresNonNumericFilesAndThrowsOnResulting
$migrator->checkFileListOrder($actualFileList);
}

/** @dataProvider dataMigrationFileList */
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileList")]
public function testCheckIntegrityGood(array $fileList) {
$path = $this->getMigrationDirectory();

Expand All @@ -198,7 +198,7 @@ public function testCheckIntegrityGood(array $fileList) {
);
}

/** @dataProvider dataMigrationFileList */
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileList")]
public function testCheckIntegrityBad(array $fileList) {
$path = $this->getMigrationDirectory();

Expand Down Expand Up @@ -239,7 +239,7 @@ public function testMigrationCountZeroAtStart() {
self::assertEquals(0, $migrator->getMigrationCount());
}

/** @dataProvider dataMigrationFileList */
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileList")]
public function testMigrationCountNotZeroAfterMigration(array $fileList) {
$path = $this->getMigrationDirectory();

Expand All @@ -261,7 +261,7 @@ public function testMigrationCountNotZeroAfterMigration(array $fileList) {
);
}

/** @dataProvider dataMigrationFileList */
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileList")]
public function testMigrationCountReturnsZeroOnException(array $fileList) {
$path = $this->getMigrationDirectory();

Expand All @@ -271,9 +271,7 @@ public function testMigrationCountReturnsZeroOnException(array $fileList) {
self::assertEquals(0, $migrator->getMigrationCount());
}

/**
* @dataProvider dataMigrationFileList
*/
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileList")]
public function testMigrationFileNameFormat(array $fileList) {
$path = $this->getMigrationDirectory();

Expand All @@ -300,9 +298,7 @@ public function testMigrationFileNameFormat(array $fileList) {
$migrator->checkFileListOrder($absoluteFileList);
}

/**
* @dataProvider dataMigrationFileList
*/
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileList")]
public function testForcedMigration(array $fileList) {
$path = $this->getMigrationDirectory();

Expand All @@ -325,7 +321,7 @@ public function testForcedMigration(array $fileList) {
self::assertNull($exception,"Exception should not be thrown");
}

/** @dataProvider dataMigrationFileList */
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileList")]
public function testHashMismatchAfterEditingFirstFile(array $fileList) {
$path = $this->getMigrationDirectory();
$this->createMigrationFiles($fileList, $path);
Expand Down Expand Up @@ -377,8 +373,8 @@ public function testHashMismatchAfterEditingFirstFile(array $fileList) {
* none of the files in fileList are migrated yet, we should only see
* 1 migration take place.
*
* @dataProvider dataMigrationFileList
*/
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileList")]
public function testResetMigration(array $fileList) {
$path = $this->getMigrationDirectory();
$this->createMigrationFiles($fileList, $path);
Expand Down Expand Up @@ -418,9 +414,7 @@ public function testResetMigration(array $fileList) {
self::assertSame(1, $migrationsExecuted);
}

/**
* @dataProvider dataMigrationFileList
*/
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileList")]
public function testPerformMigrationGood(array $fileList):void {
$path = $this->getMigrationDirectory();

Expand Down Expand Up @@ -456,7 +450,7 @@ public function testPerformMigrationGood(array $fileList):void {
);
}

/** @dataProvider dataMigrationFileList */
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileList")]
public function testPerformMigrationBad(array $fileList) {
$path = $this->getMigrationDirectory();
$this->createMigrationFiles($fileList, $path);
Expand All @@ -479,7 +473,7 @@ public function testPerformMigrationBad(array $fileList) {
$migrator->performMigration($absoluteFileList);
}

/** @dataProvider dataMigrationFileList */
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileList")]
public function testPerformMigrationAlreadyCompleted(array $fileList) {
$path = $this->getMigrationDirectory();
$this->createMigrationFiles($fileList, $path);
Expand Down Expand Up @@ -512,9 +506,7 @@ public function testPerformMigrationAlreadyCompleted(array $fileList) {

}

/**
* @dataProvider dataMigrationFileList
*/
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileList")]
public function testNonSqlExtensions(array $fileList) {
$path = $this->getMigrationDirectory();
$this->createMigrationFiles($fileList, $path);
Expand Down Expand Up @@ -747,7 +739,7 @@ public function testGetDefaultTableNameReturnsMigration():void {
self::assertSame("_migration", $method->invoke($migrator));
}

/** @dataProvider dataMigrationFileList */
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileList")]
public function testMigrationThrowsExceptionWhenNoMigrationTable(array $fileList) {
$path = $this->getMigrationDirectory();

Expand Down Expand Up @@ -776,7 +768,7 @@ public function testMigrationNoOutputEmpty() {
self::assertEmpty($output);
}

/** @dataProvider dataMigrationFileList */
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileList")]
public function testMigrationNoOutput(array $fileList) {
$path = $this->getMigrationDirectory();
$this->createMigrationFiles($fileList, $path);
Expand All @@ -800,7 +792,7 @@ public function testMigrationNoOutput(array $fileList) {
self::assertEmpty($output);
}

/** @dataProvider dataMigrationFileList */
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileList")]
public function testMigrationOutputToStream(array $fileList) {
$path = $this->getMigrationDirectory();
$this->createMigrationFiles($fileList, $path);
Expand Down Expand Up @@ -828,7 +820,7 @@ public function testMigrationOutputToStream(array $fileList) {
self::assertStringContainsString("$expectedCount migrations were completed successfully.", $output);
}

/** @dataProvider dataMigrationFileList */
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileList")]
public function testMigrationErrorOutputToStream(array $fileList) {
$path = $this->getMigrationDirectory();
$this->createMigrationFiles($fileList, $path);
Expand Down Expand Up @@ -1037,7 +1029,7 @@ protected function createSettings(string $path):Settings {
/**
* New tests for migrating from a specific file number.
*/
/** @dataProvider dataMigrationFileList */
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileList")]
public function testPerformMigrationFromSpecificNumber(array $fileList) {
$path = $this->getMigrationDirectory();
$this->createMigrationFiles($fileList, $path);
Expand Down Expand Up @@ -1078,7 +1070,7 @@ public function testPerformMigrationFromSpecificNumber(array $fileList) {
self::assertSame($expected, $migrator->getMigrationCount());
}

/** @dataProvider dataMigrationFileListMissing */
#[\PHPUnit\Framework\Attributes\DataProvider("dataMigrationFileListMissing")]
public function testCheckFileListOrderThrowsOnGapsWhenMigratingFromSpecificNumber(array $fileList) {
$path = $this->getMigrationDirectory();
$this->createFiles($fileList, $path);
Expand Down
25 changes: 14 additions & 11 deletions test/phpunit/Query/QueryFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
use PHPUnit\Framework\TestCase;

class QueryFactoryTest extends TestCase {
/**
* @dataProvider \GT\Database\Test\Helper\Helper::queryPathExistsProvider
*/
#[\PHPUnit\Framework\Attributes\DataProviderExternal(\GT\Database\Test\Helper\Helper::class, "queryPathExistsProvider")]
public function testFindQueryFilePathExists(
string $queryName,
string $directoryOfQueries
string $directoryOfQueries,
string $queryBase,
) {
$queryFactory = new QueryFactory(
$directoryOfQueries,
Expand All @@ -30,10 +29,11 @@ public function testFindQueryFilePathExists(
static::assertFileExists($queryFilePath);
}

/** @dataProvider \GT\Database\Test\Helper\Helper::queryPathNotExistsProvider */
#[\PHPUnit\Framework\Attributes\DataProviderExternal(\GT\Database\Test\Helper\Helper::class, "queryPathNotExistsProvider")]
public function testFindQueryFilePathNotExists(
string $queryName,
string $directoryOfQueries
string $directoryOfQueries,
string $queryBase,
) {
$queryFactory = new QueryFactory(
$directoryOfQueries,
Expand All @@ -44,10 +44,11 @@ public function testFindQueryFilePathNotExists(
$queryFactory->findQueryFilePath($queryName);
}

/** @dataProvider \GT\Database\Test\Helper\Helper::queryPathExtensionNotValidProvider */
#[\PHPUnit\Framework\Attributes\DataProviderExternal(\GT\Database\Test\Helper\Helper::class, "queryPathExtensionNotValidProvider")]
public function testFindQueryFilePathWithInvalidExtension(
string $queryName,
string $directoryOfQueries
string $directoryOfQueries,
string $queryBase,
) {
$queryFactory = new QueryFactory(
$directoryOfQueries,
Expand All @@ -58,10 +59,11 @@ public function testFindQueryFilePathWithInvalidExtension(
$queryFactory->findQueryFilePath($queryName);
}

/** @dataProvider \GT\Database\Test\Helper\Helper::queryPathExistsProvider */
#[\PHPUnit\Framework\Attributes\DataProviderExternal(\GT\Database\Test\Helper\Helper::class, "queryPathExistsProvider")]
public function testQueryCreated(
string $queryName,
string $directoryOfQueries
string $directoryOfQueries,
string $queryBase,
) {
$queryFactory = new QueryFactory(
$directoryOfQueries,
Expand Down Expand Up @@ -97,10 +99,11 @@ public function testSelectsCorrectFile() {
}
}

/** @dataProvider \GT\Database\Test\Helper\Helper::queryPathNotExistsProvider */
#[\PHPUnit\Framework\Attributes\DataProviderExternal(\GT\Database\Test\Helper\Helper::class, "queryPathNotExistsProvider")]
public function testCreatePhp(
string $queryName,
string $directoryOfQueries,
string $queryBase,
) {
$classPath = "$directoryOfQueries.php";
if(!is_dir($directoryOfQueries)) {
Expand Down
8 changes: 3 additions & 5 deletions test/phpunit/Query/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use PHPUnit\Framework\TestCase;

class QueryTest extends TestCase {
/** @dataProvider \GT\Database\Test\Helper\Helper::queryPathNotExistsProvider */
#[\PHPUnit\Framework\Attributes\DataProviderExternal(\GT\Database\Test\Helper\Helper::class, "queryPathNotExistsProvider")]
public function testConstructionQueryPathNotExists(
string $queryName,
string $queryCollectionPath,
Expand All @@ -20,9 +20,7 @@ public function testConstructionQueryPathNotExists(
new SqlQuery($queryPath, new Driver(new DefaultSettings()));
}

/**
* @dataProvider \GT\Database\Test\Helper\Helper::queryPathExistsProvider
*/
#[\PHPUnit\Framework\Attributes\DataProviderExternal(\GT\Database\Test\Helper\Helper::class, "queryPathExistsProvider")]
public function testConstructionQueryPathExists(
string $queryName,
string $queryCollectionPath,
Expand All @@ -36,7 +34,7 @@ public function testConstructionQueryPathExists(
}
}

/** @dataProvider \GT\Database\Test\Helper\Helper::queryPathExistsProvider */
#[\PHPUnit\Framework\Attributes\DataProviderExternal(\GT\Database\Test\Helper\Helper::class, "queryPathExistsProvider")]
public function testExecDoesNotConnect(
string $queryName,
string $queryCollectionPath,
Expand Down
Loading
Loading