DDC-644 - Added more tests for Hydrators and unknown to be skipped columns
This commit is contained in:
parent
56b3c0e8b0
commit
d6a1075b53
@ -736,4 +736,31 @@ class ArrayHydratorTest extends HydrationTestCase
|
||||
++$rowNum;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-644
|
||||
*/
|
||||
public function testSkipUnknownColumns()
|
||||
{
|
||||
$rsm = new ResultSetMapping;
|
||||
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
|
||||
$rsm->addFieldResult('u', 'u__id', 'id');
|
||||
$rsm->addFieldResult('u', 'u__name', 'name');
|
||||
|
||||
// Faked result set
|
||||
$resultSet = array(
|
||||
array(
|
||||
'u__id' => '1',
|
||||
'u__name' => 'romanb',
|
||||
'foo' => 'bar', // unknown!
|
||||
),
|
||||
);
|
||||
|
||||
$stmt = new HydratorMockStatement($resultSet);
|
||||
$hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em);
|
||||
|
||||
$result = $hydrator->hydrateAll($stmt, $rsm);
|
||||
|
||||
$this->assertEquals(1, count($result));
|
||||
}
|
||||
}
|
@ -51,6 +51,33 @@ class ObjectHydratorTest extends HydrationTestCase
|
||||
$this->assertEquals('jwage', $result[1]->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-644
|
||||
*/
|
||||
public function testSkipUnknownColumns()
|
||||
{
|
||||
$rsm = new ResultSetMapping;
|
||||
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
|
||||
$rsm->addFieldResult('u', 'u__id', 'id');
|
||||
$rsm->addFieldResult('u', 'u__name', 'name');
|
||||
|
||||
// Faked result set
|
||||
$resultSet = array(
|
||||
array(
|
||||
'u__id' => '1',
|
||||
'u__name' => 'romanb',
|
||||
'foo' => 'bar', // unknown!
|
||||
),
|
||||
);
|
||||
|
||||
$stmt = new HydratorMockStatement($resultSet);
|
||||
$hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
|
||||
|
||||
$result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true));
|
||||
|
||||
$this->assertEquals(1, count($result));
|
||||
}
|
||||
|
||||
/**
|
||||
* Select u.id, u.name from \Doctrine\Tests\Models\CMS\CmsUser u
|
||||
*/
|
||||
|
@ -68,4 +68,34 @@ class ScalarHydratorTest extends HydrationTestCase
|
||||
|
||||
$result = $hydrator->hydrateAll($stmt, $rsm);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-644
|
||||
*/
|
||||
public function testSkipUnknownColumns()
|
||||
{
|
||||
$rsm = new ResultSetMapping;
|
||||
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
|
||||
$rsm->addFieldResult('u', 'u__id', 'id');
|
||||
$rsm->addFieldResult('u', 'u__name', 'name');
|
||||
$rsm->addScalarResult('foo1', 'foo');
|
||||
$rsm->addScalarResult('bar2', 'bar');
|
||||
$rsm->addScalarResult('baz3', 'baz');
|
||||
|
||||
$resultSet = array(
|
||||
array(
|
||||
'u__id' => '1',
|
||||
'u__name' => 'romanb',
|
||||
'foo1' => 'A',
|
||||
'bar2' => 'B',
|
||||
'baz3' => 'C',
|
||||
'foo' => 'bar', // Unknown!
|
||||
),
|
||||
);
|
||||
|
||||
$stmt = new HydratorMockStatement($resultSet);
|
||||
$hydrator = new \Doctrine\ORM\Internal\Hydration\ScalarHydrator($this->_em);
|
||||
|
||||
$result = $hydrator->hydrateAll($stmt, $rsm);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user