3 namespace RedUNIT\Base;
5 use RedUNIT\Base as Base;
6 use RedBeanPHP\Facade as R;
11 * Tests whether this specific issue on github has been resolved.
12 * Pull Request #530 - OODBBean __set() checks if $property is a field link
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
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.
24 class PullRequest530 extends Base
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>
36 public function testPullRequest530()
38 testpack( 'Testing Pull Request #530 - OODBBean __set() checks if $property is a field link' );
40 R::setAutoResolve(true);
41 $linkedObjects = R::dispense('linkedobject', 2);
42 R::storeAll($linkedObjects);
43 $tester = R::dispense('parent');
44 $tester->linked = $linkedObjects[0];
46 $tester = R::findOne('parent');
47 asrt($tester->linked->id, $linkedObjects[0]->id);
48 $tester->linked_id = $linkedObjects[1]->id;
50 asrt($tester->linked->id, $linkedObjects[1]->id);