Query/tests/core/db_qp_test.php

57 lines
1.3 KiB
PHP
Raw Normal View History

2012-08-02 11:59:11 -04:00
<?php
/**
* Query
*
* Free Query Builder / Database Abstraction Layer
*
* @package Query
* @author Timothy J. Warren
2013-01-02 14:26:42 -05:00
* @copyright Copyright (c) 2012 - 2013
2012-08-02 11:59:11 -04:00
* @link https://github.com/aviat4ion/Query
* @license http://philsturgeon.co.uk/code/dbad-license
*/
// --------------------------------------------------------------------------
2012-08-09 12:15:36 -04:00
/**
* Tests for the Query Parser
*/
2014-02-14 22:08:19 -05:00
class QPTest extends Query_TestCase {
2012-08-02 11:59:11 -04:00
2014-02-14 22:08:19 -05:00
public function setUp()
2012-08-02 11:59:11 -04:00
{
$this->parser = new Query_Parser();
}
public function TestGeneric()
{
2012-08-09 12:15:36 -04:00
$matches = $this->parser->parse_join('table1.field1=table2.field2');
$this->assertIdentical($matches['combined'], array(
'table1.field1', '=', 'table2.field2'
));
2012-08-02 11:59:11 -04:00
}
2014-02-14 22:08:19 -05:00
public function testGeneric2()
2012-08-02 11:59:11 -04:00
{
2012-08-09 12:15:36 -04:00
$matches = $this->parser->parse_join('db1.table1.field1!=db2.table2.field2');
$this->assertIdentical($matches['combined'], array(
'db1.table1.field1','!=','db2.table2.field2'
));
}
2012-08-02 11:59:11 -04:00
2014-02-14 22:08:19 -05:00
public function testWUnderscore()
2012-08-09 12:15:36 -04:00
{
$matches = $this->parser->parse_join('table_1.field1 = tab_le2.field_2');
$this->assertIdentical($matches['combined'], array(
'table_1.field1', '=', 'tab_le2.field_2'
));
2012-08-02 11:59:11 -04:00
}
2014-02-14 22:08:19 -05:00
public function testFunction()
2012-08-09 12:15:36 -04:00
{
$matches = $this->parser->parse_join('table1.field1 > SUM(3+5)');
$this->assertIdentical($matches['combined'], array(
'table1.field1', '>', 'SUM(3+5)'
));
}
2012-08-02 11:59:11 -04:00
}