3 namespace RedUNIT\Base;
5 use RedUNIT\Base as Base;
6 use RedBeanPHP\Facade as R;
7 use RedBeanPHP\SimpleModel as SimpleModel;
12 * Tests whether this specific issue on github has been resolved.
13 * Issue #259 - Stash Cache breaks model delegation in open().
15 * @file RedUNIT/Base/Issue259.php
16 * @desc Issue #259 - Stash cache breaks model delegation in open().
17 * @author Gabor de Mooij and the RedBeanPHP Community
18 * @license New BSD/GPLv2
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.
24 class Issue259 extends Base
27 * Test to make sure stash cache works with recursively opening models
32 public function testIssue259()
34 testpack( 'Testing Issue #259 - Stash Cache breaks model delegation in open().' );
35 $mother = R::dispense( 'mother' );
36 $mother->desc = 'I am mother';
38 $child = R::dispense( 'child' );
39 $child->mother = $mother;
40 $child->desc = 'I am child';
41 $id = R::store( $child );
42 R::findOne( 'child', ' id = ?', array( $id ) );
43 R::find( 'child', ' id = ? ', array( $id ) );
44 R::load( 'child', $id );
50 class Model_Mother extends SimpleModel
52 public function open()
55 // $this & $bean are both referencing child incorrectly!
56 asrt( $this->bean->desc, 'I am mother' );
62 class Model_Child extends SimpleModel
64 public function open()
67 asrt( $this->bean->desc, 'I am child' );