3 namespace RedUNIT\Base;
5 use RedUNIT\Base as Base;
6 use RedBeanPHP\Facade as R;
7 use RedBeanPHP\RedException as RedException;
8 use RedBeanPHP\OODBBean as OODBBean;
14 * When I split the repositories in frozen and fluid I discovered some missed
15 * code-paths in the tests.
16 * These tests are here to make sure the following scenarios work properly
17 * in frozen mode as well.
19 * @file RedUNIT/Base/Frozen.php
20 * @desc Test some scenarios we haven't covered for frozen mode.
21 * @author Gabor de Mooij and the RedBeanPHP Community
22 * @license New BSD/GPLv2
24 * (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
25 * This source file is subject to the New BSD/GPLv2 License that is bundled
26 * with this source code in the file license.txt.
28 class Frozen extends Base
31 * Tests the handling of trashed beans in frozen mode.
32 * Are the lists unset etc?
36 public function testTrash()
39 $book = R::dispense( 'book' );
40 $book->xownPageList[] = R::dispense( 'page' );
41 $book->sharedTagList[] = R::dispense( 'tag' );
43 $book = $book->fresh();
46 $book->xownPageList = array();
49 $book = $book->fresh();
51 asrt( R::count('page'), 0 );
53 $book->xownPageList[] = R::dispense( 'page' );
56 $book = $book->fresh();
58 asrt( R::count('page'), 1 );
64 asrt( R::count('book'), 0 );
65 asrt( R::count('page'), 0 );
66 asrt( R::count('tag'), 1 );
67 asrt( R::count('book_tag'), 0 );
73 * Tests whether invalid list checks are
74 * operational in frozen mode.
78 public function testInvalidList()
81 $book = R::dispense( 'book' );
82 $book->xownPageList[] = R::dispense( 'page' );
83 $book->sharedTagList[] = R::dispense( 'tag' );
87 $book = R::dispense( 'book' );
88 $book->xownPageList[] = 'nonsense';
92 } catch( \Exception $e ) {
100 * Tests whether loading non-existant beans
101 * returns the same results in frozen mode.
105 public function testLoadNonExistant()
108 R::store( R::dispense( 'bean' ) );
110 $bean = R::load( 'bean', 123 );
112 asrt( ( $bean instanceof OODBBean ), TRUE );
113 asrt( $bean->id, 0 );