3 namespace RedUNIT\Blackhole;
5 use RedUNIT\Blackhole as Blackhole;
6 use RedBeanPHP\Facade as R;
7 use RedBeanPHP\OODBBean as OODBBean;
8 use RedBeanPHP\SimpleModel as SimpleModel;
13 * Tests whether we can convert a bean to a model and
14 * a model to a bean. This process is called boxing and
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
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.
27 class Fusebox extends Blackhole
30 * Test type hinting with boxed model
32 * @param Model_Soup $soup
34 private function giveMeSoup( \Model_Soup $soup )
36 asrt( ( $soup instanceof \Model_Soup ), TRUE );
37 asrt( 'A bit too salty', $soup->taste() );
38 asrt( 'tomato', $soup->flavour );
44 * @param OODBBean $bean
46 private function giveMeBean( OODBBean $bean )
48 asrt( ( $bean instanceof OODBBean ), TRUE );
49 asrt( 'A bit too salty', $bean->taste() );
50 asrt( 'tomato', $bean->flavour );
58 public function testBasicBox()
60 $soup = R::dispense( 'soup' );
61 $soup->flavour = 'tomato';
62 $this->giveMeSoup( $soup->box() );
63 $this->giveMeBean( $soup->box()->unbox() );
64 $this->giveMeBean( $soup );