Compare commits
No commits in common. '7783b245df93a8c1bfc38247719acb626e7a8d03' and '3a5a4c7a5c673044b8704186d9f83d7760efdc46' have entirely different histories.
7783b245df
...
3a5a4c7a5c
File diff suppressed because it is too large
Load Diff
@ -1,101 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Kartierung\Repository\ResolutionStrategy;
|
|
||||||
|
|
||||||
use Kartierung\Analyze\Result\RepositoryMethod;
|
|
||||||
use PHPUnit\Framework\Attributes\Group;
|
|
||||||
|
|
||||||
class FindByIdTest extends SqliteBaseCase
|
|
||||||
{
|
|
||||||
protected function setUp(): void
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
$this->getPdo()->exec(
|
|
||||||
"
|
|
||||||
CREATE TABLE SimpleEntity (
|
|
||||||
stringcol VARCHAR(250),
|
|
||||||
intcol INT
|
|
||||||
);
|
|
||||||
INSERT INTO SimpleEntity(stringcol, intcol)
|
|
||||||
VALUES ('dings', 1),
|
|
||||||
('bumms', 2),
|
|
||||||
('foobar', 3);
|
|
||||||
"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Group('integration')]
|
|
||||||
public function testSelectsFirstEntry(): void
|
|
||||||
{
|
|
||||||
// Given
|
|
||||||
$method = new RepositoryMethod(
|
|
||||||
query: '',
|
|
||||||
returnType: SimpleEntity::class,
|
|
||||||
returnsNullable: true,
|
|
||||||
returnListType: '',
|
|
||||||
name: '',
|
|
||||||
parameters: [],
|
|
||||||
resolutionStrategy: new FindById()
|
|
||||||
);
|
|
||||||
$query = $method->createQuery([1]);
|
|
||||||
|
|
||||||
// When
|
|
||||||
$result = $query->execute($this->getPdo());
|
|
||||||
|
|
||||||
// Then
|
|
||||||
$this->assertEquals(
|
|
||||||
new SimpleEntity(1, 'dings'),
|
|
||||||
$result
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Group('integration')]
|
|
||||||
public function testSelectsThirdEntry(): void
|
|
||||||
{
|
|
||||||
// Given
|
|
||||||
$method = new RepositoryMethod(
|
|
||||||
query: '',
|
|
||||||
returnType: SimpleEntity::class,
|
|
||||||
returnsNullable: true,
|
|
||||||
returnListType: '',
|
|
||||||
name: '',
|
|
||||||
parameters: [],
|
|
||||||
resolutionStrategy: new FindById()
|
|
||||||
);
|
|
||||||
$query = $method->createQuery([3]);
|
|
||||||
|
|
||||||
// When
|
|
||||||
$result = $query->execute($this->getPdo());
|
|
||||||
|
|
||||||
// Then
|
|
||||||
$this->assertEquals(
|
|
||||||
new SimpleEntity(3, 'foobar'),
|
|
||||||
$result
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Group('integration')]
|
|
||||||
public function testSelectsNothingMatching(): void
|
|
||||||
{
|
|
||||||
// Given
|
|
||||||
$method = new RepositoryMethod(
|
|
||||||
query: '',
|
|
||||||
returnType: SimpleEntity::class,
|
|
||||||
returnsNullable: true,
|
|
||||||
returnListType: '',
|
|
||||||
name: '',
|
|
||||||
parameters: [],
|
|
||||||
resolutionStrategy: new FindById()
|
|
||||||
);
|
|
||||||
$query = $method->createQuery([4]);
|
|
||||||
|
|
||||||
// When
|
|
||||||
$result = $query->execute($this->getPdo());
|
|
||||||
|
|
||||||
// Then
|
|
||||||
$this->assertNull($result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Kartierung\Repository\ResolutionStrategy;
|
|
||||||
|
|
||||||
use PDO;
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
|
|
||||||
|
|
||||||
abstract class SqliteBaseCase extends TestCase
|
|
||||||
{
|
|
||||||
private PDO $pdo;
|
|
||||||
|
|
||||||
protected function setUp(): void
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
$tmpfile = tempnam(sys_get_temp_dir(), 'kartierung.sqlite');
|
|
||||||
$this->pdo = new \PDO("sqlite:/$tmpfile");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getPdo(): PDO
|
|
||||||
{
|
|
||||||
return $this->pdo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue