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.

62 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace Kartierung\Repository\ResolutionStrategy;
use Kartierung\Analyze\Result\EntityField;
use Kartierung\Analyze\Result\EntityResult;
use Kartierung\Analyze\Result\FieldAccess;
use Kartierung\Analyze\Result\Type\PrimitiveType;
use PHPUnit\Framework\TestCase;
class EntityToDataMapperTest extends TestCase
{
public function testMapsByColumnName(): void
{
// Given
$entity = new SimpleEntity(1, "2");
$entityResult = new EntityResult(
classFqcn: '',
tableName: '',
fields: [
new EntityField(
name: 'intcol',
type: PrimitiveType::INTEGER,
columnName: 'intcol',
isIdField: true,
readAccess: FieldAccess::PUBLIC
),
new EntityField(
name: 'stringcol',
type: PrimitiveType::INTEGER,
columnName: 'stringcol',
isIdField: true,
readAccess: FieldAccess::PUBLIC
)
],
idField: new EntityField(
name: '',
type: PrimitiveType::INTEGER,
columnName: '',
isIdField: true,
readAccess: FieldAccess::PUBLIC
)
);
// When
$result = (new EntityToDataMapper())->byColumnName(
$entityResult, $entity
);
// Then
$this->assertEquals(
[
'intcol' => 1,
'stringcol' => 2
],
$result
);
}
}