public function testOneDeepLvl() { $scope = array('a' => '1', 'c' => '@3', 'g' => array('1' => '1', '0' => '[0]')); $this->assertEquals('a=1&c=%403&g[1]=1&g[0]=%5B0%5D', UrlParamsUtils::toStringOneDeepLvl($scope)); $scope['z'] = array('2' => array('8' => '8')); try { UrlParamsUtils::toStringOneDeepLvl($scope); $this->fail('expected exception'); } catch (BaseException $e) { $this->assertEquals('urlencode() expects parameter 1 to be string, array given', $e->getMessage()); } }
private function getPostFields(HttpRequest $request) { if ($request->hasBody()) { return $request->getBody(); } else { if ($this->oldUrlConstructor) { return UrlParamsUtils::toStringOneDeepLvl($request->getPost()); } else { $fileList = array_map(array($this, 'fileFilter'), UrlParamsUtils::toParamsList($request->getFiles())); if (empty($fileList)) { return UrlParamsUtils::toString($request->getPost()); } else { $postList = UrlParamsUtils::toParamsList($request->getPost()); if (!is_null($atParam = $this->findAtParamInPost($postList))) { throw new NetworkException('Security excepion: not allowed send post param ' . $atParam . ' which begins from @ in request which contains files'); } return array_merge($postList, $fileList); } } } }