3 namespace RedUNIT\CUBRID;
5 use RedBeanPHP\Facade as R;
6 use \RedBeanPHP\RedException as RedException;
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/CUBRID/Setget.php
26 * @desc Tests whether values are stored correctly.
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 \RedUNIT\CUBRID
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.2500000000000000" );
50 asrt( setget( -0.25 ), "-0.2500000000000000" );
52 asrt( setget( "0.12345678" ), "0.1234567800000000" );
53 asrt( setget( 0.12345678 ), "0.1234567800000000" );
55 asrt( setget( "-0.12345678" ), "-0.1234567800000000" );
56 asrt( setget( -0.12345678 ), "-0.1234567800000000" );
58 asrt( setget( "2147483647" ), "2147483647" );
59 asrt( setget( 2147483647 ), "2147483647" );
61 asrt( setget( -2147483647 ), "-2147483647" );
62 asrt( setget( "-2147483647" ), "-2147483647" );
64 asrt( setget( "2147483648" ), "2147483648.0000000000000000" );
65 asrt( setget( "-2147483648" ), "-2147483648.0000000000000000" );
67 asrt( setget( "199936710040730" ), "199936710040730.0000000000000000" );
68 asrt( setget( "-199936710040730" ), "-199936710040730.0000000000000000" );
76 public function testDates()
78 asrt( setget( "2010-10-11" ), "2010-10-11" );
79 asrt( setget( "2010-10-11 12:10" ), "2010-10-11 12:10" );
80 asrt( setget( "2010-10-11 12:10:11" ), "2010-10-11 12:10:11.000" );
81 asrt( setget( "x2010-10-11 12:10:11" ), "x2010-10-11 12:10:11" );
89 public function testStrings()
91 asrt( setget( "a" ), "a" );
92 asrt( setget( "." ), "." );
93 asrt( setget( "\"" ), "\"" );
94 asrt( setget( "just some text" ), "just some text" );
102 public function testBool()
104 asrt( setget( TRUE ), "1" );
105 asrt( setget( FALSE ), "0" );
106 asrt( setget( "TRUE" ), "TRUE" );
107 asrt( setget( "FALSE" ), "FALSE" );
115 public function testNull()
117 asrt( setget( "NULL" ), "NULL" );
118 asrt( setget( "NULL" ), "NULL" );
120 asrt( setget( "0123" ), "0123" );
121 asrt( setget( "0000123" ), "0000123" );
123 asrt( setget( NULL ), NULL );
125 asrt( ( setget( 0 ) == 0 ), TRUE );
126 asrt( ( setget( 1 ) == 1 ), TRUE );
128 asrt( ( setget( TRUE ) == TRUE ), TRUE );
129 asrt( ( setget( FALSE ) == FALSE ), TRUE );
131 // minor test sqltest
132 $a = R::getWriter()->sqlStateIn( '000', array() );
133 // Unknown state must return FALSE.
136 R::getWriter()->esc( '`aaa`' );
138 } catch (\Exception $e ) {
141 asrt( ( $e instanceof RedException ), TRUE );