lithium\tests\cases\util\CollectionTest::testCollectionHandlers PHP Method

testCollectionHandlers() public method

    public function testCollectionHandlers()
    {
        $obj = new stdClass();
        $obj->a = "b";
        $handlers = array('stdClass' => function ($v) {
            return (array) $v;
        });
        $data = array('test' => new Collection(array('data' => compact('obj')))) + compact('obj');
        $collection = new Collection(compact('data'));
        $expected = array('test' => array('obj' => array('a' => 'b')), 'obj' => array('a' => 'b'));
        $this->assertIdentical($expected, $collection->to('array', compact('handlers')));
        $handlers = array('stdClass' => function ($v) {
            return $v;
        });
        $expected = array('test' => compact('obj')) + compact('obj');
        $this->assertIdentical($expected, $collection->to('array', compact('handlers')));
    }