Yaffs site version 1.1
[yaffs-website] / vendor / gabordemooij / redbean / testing / RedUNIT / Base / Nuke.php
diff --git a/vendor/gabordemooij/redbean/testing/RedUNIT/Base/Nuke.php b/vendor/gabordemooij/redbean/testing/RedUNIT/Base/Nuke.php
new file mode 100644 (file)
index 0000000..857e7c5
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+
+namespace RedUNIT\Base;
+
+use RedUNIT\Base as Base;
+use RedBeanPHP\Facade as R;
+
+/**
+ * Nuke
+ *
+ * Tests the nuke() command. The nuke command empties an entire database
+ * and should also be capable of removing all foreign keys, constraints and
+ * indexes.
+ *
+ * @file    RedUNIT/Base/Nuke.php
+ * @desc    Test the nuke() function.
+ * @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 Nuke extends Base
+{
+       /**
+        * Nuclear test suite.
+        *
+        * @return void
+        */
+       public function testNuke()
+       {
+               $bean = R::dispense( 'bean' );
+               R::store( $bean );
+               asrt( count( R::getWriter()->getTables() ), 1 );
+               R::nuke();
+               asrt( count( R::getWriter()->getTables() ), 0 );
+               $bean = R::dispense( 'bean' );
+               R::store( $bean );
+               asrt( count( R::getWriter()->getTables() ), 1 );
+               R::freeze();
+               R::nuke();
+               // No effect
+               asrt( count( R::getWriter()->getTables() ), 1 );
+               R::freeze( FALSE );
+       }
+}