1
0
mirror of synced 2024-12-13 22:56:04 +03:00

DDC-644 - Added more tests for Hydrators and unknown to be skipped columns

This commit is contained in:
Benjamin Eberlei 2010-07-28 22:09:43 +02:00
parent 56b3c0e8b0
commit d6a1075b53
3 changed files with 84 additions and 0 deletions

View File

@ -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));
}
}

View File

@ -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
*/

View File

@ -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);
}
}