RedUNIT\Base\Aliasing::testAssociated PHP Method

testAssociated() public method

Associating two beans, then loading the associated bean
public testAssociated ( ) : void
return void
    public function testAssociated()
    {
        $person = R::dispense('person');
        $person->name = 'John';
        R::store($person);
        $course = R::dispense('course');
        $course->name = 'Math';
        R::store($course);
        $course->teacher = $person;
        $id = R::store($course);
        $course = R::load('course', $id);
        $teacher = $course->fetchAs('person')->teacher;
        asrt($teacher->name, 'John');
        //Trying to load a property that has an invalid name
        $book = R::dispense('book');
        $page = R::dispense('page');
        $book->wrongProperty = array($page);
        try {
            $book->wrongProperty[] = $page;
            R::store($book);
            fail();
        } catch (RedException $e) {
            pass();
        } catch (\Exception $e) {
            fail();
        }
    }