Yaffs site version 1.1
[yaffs-website] / vendor / gabordemooij / redbean / testing / RedUNIT / Base / Nuke.php
1 <?php
2
3 namespace RedUNIT\Base;
4
5 use RedUNIT\Base as Base;
6 use RedBeanPHP\Facade as R;
7
8 /**
9  * Nuke
10  *
11  * Tests the nuke() command. The nuke command empties an entire database
12  * and should also be capable of removing all foreign keys, constraints and
13  * indexes.
14  *
15  * @file    RedUNIT/Base/Nuke.php
16  * @desc    Test the nuke() function.
17  * @author  Gabor de Mooij and the RedBeanPHP Community
18  * @license New BSD/GPLv2
19  *
20  * (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
21  * This source file is subject to the New BSD/GPLv2 License that is bundled
22  * with this source code in the file license.txt.
23  */
24 class Nuke extends Base
25 {
26         /**
27          * Nuclear test suite.
28          *
29          * @return void
30          */
31         public function testNuke()
32         {
33                 $bean = R::dispense( 'bean' );
34                 R::store( $bean );
35                 asrt( count( R::getWriter()->getTables() ), 1 );
36                 R::nuke();
37                 asrt( count( R::getWriter()->getTables() ), 0 );
38                 $bean = R::dispense( 'bean' );
39                 R::store( $bean );
40                 asrt( count( R::getWriter()->getTables() ), 1 );
41                 R::freeze();
42                 R::nuke();
43                 // No effect
44                 asrt( count( R::getWriter()->getTables() ), 1 );
45                 R::freeze( FALSE );
46         }
47 }