Yaffs site version 1.1
[yaffs-website] / vendor / gabordemooij / redbean / testing / RedUNIT / Mysql / Double.php
1 <?php
2
3 namespace RedUNIT\Mysql;
4
5 use RedUNIT\Mysql as Mysql;
6 use RedBeanPHP\Facade as R;
7
8 /**
9  * Double
10  *
11  * Tests whether double precision values are correctly stored and
12  * preserved.
13  *
14  * @file    RedUNIT/Mysql/Double.php
15  * @desc    Tests handling of double precision values.
16  * @author  Gabor de Mooij and the RedBeanPHP Community
17  * @license New BSD/GPLv2
18  *
19  * (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
20  * This source file is subject to the New BSD/GPLv2 License that is bundled
21  * with this source code in the file license.txt.
22  */
23 class Double extends Mysql
24 {
25         /**
26          * Test storage of doubles.
27          *
28          * @return void
29          */
30         public function testDouble()
31         {
32                 $toolbox = R::getToolBox();
33                 $adapter = $toolbox->getDatabaseAdapter();
34                 $writer  = $toolbox->getWriter();
35                 $redbean = $toolbox->getRedBean();
36                 $pdo     = $adapter->getDatabase();
37                 $largeDouble = 999999888889999922211111; //8.88889999922211e+17;
38                 $page = $redbean->dispense( "page" );
39                 $page->weight = $largeDouble;
40                 $id = $redbean->store( $page );
41                 $cols = $writer->getColumns( 'page' );
42                 asrt( $cols['weight'], 'double' );
43                 $page = $redbean->load( 'page', $id );
44                 $page->name = 'dont change the numbers!';
45                 $redbean->store( $page );
46                 $page = $redbean->load( 'page', $id );
47                 $cols = $writer->getColumns( 'page' );
48                 asrt( $cols['weight'], 'double' );
49         }
50 }