Exemplo n.º 1
0
 protected function getTestingRows(QueryBuilder $queryBuilder)
 {
     $queryBuilder->select('configvalue')->from('*PREFIX*appconfig')->where($queryBuilder->expr()->eq('appid', $queryBuilder->expr()->literal('testFirstResult')))->orderBy('configkey', 'ASC');
     $query = $queryBuilder->execute();
     $rows = [];
     while ($row = $query->fetch()) {
         $rows[] = $row['configvalue'];
     }
     $query->closeCursor();
     return $rows;
 }
Exemplo n.º 2
0
 /**
  * @dataProvider dataAddSelect
  *
  * @param array $selectArguments
  * @param array $expected
  * @param string $expectedLiteral
  */
 public function testAddSelect($selectArguments, $expected, $expectedLiteral = '')
 {
     $this->deleteTestingRows();
     $this->createTestingRows();
     $this->queryBuilder->select('appid');
     call_user_func_array([$this->queryBuilder, 'addSelect'], $selectArguments);
     $this->queryBuilder->from('*PREFIX*appconfig')->where($this->queryBuilder->expr()->eq('appid', $this->queryBuilder->expr()->literal('testFirstResult')))->orderBy('configkey', 'ASC')->setMaxResults(1);
     $query = $this->queryBuilder->execute();
     $row = $query->fetch();
     $query->closeCursor();
     foreach ($expected as $key => $value) {
         $this->assertArrayHasKey($key, $row);
         $this->assertEquals($value, $row[$key]);
         unset($row[$key]);
     }
     if ($expectedLiteral) {
         $this->assertEquals([$expectedLiteral], array_values($row));
     } else {
         $this->assertEmpty($row);
     }
     $this->deleteTestingRows();
 }