Skip to content

Commit

Permalink
Improve Dbal Bulk coverage (#823)
Browse files Browse the repository at this point in the history
  • Loading branch information
stloyd committed Nov 22, 2023
1 parent 3beeba1 commit adc4e68
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/lib/doctrine-dbal-bulk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ $bulk->update(
## Supported Dialects

* PostgreSQL
* MySQL / MariaDB
* SQLite

### Adding new Dialects

Expand All @@ -79,4 +81,4 @@ example:
`dialect_option?: string`

[DbalPlatform](src/Flow/Doctrine/Bulk/DbalPlatform.php) is a factory that detects which Dialect should be used for given
Doctrine DBAL Platform.
Doctrine DBAL Platform.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

/**
* @infection-ignore-all
*
* @codeCoverageIgnore
*/
final class DbalPlatform
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Flow\Doctrine\Bulk\QueryFactory;
use Flow\Doctrine\Bulk\TableDefinition;

class DbalQueryFactory implements QueryFactory
final class DbalQueryFactory implements QueryFactory
{
/**
* @param AbstractPlatform $platform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

namespace Flow\Doctrine\Bulk\Tests\Unit;

use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Platforms\MySQL80Platform;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Flow\Doctrine\Bulk\DbalPlatform;
use Flow\Doctrine\Bulk\Dialect\MySQLDialect;
use Flow\Doctrine\Bulk\Dialect\PostgreSQLDialect;
use Flow\Doctrine\Bulk\Dialect\SqliteDialect;
use Flow\Doctrine\Bulk\Exception\RuntimeException;
use PHPUnit\Framework\TestCase;

final class DbalPlatformTest extends TestCase
Expand All @@ -20,6 +23,13 @@ public function test_is_mysql() : void
$this->assertInstanceOf(MySQLDialect::class, $platform->dialect());
}

public function test_is_mysql_with_mariadb() : void
{
$platform = new DbalPlatform(new MariaDBPlatform());

$this->assertInstanceOf(MySQLDialect::class, $platform->dialect());
}

public function test_is_postgres_sql() : void
{
$platform = new DbalPlatform(new PostgreSQLPlatform());
Expand All @@ -33,4 +43,13 @@ public function test_is_sqlite_sql() : void

$this->assertInstanceOf(SqliteDialect::class, $platform->dialect());
}

public function test_no_supported_platform() : void
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Database platform "Doctrine\DBAL\Platforms\OraclePlatform" is not yet supported');

$platform = new DbalPlatform(new OraclePlatform());
$platform->dialect();
}
}

0 comments on commit adc4e68

Please sign in to comment.