lithium\tests\cases\data\source\mongo_db\ExporterTest::testSubObjectCastingOnSave PHP Метод

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

Test that sub-objects are properly casted on creating a new Document.
    public function testSubObjectCastingOnSave()
    {
        $model = $this->_model;
        $model::schema(array('_id' => array('type' => 'id'), 'sub.foo' => array('type' => 'boolean'), 'bar' => array('type' => 'boolean')));
        $data = array('sub' => array('foo' => 0), 'bar' => 1);
        $doc = new Document(compact('data', 'model'));
        $this->assertIdentical(true, $doc->bar);
        $this->assertIdentical(false, $doc->sub->foo);
        $data = array('sub.foo' => '1', 'bar' => '0');
        $doc = new Document(compact('data', 'model', 'schema'));
        $this->assertIdentical(false, $doc->bar);
        $this->assertIdentical(true, $doc->sub->foo);
    }