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