lithium\tests\cases\data\entity\DocumentTest::testNestedObjectExistence PHP Метод

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

Tests that documents nested within existing documents also exist, and vice versa.
    public function testNestedObjectExistence()
    {
        $model = $this->_model;
        $data = array('foo' => array('bar' => 'bar', 'baz' => 'dib'), 'deeply' => array('nested' => array('object' => array('should' => 'exist'))));
        $doc = new Document(compact('model', 'data') + array('exists' => false));
        $this->assertFalse($doc->exists());
        $this->assertFalse($doc->foo->exists());
        $doc = new Document(compact('model', 'data') + array('exists' => true));
        $this->assertTrue($doc->exists());
        $this->assertTrue($doc->foo->exists());
        $this->assertTrue($doc->deeply->nested->object->exists());
        $doc = new Document(compact('model', 'data') + array('exists' => true));
        $subDoc = new Document(array('data' => array('bar' => 'stuff')));
        $this->assertTrue($doc->foo->exists());
        $this->assertFalse($subDoc->exists());
        $doc->foo = $subDoc;
        $this->assertTrue($doc->exists());
        $this->assertFalse($doc->foo->exists());
        $doc->sync();
        $this->assertTrue($doc->foo->exists());
    }