3 namespace RedUNIT\Postgres;
5 use RedUNIT\Postgres as Postgres;
6 use RedBeanPHP\Facade as R;
11 * This class has been designed to test set/get operations
12 * for a specific Query Writer / Adapter. Since RedBeanPHP
13 * creates columns based on values it's essential that you
14 * get back the 'same' value as you put in - or - if that's
15 * not the case, that there are at least very clear rules
16 * about what to expect. Examples of possible issues tested in
19 * - Test whether booleans are returned correctly (they will become integers)
20 * - Test whether large numbers are preserved
21 * - Test whether floating point numbers are preserved
22 * - Test whether date/time values are preserved
25 * @file RedUNIT/Postgres/Setget.php
26 * @desc Tests whether values are correctly stored.
27 * @author Gabor de Mooij and the RedBeanPHP Community
28 * @license New BSD/GPLv2
30 * (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
31 * This source file is subject to the New BSD/GPLv2 License that is bundled
32 * with this source code in the file license.txt.
34 class Setget extends Postgres
41 public function testNumbers()
43 asrt( setget( "-1" ), "-1" );
44 asrt( setget( -1 ), "-1" );
46 asrt( setget( "1.0" ), "1" );
47 asrt( setget( 1.0 ), "1" );
49 asrt( setget( "-0.25" ), "-0.25" );
50 asrt( setget( -0.25 ), "-0.25" );
52 asrt( setget( "3.20" ), "3.20" );
53 asrt( setget( "13.20" ), "13.20" );
54 asrt( setget( "134.20" ), "134.20" );
55 asrt( setget( 3.21 ), '3.21' );
57 asrt( setget( "0.12345678" ), "0.12345678" );
58 asrt( setget( 0.12345678 ), "0.12345678" );
60 asrt( setget( "-0.12345678" ), "-0.12345678" );
61 asrt( setget( -0.12345678 ), "-0.12345678" );
63 asrt( setget( "2147483647" ), "2147483647" );
64 asrt( setget( 2147483647 ), "2147483647" );
66 asrt( setget( -2147483647 ), "-2147483647" );
67 asrt( setget( "-2147483647" ), "-2147483647" );
69 asrt( setget( "2147483648" ), "2147483648" );
70 asrt( setget( "-2147483648" ), "-2147483648" );
72 asrt( setget( "199936710040730" ), "199936710040730" );
73 asrt( setget( "-199936710040730" ), "-199936710040730" );
81 public function testDates()
83 asrt( setget( "2010-10-11" ), "2010-10-11" );
84 asrt( setget( "2010-10-11 12:10" ), "2010-10-11 12:10" );
85 asrt( setget( "2010-10-11 12:10:11" ), "2010-10-11 12:10:11" );
86 asrt( setget( "x2010-10-11 12:10:11" ), "x2010-10-11 12:10:11" );
94 public function testStrings()
96 asrt( setget( "a" ), "a" );
97 asrt( setget( "." ), "." );
98 asrt( setget( "\"" ), "\"" );
99 asrt( setget( "just some text" ), "just some text" );
107 public function testBool()
109 asrt( setget( TRUE ), "1" );
110 asrt( setget( FALSE ), "0" );
112 asrt( setget( "TRUE" ), "TRUE" );
113 asrt( setget( "FALSE" ), "FALSE" );
121 public function testNull()
123 asrt( setget( "NULL" ), "NULL" );
124 asrt( setget( "NULL" ), "NULL" );
126 asrt( setget( NULL ), NULL );
128 asrt( ( setget( 0 ) == 0 ), TRUE );
129 asrt( ( setget( 1 ) == 1 ), TRUE );
131 asrt( ( setget( TRUE ) == TRUE ), TRUE );
132 asrt( ( setget( FALSE ) == FALSE ), TRUE );