public function testShouldCreateSqlInsertStatementWithParameters()
 {
     $table = "test";
     $value = StringUtils::generateRandomAlphaNumeric(10);
     $insert = new InsertStatement($table);
     $insert->addParameter('content', $value);
     $sql = $insert->toSql();
     $this->assertThat(trim($sql), $this->equalTo("INSERT INTO {$table} (content) VALUES (:content)"));
     $this->assertThat($insert->hasParameters(), $this->isTrue());
     $parameters = $insert->getParameters();
     $this->assertThat(array_pop($parameters), $this->equalTo($value));
 }
 public function testShouldExecuteSqlQuery()
 {
     $table = "tests";
     $content = "Test Content 1001";
     $statement = new InsertStatement($table);
     $statement->addParameter("content", $content);
     $database = new Database(self::$phactory->getConnection());
     $lastInsertId = $database->execute($statement);
     $this->assertThat($lastInsertId, $this->logicalNot($this->isNull()));
     $query = Query::getInstance();
     $query->select()->from($table)->where(Restrictions::eq("id", $lastInsertId));
     $test = $database->query($query)->uniqueResult();
     $this->assertThat($test['content'], $this->equalTo($content));
 }
 public function save(ModelInterface $model)
 {
     $statement = new InsertStatement($model->table());
     $statement->setParameters($model->extract());
     return $this->getDatabase()->execute($statement);
 }