1
0
mirror of synced 2025-02-10 17:29:27 +03:00

Simplified test: invalid entities must make it in the UnitOfWork manually, via registerManaged

This commit is contained in:
Marco Pivetta 2016-07-07 20:28:21 +02:00
parent 5b8b548bd4
commit 2829174267

View File

@ -375,11 +375,7 @@ class UnitOfWorkTest extends OrmTestCase
*/ */
public function testAddToIdentityMapValidIdentifiers($entity, $idHash) public function testAddToIdentityMapValidIdentifiers($entity, $idHash)
{ {
$this->_unitOfWork->registerManaged( $this->_unitOfWork->persist($entity);
$entity,
$this->_emMock->getClassMetadata(get_class($entity))->getIdentifierValues($entity),
[]
);
$this->_unitOfWork->addToIdentityMap($entity); $this->_unitOfWork->addToIdentityMap($entity);
// note: cloning to avoid lookup by spl_object_hash() // note: cloning to avoid lookup by spl_object_hash()
@ -428,20 +424,15 @@ class UnitOfWorkTest extends OrmTestCase
* @dataProvider entitiesWithInvalidIdentifiersProvider * @dataProvider entitiesWithInvalidIdentifiersProvider
* *
* @param object $entity * @param object $entity
* @param array $identifier
* *
* @return void * @return void
*/ */
public function testAddToIdentityMapInvalidIdentifiers($entity) public function testAddToIdentityMapInvalidIdentifiers($entity, array $identifier)
{ {
$this->_unitOfWork->registerManaged(
$entity,
$this->_emMock->getClassMetadata(get_class($entity))->getIdentifierValues($entity),
[]
);
$this->expectException(ORMInvalidArgumentException::class); $this->expectException(ORMInvalidArgumentException::class);
$this->_unitOfWork->addToIdentityMap($entity); $this->_unitOfWork->registerManaged($entity, $identifier, []);
} }
@ -456,10 +447,10 @@ class UnitOfWorkTest extends OrmTestCase
$secondNullString->id1 = uniqid('id1', true); $secondNullString->id1 = uniqid('id1', true);
return [ return [
'null string, single field' => [new EntityWithStringIdentifier()], 'null string, single field' => [new EntityWithStringIdentifier(), ['id' => null]],
'null strings, two fields' => [new EntityWithCompositeStringIdentifier()], 'null strings, two fields' => [new EntityWithCompositeStringIdentifier(), ['id1' => null, 'id2' => null]],
'first null string, two fields' => [$firstNullString], 'first null string, two fields' => [$firstNullString, ['id1' => null, 'id2' => $firstNullString->id2]],
'second null string, two fields' => [$secondNullString], 'second null string, two fields' => [$secondNullString, ['id1' => $secondNullString->id1, 'id2' => null]],
]; ];
} }
} }