Yaffs site version 1.1
[yaffs-website] / vendor / gabordemooij / redbean / testing / RedUNIT / Base / Issue303.php
diff --git a/vendor/gabordemooij/redbean/testing/RedUNIT/Base/Issue303.php b/vendor/gabordemooij/redbean/testing/RedUNIT/Base/Issue303.php
new file mode 100644 (file)
index 0000000..626b419
--- /dev/null
@@ -0,0 +1,58 @@
+<?php
+
+namespace RedUNIT\Base;
+
+use RedUNIT\Base as Base;
+use RedBeanPHP\Facade as R;
+use RedBeanPHP\RedException as RedException;
+
+/**
+ * Issue303
+ *
+ * Tests whether this specific issue on github has been resolved.
+ * Test whether we have two different exception messages for
+ * properties and values.
+ *
+ * @file    RedUNIT/Base/Issue303.php
+ * @desc    Issue #303 - Split bean property exception.
+ * @author  Gabor de Mooij and the RedBeanPHP Community
+ * @license New BSD/GPLv2
+ *
+ * (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
+ * This source file is subject to the New BSD/GPLv2 License that is bundled
+ * with this source code in the file license.txt.
+ */
+class Issue303 extends Base
+{
+       /**
+        * Test whether we have two different exception messages for
+        * properties and values.
+        *
+        * @return void
+        */
+       public function testIssue303()
+       {
+               testpack( 'Testing Issue #303 - Test splitting bean exception property/value.' );
+
+               try {
+                       R::store( R::dispense( 'invalidbean' )->setAttr( 'invalid.property', 'value' ) );
+                       fail();
+               } catch (RedException $e ) {
+                       asrt( $e->getMessage(), 'Invalid Bean property: property invalid.property' );
+               }
+
+               try {
+                       R::store( R::dispense( 'invalidbean' )->setAttr( 'property', array() ) );
+                       fail();
+               } catch (RedException $e ) {
+                       asrt( $e->getMessage(), 'Invalid Bean value: property property' );
+               }
+
+               try {
+                       R::store( R::dispense( 'invalidbean' )->setAttr( 'property', new \stdClass ) );
+                       fail();
+               } catch (RedException $e ) {
+                       asrt( $e->getMessage(), 'Invalid Bean value: property property' );
+               }
+       }
+}