Skip to content

Commit 5023e80

Browse files
committed
Fixing tests to only test @readonly with MySQL
1 parent 533cd54 commit 5023e80

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

tests/TDBMAbstractServiceTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
use TheCodingMachine\TDBM\Utils\Annotation\AddInterface;
4444
use TheCodingMachine\TDBM\Utils\DefaultNamingStrategy;
4545
use TheCodingMachine\TDBM\Utils\PathFinder\PathFinder;
46+
use function stripos;
4647

4748
abstract class TDBMAbstractServiceTest extends TestCase
4849
{
@@ -416,7 +417,7 @@ private static function initSchema(Connection $connection): void
416417
}
417418

418419
// Let's generate computed columns
419-
if ($connection->getDatabasePlatform() instanceof MySqlPlatform) {
420+
if ($connection->getDatabasePlatform() instanceof MySqlPlatform && !self::isMariaDb($connection)) {
420421
$connection->exec('CREATE TABLE `players` (
421422
`id` INT UNSIGNED AUTO_INCREMENT NOT NULL,
422423
`player_and_games` JSON NOT NULL,
@@ -768,4 +769,13 @@ protected static function delete(Connection $connection, string $tableName, arra
768769
}
769770
$connection->delete($connection->quoteIdentifier($tableName), $quotedData);
770771
}
772+
773+
protected static function isMariaDb(Connection $connection): bool
774+
{
775+
if (!$connection->getDatabasePlatform() instanceof MySqlPlatform) {
776+
return false;
777+
}
778+
$version = $connection->fetchColumn('SELECT VERSION()');
779+
return stripos($version, 'maria') !== false;
780+
}
771781
}

tests/TDBMDaoGeneratorTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2282,6 +2282,10 @@ public function testFindFromRawSQLOnInheritance(): void
22822282

22832283
public function testGeneratedColumnsAreNotPartOfTheConstructor(): void
22842284
{
2285+
if ($this->tdbmService->getConnection()->getDatabasePlatform() instanceof MySqlPlatform && !self::isMariaDb($this->tdbmService->getConnection())) {
2286+
$this->markTestSkipped('ReadOnly column is only tested with MySQL');
2287+
}
2288+
22852289
$dao = new PlayerDao($this->tdbmService);
22862290

22872291
$player = new PlayerBean([
@@ -2314,6 +2318,10 @@ public function testGeneratedColumnsAreNotPartOfTheConstructor(): void
23142318

23152319
public function testCanReadVirtualColumn(): void
23162320
{
2321+
if ($this->tdbmService->getConnection()->getDatabasePlatform() instanceof MySqlPlatform && !self::isMariaDb($this->tdbmService->getConnection())) {
2322+
$this->markTestSkipped('ReadOnly column is only tested with MySQL');
2323+
}
2324+
23172325
$dao = new PlayerDao($this->tdbmService);
23182326

23192327
$player = $dao->getById(1);

0 commit comments

Comments
 (0)