Esempio n. 1
0
 /**
  * Test checks passing query params and dependency injector into
  * constructor
  */
 public function testConstructor()
 {
     require 'unit-tests/config.db.php';
     if (empty($configMysql)) {
         $this->markTestSkipped("Test skipped");
         return;
     }
     $di = $this->_getDI();
     $params = array('models' => 'Robots', 'columns' => array('id', 'name', 'status'), 'conditions' => "a > 5", 'group' => array('type', 'source'), 'having' => "b < 5", 'order' => array('name', 'created'), 'limit' => 10, 'offset' => 15);
     $builder = new Builder($params, $di);
     $expectedPhql = "SELECT id, name, status FROM [Robots] " . "WHERE a > 5 GROUP BY [type], [source] " . "HAVING b < 5 ORDER BY [name], [created] " . "LIMIT :APL0: OFFSET :APL1:";
     $this->assertEquals($expectedPhql, $builder->getPhql());
     $this->assertEquals($di, $builder->getDI());
 }
Esempio n. 2
0
 /**
  * Test checks passing query params and dependency injector into
  * constructor
  */
 public function testConstructor()
 {
     $this->specify("Query Builders don't work with params in the constructor", function () {
         $di = $this->di;
         $params = ["models" => Robots::class, "columns" => ["id", "name", "status"], "conditions" => "a > 5", "group" => ["type", "source"], "having" => "b < 5", "order" => ["name", "created"], "limit" => 10, "offset" => 15];
         $builder = new Builder($params, $di);
         $expectedPhql = "SELECT id, name, status FROM [" . Robots::class . "] " . "WHERE a > 5 GROUP BY [type], [source] " . "HAVING b < 5 ORDER BY [name], [created] " . "LIMIT :APL0: OFFSET :APL1:";
         expect($expectedPhql)->equals($builder->getPhql());
         expect($di)->equals($builder->getDI());
     });
 }