lithium\tests\cases\net\http\MediaTest::testDecode PHP Метод

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

Tests that types with decode handlers can properly decode content.
public testDecode ( )
    public function testDecode()
    {
        $data = array('movies' => array(array('name' => 'Shaun of the Dead', 'year' => 2004), array('name' => 'V for Vendetta', 'year' => 2005)));
        $jsonEncoded = '{"movies":[{"name":"Shaun of the Dead","year":2004},';
        $jsonEncoded .= '{"name":"V for Vendetta","year":2005}]}';
        $result = Media::decode('json', $jsonEncoded);
        $this->assertEqual($data, $result);
        $formEncoded = 'movies%5B0%5D%5Bname%5D=Shaun+of+the+Dead&movies%5B0%5D%5Byear%5D=2004';
        $formEncoded .= '&movies%5B1%5D%5Bname%5D=V+for+Vendetta&movies%5B1%5D%5Byear%5D=2005';
        $result = Media::decode('form', $formEncoded);
        $this->assertEqual($data, $result);
    }