/** * Prepares an Entity for use in the application. * * @param \Rawebone\Ormish\Entity $entity * @param \Rawebone\Ormish\GatewayInterface $gateway * @param \Rawebone\Ormish\Database $db * @param boolean $readOnly */ public function prepare(Entity $entity, GatewayInterface $gateway, Database $db, $readOnly) { $shadow = (bool) $readOnly ? new NullShadow() : new Shadow(); $shadow->update($entity->all()); $entity->letDatabase($db); $entity->letShadow($shadow); $entity->letGateway($gateway); }
function it_should_prepare_an_entity_with_a_real_shadow(Entity $ent, GatewayInterface $gate, Database $db) { $readOnly = false; $ent->all()->willReturn(array())->shouldBeCalled(); $ent->letDatabase($db)->shouldBeCalled(); $ent->letGateway($gate)->shouldBeCalled(); $ent->letShadow(Argument::type('Rawebone\\Ormish\\Utilities\\Shadow'))->shouldBeCalled(); $this->prepare($ent, $gate, $db, $readOnly); }