RedUNIT\Base\Association::testOneToOne PHP Метод

testOneToOne() публичный Метод

The rule is, one-to-ones are supposes to be in the same table, this is just for some legacy tables not designed to work with RedBeanPHP at all.
public testOneToOne ( ) : void
Результат void
    public function testOneToOne()
    {
        testpack('Testing one-to-ones');
        $author = R::dispense('author')->setAttr('name', 'a');
        $bio = R::dispense('bio')->setAttr('name', 'a');
        R::storeAll(array($author, $bio));
        $id1 = $author->id;
        $author = R::dispense('author')->setAttr('name', 'b');
        $bio = R::dispense('bio')->setAttr('name', 'b');
        R::storeAll(array($author, $bio));
        $x = $author->one('bio');
        $y = $bio->one('author');
        asrt($x->name, $bio->name);
        asrt($y->name, $author->name);
        asrt($x->id, $bio->id);
        asrt($y->id, $author->id);
        $id2 = $author->id;
        list($a, $b) = R::loadMulti('author,bio', $id1);
        asrt($a->name, $b->name);
        asrt($a->name, 'a');
        list($a, $b) = R::loadMulti('author,bio', $id2);
        asrt($a->name, $b->name);
        asrt($a->name, 'b');
        list($a, $b) = R::loadMulti(array('author', 'bio'), $id1);
        asrt($a->name, $b->name);
        asrt($a->name, 'a');
        list($a, $b) = R::loadMulti(array('author', 'bio'), $id2);
        asrt($a->name, $b->name);
        asrt($a->name, 'b');
        asrt(is_array(R::loadMulti(NULL, 1)), TRUE);
        asrt(count(R::loadMulti(NULL, 1)) === 0, TRUE);
    }