public function testDecrementException() { try { QueryBuilder::decrement(array('key' => 0, 'num' => 'text'))->fromDataBase($this->getDatabase())->fromTable($this->getTableName())->where(Comparison::EQUAL, array('key' => 105)); } catch (WrongParameterException $e) { return true; } $this->fail('Not fall decrementBuilder with wrong parameters.'); }
public function testBugSingleSelectWithWhereIn() { $selectQueryBuilder = QueryBuilder::select(array('key', 'float'))->fromDataBase($this->getDatabase())->fromTable($this->getTableName())->whereIn('key', array(42, 4))->limit(5); $selectQuery = $this->getReader()->addQueryBuilder($selectQueryBuilder); $this->getReader()->getResultList(); $selectResult = $selectQuery->getResult(); $this->assertTrue($selectResult->isSuccessfully(), 'Fall selectQuery is not successfully done.'); $this->assertEquals(array(array('key' => '42', 'float' => '3.14159'), array('key' => '4', 'float' => '4')), $selectResult->getData(), 'Fall returned data not valid.'); }
public function testSingleUpdate() { $updateQueryBuilder = QueryBuilder::update(array('key' => 2, 'varchar' => 'test update query'))->fromDataBase($this->getDatabase())->fromTable($this->getTableName())->where(Comparison::EQUAL, array('key' => 2)); $updateQuery = $this->getWriter()->addQueryBuilder($updateQueryBuilder); $selectQuery = $this->getWriter()->selectByIndex($updateQuery->getIndexId(), Comparison::EQUAL, array('2')); $this->getWriter()->getResultList(); $updateResult = $updateQuery->getResult(); $this->assertTrue($updateResult->isSuccessfully(), 'Fall updateQuery is not successfully done.'); $this->assertEquals(array(array('key' => '2', 'varchar' => 'test update query')), $selectQuery->getResult()->getData(), 'Fall returned data not valid.'); }
public function testSingleDelete() { $deleteQueryBuilder = QueryBuilder::delete(); $deleteQueryBuilder->fromDataBase($this->getDatabase())->fromTable($this->getTableName())->where(Comparison::EQUAL, array('key' => 5)); $deleteQuery = $this->getWriter()->addQueryBuilder($deleteQueryBuilder); $selectQuery = $this->getWriter()->selectByIndex($deleteQuery->getIndexId(), Comparison::EQUAL, array('5')); $this->getWriter()->getResultList(); $updateResult = $deleteQuery->getResult(); $this->assertTrue($updateResult->isSuccessfully(), 'Fall deleteQuery is not successfully done.'); $data = $selectQuery->getResult()->getData(); $this->assertTrue(empty($data), 'Fall returned data not valid.'); }
public function testSingleInsert() { $forInsert = array('key' => '123', 'date' => '0000-00-00', 'float' => '1.02', 'varchar' => 'char', 'text' => 'text', 'set' => 'a', 'union' => 'a'); $insertQueryBuilder = QueryBuilder::insert(); $insertQueryBuilder->toDatabase($this->getDatabase())->toTable($this->getTableName())->addRow($forInsert); $insertQuery = $this->getWriter()->addQueryBuilder($insertQueryBuilder); $selectQuery = $this->getWriter()->selectByIndex($insertQuery->getIndexId(), Comparison::EQUAL, array('123')); $this->getWriter()->getResultList(); $insertResult = $insertQuery->getResult(); $this->assertTrue($insertResult->isSuccessfully(), 'Fall insertQuery is not successfully done.'); $data = $selectQuery->getResult()->getData(); $this->assertEquals(array($forInsert), $data, 'Fall returned data not valid.'); }