Initial SQLite development (#1)
Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
43
tests/unit/Mapper/ExistsMapperTest.php
Normal file
43
tests/unit/Mapper/ExistsMapperTest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Test\Unit\Mapper;
|
||||
|
||||
use BitBadger\PDODocument\{Configuration, DocumentException, Mode};
|
||||
use BitBadger\PDODocument\Mapper\ExistsMapper;
|
||||
use PHPUnit\Framework\Attributes\TestDox;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Unit tests for the ExistsMapper class
|
||||
*/
|
||||
class ExistsMapperTest extends TestCase
|
||||
{
|
||||
#[TestDox('Map succeeds for PostgreSQL')]
|
||||
public function testMapSucceedsForPostgreSQL(): void
|
||||
{
|
||||
try {
|
||||
Configuration::$mode = Mode::PgSQL;
|
||||
$this->assertFalse((new ExistsMapper())->map([false, 'nope']), 'Result should have been false');
|
||||
} finally {
|
||||
Configuration::$mode = null;
|
||||
}
|
||||
}
|
||||
|
||||
#[TestDox('Map succeeds for SQLite')]
|
||||
public function testMapSucceedsForSQLite(): void
|
||||
{
|
||||
try {
|
||||
Configuration::$mode = Mode::SQLite;
|
||||
$this->assertTrue((new ExistsMapper())->map([1, 'yep']), 'Result should have been true');
|
||||
} finally {
|
||||
Configuration::$mode = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function testMapFailsWhenModeNotSet(): void
|
||||
{
|
||||
$this->expectException(DocumentException::class);
|
||||
Configuration::$mode = null;
|
||||
(new ExistsMapper())->map(['0']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user