You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace Kartierung\Repository\ResolutionStrategy;
use Kartierung\Analyze\Result\ParameterFunction;
use Kartierung\Analyze\Result\RepositoryMethod;
use Kartierung\Analyze\Result\RepositoryMethodParameter;
use PHPUnit\Framework\Attributes\Group;
class SaveEntityTest extends SqliteBaseCase
{
protected function setUp(): void
{
parent::setUp();
$this->getPdo()->exec(
"
CREATE TABLE SimpleEntity (
stringcol VARCHAR(250),
intcol INTEGER PRIMARY KEY AUTOINCREMENT
);
INSERT INTO SimpleEntity(stringcol, intcol)
VALUES ('dings', 1),
('bumms', 2);
"
);
}
#[Group('integration')]
public function testSelectsData(): void
{
// Given
$strategy = new SaveEntity();
$method = new RepositoryMethod(
query: '',
returnType: '',
returnsNullable: true,
returnListType: '',
name: '',
parameters: [
new RepositoryMethodParameter(
name: '',
type: SimpleEntity::class,
function: ParameterFunction::STATEMENT_PARAMETER
)
],
resolutionStrategy: $strategy
);
$entity = new SimpleEntity(null, 'foobar');
$query = $method->createQuery([$entity]);
// When
$result = $query->execute($this->getPdo());
// Then
$this->assertInstanceOf(SimpleEntity::class, $result);
$this->assertNotNull($result->intcol);
}
}