| [ Index ] |
PHP Cross Reference of GlotPress |
[Summary view] [Print] [Text view]
1 <?php 2 require_once ('init.php'); 3 4 $GLOBALS['gpdb']->mytable = 'mytable'; 5 6 class GP_My_Table extends GP_Thing { 7 var $field_names = array('id', 'name', 'description'); 8 var $table_basename = 'mytable'; 9 } 10 11 class GP_Test_Thing extends GP_UnitTestCase { 12 13 function setUp() { 14 parent::setUp(); 15 $this->t = new GP_My_Table; 16 } 17 18 function test_sql_condition_from_php_value() { 19 $this->assertEquals( '= 5', $this->t->sql_condition_from_php_value( 5 ) ); 20 $this->assertEquals( '= 5', $this->t->sql_condition_from_php_value( '5' ) ); 21 $this->assertEquals( "= 'baba'", $this->t->sql_condition_from_php_value( 'baba' ) ); 22 $this->assertEquals( "IS NULL", $this->t->sql_condition_from_php_value( null ) ); 23 $this->assertEquals( array('= 5', '= 10'), $this->t->sql_condition_from_php_value( array( 5, 10 ) ) ); 24 $this->assertEquals( array("= 'baba'", "= 10", "= 'don\\'t'"), $this->t->sql_condition_from_php_value( array( 'baba', '10', "don't" ) ) ); 25 } 26 27 function test_sql_from_conditions() { 28 $this->assertEquals( 'a = 5', $this->t->sql_from_conditions( array('a' => 5) ) ); 29 $this->assertEquals( "(a = 5 OR a = 6) AND b = 'baba'", $this->t->sql_from_conditions( array('a' => array(5, 6), 'b' => 'baba' ) ) ); 30 } 31 32 function test_sql_from_order() { 33 $this->assertEquals( '', $this->t->sql_from_order( null ) ); 34 $this->assertEquals( '', $this->t->sql_from_order( '' ) ); 35 $this->assertEquals( '', $this->t->sql_from_order( array() ) ); 36 $this->assertEquals( '', $this->t->sql_from_order( array(), 'baba' ) ); 37 $this->assertEquals( 'ORDER BY x', $this->t->sql_from_order( 'x' ) ); 38 $this->assertEquals( 'ORDER BY table.field', $this->t->sql_from_order( 'table.field' ) ); 39 $this->assertEquals( 'ORDER BY table.field ASC', $this->t->sql_from_order( 'table.field ASC' ) ); 40 $this->assertEquals( 'ORDER BY table.field', $this->t->sql_from_order( array( 'table.field' ) ) ); 41 $this->assertEquals( 'ORDER BY table.field ASC', $this->t->sql_from_order( 'table.field', 'ASC' ) ); 42 $this->assertEquals( 'ORDER BY table.field ASC', $this->t->sql_from_order( array( 'table.field', 'ASC' ) ) ); 43 $this->assertEquals( 'ORDER BY table.field ASC', $this->t->sql_from_order( array( 'table.field', 'ASC' ), 'baba' ) ); 44 } 45 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu May 24 03:59:35 2012 | Hosted by follow the white rabbit. |