public function testDeleteParsing()
{
$this->specify("DELETE PHQL queries don't work as expected", function () {
$expected = array('tables' => array('robots'), 'models' => array(Robots::class));
$query = new Query('DELETE FROM ' . Robots::class);
$query->setDI($this->di);
expect($query->parse())->equals($expected);
$expected = array('tables' => array(array('robots', null, 'r')), 'models' => array(Robots::class), 'where' => array('type' => 'binary-op', 'op' => '>', 'left' => array('type' => 'qualified', 'domain' => 'r', 'name' => 'id', 'balias' => 'id'), 'right' => array('type' => 'literal', 'value' => '100')));
$query = new Query('DELETE FROM ' . Robots::class . ' AS r WHERE r.id > 100');
$query->setDI($this->di);
expect($query->parse())->equals($expected);
$expected = array('tables' => array(array('robots', null, 'r')), 'models' => array(Robots::class), 'where' => array('type' => 'binary-op', 'op' => '>', 'left' => array('type' => 'qualified', 'domain' => 'r', 'name' => 'id', 'balias' => 'id'), 'right' => array('type' => 'literal', 'value' => '100')));
$query = new Query('DELETE FROM ' . Robots::class . ' r WHERE r.id > 100');
$query->setDI($this->di);
expect($query->parse())->equals($expected);
$expected = array('tables' => array(array('robots', null, 'r')), 'models' => array(Robots::class), 'where' => array('type' => 'binary-op', 'op' => '>', 'left' => array('type' => 'qualified', 'domain' => 'r', 'name' => 'id', 'balias' => 'id'), 'right' => array('type' => 'literal', 'value' => '100')));
$query = new Query('DELETE FROM ' . Robots::class . ' as r WHERE r.id > 100');
$query->setDI($this->di);
expect($query->parse())->equals($expected);
$expected = array('tables' => array(array('robots', null, 'r')), 'models' => array(Robots::class), 'limit' => array('number' => array('type' => 'literal', 'value' => '10')));
$query = new Query('DELETE FROM ' . Robots::class . ' r LIMIT 10');
$query->setDI($this->di);
expect($query->parse())->equals($expected);
$expected = array('tables' => array(array('robots', null, 'r')), 'models' => array(Robots::class), 'where' => array('type' => 'binary-op', 'op' => '>', 'left' => array('type' => 'qualified', 'domain' => 'r', 'name' => 'id', 'balias' => 'id'), 'right' => array('type' => 'literal', 'value' => '100')), 'limit' => array('number' => array('type' => 'literal', 'value' => '10')));
$query = new Query('DELETE FROM ' . Robots::class . ' r WHERE r.id > 100 LIMIT 10');
$query->setDI($this->di);
expect($query->parse())->equals($expected);
// Issue 1011
$expected = array('tables' => array(array('robots', null, 'r')), 'models' => array(Robots::class), 'where' => array('type' => 'binary-op', 'op' => '>', 'left' => array('type' => 'qualified', 'domain' => 'r', 'name' => 'id', 'balias' => 'id'), 'right' => array('type' => 'literal', 'value' => '100')), 'limit' => array('number' => array('type' => 'placeholder', 'value' => ':limit')));
$query = new Query('DELETE FROM ' . Robots::class . ' r WHERE r.id > 100 LIMIT :limit:');
$query->setDI($this->di);
expect($query->parse())->equals($expected);
});
}