/** * @param \Rawebone\Ormish\Table $tbl * @param \Rawebone\Ormish\SqlGeneratorInterface $gen * @param \Rawebone\Ormish\Executor $ex */ function it_should_include_additional_params($tbl, $gen, $ex) { $tbl->table()->willReturn("table"); $gen->findWhere("table", "a = ?")->willReturn("query"); $ex->query("query", array(1))->willThrow(new ExecutionException("", "", "", array())); $this->run("a = ?", 1)->shouldReturn(array()); }
/** * @param \Rawebone\Ormish\Entity $ent * @param \Rawebone\Ormish\Table $tbl * @param \Rawebone\Ormish\SqlGeneratorInterface $gen * @param \Rawebone\Ormish\Executor $ex */ function it_should_try_to_update_and_fail($ent, $tbl, $gen, $ex) { $tbl->readOnly()->willReturn(false); $tbl->id()->willReturn("id"); $tbl->table()->willReturn("table"); $ent->id = 1; $ent->changes()->willReturn(array()); $gen->update("table", array(), "id", 1)->willReturn(array("query", array())); $ex->exec("query", array())->willThrow(new ExecutionException("", "", "", array())); $this->run($ent)->shouldReturn(false); }
/** * @param \Rawebone\Ormish\Table $tbl * @param \Rawebone\Ormish\SqlGeneratorInterface $gen * @param \Rawebone\Ormish\Executor $ex * @param \Rawebone\Ormish\Utilities\Populater $pop */ function it_should_return_null_if_no_records_returned($tbl, $gen, $ex, $pop, \PDOStatement $stmt) { $tbl->table()->willReturn("table"); $tbl->id()->willReturn("id"); $tbl->model()->willReturn("Entity"); $tbl->readOnly()->willReturn(true); $gen->find("table", "id")->willReturn("query"); $ex->query("query", array(1))->willReturn($stmt); $pop->populate($stmt, "Entity")->willReturn(array()); $this->run(1)->shouldReturn(null); }
/** * @param \Rawebone\Ormish\Utilities\EntityManager $em * @param \Rawebone\Ormish\Entity $ent * @param \Rawebone\Ormish\Table $tbl * @param \Rawebone\Ormish\Database $db */ function it_should_return_a_new_entity_instance($em, $ent, $tbl, $db) { $entity = 'Rawebone\\Ormish\\Entity'; $id = "id"; $readOnly = false; $tbl->model()->willReturn($entity); $tbl->id()->willReturn($id); $tbl->readOnly()->willReturn($readOnly); $em->create($entity, $id, array())->willReturn($ent); $em->prepare($ent, Argument::type('Rawebone\\Ormish\\GatewayInterface'), $db, $readOnly)->shouldBeCalled(); $this->run(array())->shouldReturn($ent); }
/** * Attaches a table to the database for use. * * @param \Rawebone\Ormish\Table $tbl * @return \Rawebone\Ormish\Database */ public function attach(Table $tbl) { $gate = new Gateway($this, $tbl, $this->factory); $this->tables[$tbl->table()] = $gate; return $this; }