lithium\tests\cases\data\entity\DocumentTest::testSetMultipleNested PHP Method

testSetMultipleNested() public method

    public function testSetMultipleNested()
    {
        $doc = new Document(array('model' => $this->_model));
        $doc->_id = 123;
        $doc->type = 'father';
        $doc->set(array('children' => array(array('_id' => 124, 'type' => 'child', 'children' => null), array('_id' => 125, 'type' => 'child', 'children' => null))));
        $this->assertEqual('father', $doc->type);
        $this->assertInstanceOf('lithium\\data\\collection\\DocumentSet', $doc->children);
        $expected = array('_id' => 124, 'type' => 'child', 'children' => null);
        $result = $doc->children[124]->data();
        $this->assertEqual($expected, $result);
        $expected = array('_id' => 125, 'type' => 'child', 'children' => null);
        $result = $doc->children[125]->data();
        // @todo Make $result = $doc->children->{1}->data(); work as well (and ...->{'1'}->...)
        $this->assertEqual($expected, $result);
    }