Yaffs site version 1.1
[yaffs-website] / vendor / gabordemooij / redbean / testing / RedUNIT / Blackhole / Fusebox.php
1 <?php
2
3 namespace RedUNIT\Blackhole;
4
5 use RedUNIT\Blackhole as Blackhole;
6 use RedBeanPHP\Facade as R;
7 use RedBeanPHP\OODBBean as OODBBean;
8 use RedBeanPHP\SimpleModel as SimpleModel;
9
10 /**
11  * Fusebox
12  *
13  * Tests whether we can convert a bean to a model and
14  * a model to a bean. This process is called boxing and
15  * unboxing.
16  *
17  * @file    RedUNIT/Blackhole/Fusebox.php
18  * @desc    Tests Boxing/Unboxing of beans.
19  * @author  Gabor de Mooij and the RedBeanPHP Community
20  * @license New BSD/GPLv2
21  *
22  * (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
23  * This source file is subject to the New BSD/GPLv2 License that is bundled
24  * with this source code in the file license.txt.
25  */
26
27 class Fusebox extends Blackhole
28 {
29         /**
30          * Test type hinting with boxed model
31          *
32          * @param Model_Soup $soup
33          */
34         private function giveMeSoup( \Model_Soup $soup )
35         {
36                 asrt( ( $soup instanceof \Model_Soup ), TRUE );
37                 asrt( 'A bit too salty', $soup->taste() );
38                 asrt( 'tomato', $soup->flavour );
39         }
40
41         /**
42          * Test unboxing
43          *
44          * @param OODBBean $bean
45          */
46         private function giveMeBean( OODBBean $bean )
47         {
48                 asrt( ( $bean instanceof OODBBean ), TRUE );
49                 asrt( 'A bit too salty', $bean->taste() );
50                 asrt( 'tomato', $bean->flavour );
51         }
52
53         /**
54          * Test boxing.
55          *
56          * @return void
57          */
58         public function testBasicBox()
59         {
60                 $soup = R::dispense( 'soup' );
61                 $soup->flavour = 'tomato';
62                 $this->giveMeSoup( $soup->box() );
63                 $this->giveMeBean( $soup->box()->unbox() );
64                 $this->giveMeBean( $soup );
65         }
66 }