Yaffs site version 1.1
[yaffs-website] / vendor / gabordemooij / redbean / testing / RedUNIT / Base / PullRequest530.php
1 <?php
2
3 namespace RedUNIT\Base;
4
5 use RedUNIT\Base as Base;
6 use RedBeanPHP\Facade as R;
7
8 /**
9  * PullRequest530
10  *
11  * Tests whether this specific issue on github has been resolved.
12  * Pull Request #530 - OODBBean __set() checks if $property is a field link 
13  *
14  * @file    RedUNIT/Base/PullRequest530.php
15  * @desc    Pull Request #530 - OODBBean __set() checks if $property is a field link
16  * @author  Gabor de Mooij and the RedBeanPHP Community
17  * @license New BSD/GPLv2
18  *
19  * (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
20  * This source file is subject to the New BSD/GPLv2 License that is bundled
21  * with this source code in the file license.txt.
22  */
23  
24 class PullRequest530 extends Base
25 {
26         /**
27          * testPullRequest530
28          * 
29          * Test to check if OODBBean correctly stores a bean if a field link is set directly.
30          * (We have to unset the linked bean (if loaded), so that the Repository::processEmbeddedBean
31          * function call does not update the field link property and overwrites the change
32          * in the following statement: <code>if ($bean->$linkField != $id) $bean->$linkField = $id;</code>
33          *
34          * @return void
35          */
36         public function testPullRequest530()
37         {
38                 testpack( 'Testing Pull Request #530 - OODBBean __set() checks if $property is a field link' );
39                 R::freeze(false);
40                 R::setAutoResolve(true);
41                 $linkedObjects = R::dispense('linkedobject', 2);
42                 R::storeAll($linkedObjects);
43                 $tester = R::dispense('parent');
44                 $tester->linked = $linkedObjects[0];
45                 R::store($tester);
46                 $tester = R::findOne('parent');
47                 asrt($tester->linked->id, $linkedObjects[0]->id);
48                 $tester->linked_id = $linkedObjects[1]->id;
49                 R::store($tester);
50                 asrt($tester->linked->id, $linkedObjects[1]->id);
51         }
52 }
53
54 ?>