@@ -8,7 +8,7 @@ final class preparedTest extends TestCase {
88 /**
99 * @var Connection
1010 */
11- private $ conn ;
11+ private static $ conn ;
1212
1313 /**
1414 * Next ID for the records
@@ -17,33 +17,37 @@ final class preparedTest extends TestCase {
1717 */
1818 private static $ id = 0 ;
1919
20- public function setUp (): void
20+ public static function setUpBeforeClass (): void
2121 {
22- $ this -> conn = new Connection ("127.0.0.1 " , 50000 , "monetdb " , "monetdb " , "myDatabase " );
22+ self :: $ conn = new Connection ("127.0.0.1 " , 50000 , "monetdb " , "monetdb " , "myDatabase " );
2323 }
2424
2525 public function testCreateTable (): void
2626 {
27- $ this -> conn ->Query ("drop table if exists php_prepared " );
28- $ res = $ this -> conn ->Query ("CREATE TABLE php_prepared (id int, h HUGEINT, b BIGINT, i int, d DECIMAL(38,19), d2 dec(38,0),
29- n numeric(38,2), t timestamp, dat date, r real, f float, dbl double, dbl2 double precision); " );
27+ self :: $ conn ->Query ("drop table if exists php_prepared " );
28+ $ res = self :: $ conn ->Query ("CREATE TABLE php_prepared (id int, h HUGEINT, b BIGINT, i int, d DECIMAL(38,19), d2 dec(38,0),
29+ n numeric(38,2), t timestamp, dat date, r real, f float, dbl double, dbl2 double precision, bo bool, tim time ); " );
3030
3131 $ this ->assertCount (0 , $ res );
3232 }
3333
34- private function InsertValuePrepared (string $ field , $ value , string $ strValue ) {
34+ private function InsertValuePrepared (string $ field , $ value , $ cmpValue ) {
3535 self ::$ id ++;
3636
37- $ this -> conn ->Query ("insert into php_prepared (id, {$ field }) values (?, ?) " , [self ::$ id , $ value ]);
38- $ response = $ this -> conn ->QueryFirst ("select {$ field } from php_prepared where id = ? " , [self ::$ id ]);
37+ self :: $ conn ->Query ("insert into php_prepared (id, {$ field }) values (?, ?) " , [self ::$ id , $ value ]);
38+ $ response = self :: $ conn ->QueryFirst ("select {$ field } from php_prepared where id = ? " , [self ::$ id ]);
3939
40- $ this ->assertEquals ($ strValue , $ response [$ field ]);
40+ $ this ->assertEquals ($ cmpValue , $ response [$ field ]);
4141 }
4242
4343 public function testDec38 (): void {
4444 $ this ->InsertValuePrepared ('d ' , '1234567890123456789.9876543210987654321 ' , '1234567890123456789.9876543210987654321 ' );
4545 }
4646
47+ public function testNull (): void {
48+ $ this ->InsertValuePrepared ('d ' , null , null );
49+ }
50+
4751 public function testInt32 (): void {
4852 $ this ->InsertValuePrepared ('i ' , 123456 , '123456 ' );
4953 $ this ->InsertValuePrepared ('i ' , '123456 ' , '123456 ' );
@@ -87,4 +91,26 @@ public function testReal(): void {
8791 $ this ->InsertValuePrepared ('r ' , 3.141592 , '3.141592 ' );
8892 $ this ->InsertValuePrepared ('r ' , '3.141592 ' , '3.141592 ' );
8993 }
94+
95+ public function testBool (): void {
96+ $ this ->InsertValuePrepared ('bo ' , true , 'true ' );
97+ $ this ->InsertValuePrepared ('bo ' , false , 'false ' );
98+ $ this ->InsertValuePrepared ('bo ' , 'true ' , 'true ' );
99+ $ this ->InsertValuePrepared ('bo ' , 'false ' , 'false ' );
100+ $ this ->InsertValuePrepared ('bo ' , 'FALSE ' , 'false ' );
101+ $ this ->InsertValuePrepared ('bo ' , 1 , 'true ' );
102+ $ this ->InsertValuePrepared ('bo ' , 0 , 'false ' );
103+ $ this ->InsertValuePrepared ('bo ' , 'enabled ' , 'true ' );
104+ $ this ->InsertValuePrepared ('bo ' , 'disabled ' , 'false ' );
105+ $ this ->InsertValuePrepared ('bo ' , 't ' , 'true ' );
106+ $ this ->InsertValuePrepared ('bo ' , 'f ' , 'false ' );
107+ }
108+
109+ public function testTime (): void {
110+ $ dt = new DateTime ();
111+
112+ $ this ->InsertValuePrepared ('tim ' , '12:28 ' , '12:28:00 ' );
113+ $ this ->InsertValuePrepared ('tim ' , '12:28:34 ' , '12:28:34 ' );
114+ $ this ->InsertValuePrepared ('tim ' , $ dt , $ dt ->format ("H:i:s " ));
115+ }
90116}
0 commit comments