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

testHandlers() public method

public testHandlers ( )
    public function testHandlers()
    {
        $model = $this->_model;
        $schema = new DocumentSchema(array('fields' => array('_id' => array('type' => 'id'), 'date' => array('type' => 'date')), 'types' => array('date' => 'date'), 'handlers' => array('date' => function ($v) {
            return (object) $v;
        })));
        $handlers = array('stdClass' => function ($value) {
            return date('d/m/Y H:i', strtotime($value->scalar));
        });
        $array = new Document(compact('model', 'schema', 'handlers') + array('data' => array('_id' => '2', 'date' => '2013-06-06 13:00:00')));
        $expected = array('_id' => '2', 'date' => '06/06/2013 13:00');
        $this->assertIdentical($expected, $array->to('array', array('indexed' => false)));
    }