3 namespace RedUNIT\Base;
5 use RedUNIT\Base as Base;
6 use RedBeanPHP\Facade as R;
7 use RedBeanPHP\SimpleModel as SimpleModel;
12 * Test boxing and unboxing of beans.
14 * @file RedUNIT/Base/Boxing.php
15 * @desc Tests bean boxing and unboxing functionality.
16 * @author Gabor de Mooij and the RedBeanPHP Community
17 * @license New BSD/GPLv2
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.
23 class Boxing extends Base
31 public function testBoxing()
34 $bean = R::dispense( 'boxedbean' )->box();
37 $bean = R::dispense( 'boxedbean' );
38 $bean->sharedBoxbean = R::dispense( 'boxedbean' )->box();
41 $bean = R::dispense( 'boxedbean' );
42 $bean->ownBoxedbean = R::dispense( 'boxedbean' )->box();
45 $bean = R::dispense( 'boxedbean' );
46 $bean->other = R::dispense( 'boxedbean' )->box();
49 $bean = R::dispense( 'boxedbean' );
50 $bean->title = 'MyBean';
52 asrt( ( $box instanceof \Model_Boxedbean ), TRUE );
57 * Test fix for issue #512 - thanks for reporting Bernhard H.
58 * OODBBean::__toString() implementation only works with C_ERR_IGNORE
62 public function testToStringIssue512()
64 R::setErrorHandlingFUSE( \RedBeanPHP\OODBBean::C_ERR_FATAL );
65 $boxedBean = R::dispense( 'boxedbean' );
66 $str = (string) $boxedBean;
67 asrt( $str, '{"id":0}' ); //no fatal error
68 R::setErrorHandlingFUSE( FALSE );