Yaffs site version 1.1
[yaffs-website] / vendor / gabordemooij / redbean / testing / RedUNIT / Base / Issue303.php
1 <?php
2
3 namespace RedUNIT\Base;
4
5 use RedUNIT\Base as Base;
6 use RedBeanPHP\Facade as R;
7 use RedBeanPHP\RedException as RedException;
8
9 /**
10  * Issue303
11  *
12  * Tests whether this specific issue on github has been resolved.
13  * Test whether we have two different exception messages for
14  * properties and values.
15  *
16  * @file    RedUNIT/Base/Issue303.php
17  * @desc    Issue #303 - Split bean property exception.
18  * @author  Gabor de Mooij and the RedBeanPHP Community
19  * @license New BSD/GPLv2
20  *
21  * (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
22  * This source file is subject to the New BSD/GPLv2 License that is bundled
23  * with this source code in the file license.txt.
24  */
25 class Issue303 extends Base
26 {
27         /**
28          * Test whether we have two different exception messages for
29          * properties and values.
30          *
31          * @return void
32          */
33         public function testIssue303()
34         {
35                 testpack( 'Testing Issue #303 - Test splitting bean exception property/value.' );
36
37                 try {
38                         R::store( R::dispense( 'invalidbean' )->setAttr( 'invalid.property', 'value' ) );
39                         fail();
40                 } catch (RedException $e ) {
41                         asrt( $e->getMessage(), 'Invalid Bean property: property invalid.property' );
42                 }
43
44                 try {
45                         R::store( R::dispense( 'invalidbean' )->setAttr( 'property', array() ) );
46                         fail();
47                 } catch (RedException $e ) {
48                         asrt( $e->getMessage(), 'Invalid Bean value: property property' );
49                 }
50
51                 try {
52                         R::store( R::dispense( 'invalidbean' )->setAttr( 'property', new \stdClass ) );
53                         fail();
54                 } catch (RedException $e ) {
55                         asrt( $e->getMessage(), 'Invalid Bean value: property property' );
56                 }
57         }
58 }