ClientTest.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\BrowserKit\Tests;
  11. use Symfony\Component\BrowserKit\Client;
  12. use Symfony\Component\BrowserKit\History;
  13. use Symfony\Component\BrowserKit\CookieJar;
  14. use Symfony\Component\BrowserKit\Request;
  15. use Symfony\Component\BrowserKit\Response;
  16. class SpecialResponse extends Response
  17. {
  18. }
  19. class TestClient extends Client
  20. {
  21. protected $nextResponse = null;
  22. protected $nextScript = null;
  23. public function setNextResponse(Response $response)
  24. {
  25. $this->nextResponse = $response;
  26. }
  27. public function setNextScript($script)
  28. {
  29. $this->nextScript = $script;
  30. }
  31. protected function doRequest($request)
  32. {
  33. if (null === $this->nextResponse) {
  34. return new Response();
  35. }
  36. $response = $this->nextResponse;
  37. $this->nextResponse = null;
  38. return $response;
  39. }
  40. protected function filterResponse($response)
  41. {
  42. if ($response instanceof SpecialResponse) {
  43. return new Response($response->getContent(), $response->getStatus(), $response->getHeaders());
  44. }
  45. return $response;
  46. }
  47. protected function getScript($request)
  48. {
  49. $r = new \ReflectionClass('Symfony\Component\BrowserKit\Response');
  50. $path = $r->getFileName();
  51. return <<<EOF
  52. <?php
  53. require_once('$path');
  54. echo serialize($this->nextScript);
  55. EOF;
  56. }
  57. }
  58. class ClientTest extends \PHPUnit_Framework_TestCase
  59. {
  60. /**
  61. * @covers Symfony\Component\BrowserKit\Client::getHistory
  62. */
  63. public function testGetHistory()
  64. {
  65. $client = new TestClient(array(), $history = new History());
  66. $this->assertSame($history, $client->getHistory(), '->getHistory() returns the History');
  67. }
  68. /**
  69. * @covers Symfony\Component\BrowserKit\Client::getCookieJar
  70. */
  71. public function testGetCookieJar()
  72. {
  73. $client = new TestClient(array(), null, $cookieJar = new CookieJar());
  74. $this->assertSame($cookieJar, $client->getCookieJar(), '->getCookieJar() returns the CookieJar');
  75. }
  76. /**
  77. * @covers Symfony\Component\BrowserKit\Client::getRequest
  78. */
  79. public function testGetRequest()
  80. {
  81. $client = new TestClient();
  82. $client->request('GET', 'http://example.com/');
  83. $this->assertEquals('http://example.com/', $client->getRequest()->getUri(), '->getCrawler() returns the Request of the last request');
  84. }
  85. public function testGetResponse()
  86. {
  87. $client = new TestClient();
  88. $client->setNextResponse(new Response('foo'));
  89. $client->request('GET', 'http://example.com/');
  90. $this->assertEquals('foo', $client->getResponse()->getContent(), '->getCrawler() returns the Response of the last request');
  91. $this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getResponse(), '->getCrawler() returns the Response of the last request');
  92. }
  93. public function testGetInternalResponse()
  94. {
  95. $client = new TestClient();
  96. $client->setNextResponse(new SpecialResponse('foo'));
  97. $client->request('GET', 'http://example.com/');
  98. $this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getInternalResponse());
  99. $this->assertNotInstanceOf('Symfony\Component\BrowserKit\Tests\SpecialResponse', $client->getInternalResponse());
  100. $this->assertInstanceOf('Symfony\Component\BrowserKit\Tests\SpecialResponse', $client->getResponse());
  101. }
  102. public function testGetContent()
  103. {
  104. $json = '{"jsonrpc":"2.0","method":"echo","id":7,"params":["Hello World"]}';
  105. $client = new TestClient();
  106. $client->request('POST', 'http://example.com/jsonrpc', array(), array(), array(), $json);
  107. $this->assertEquals($json, $client->getRequest()->getContent());
  108. }
  109. /**
  110. * @covers Symfony\Component\BrowserKit\Client::getCrawler
  111. */
  112. public function testGetCrawler()
  113. {
  114. $client = new TestClient();
  115. $client->setNextResponse(new Response('foo'));
  116. $crawler = $client->request('GET', 'http://example.com/');
  117. $this->assertSame($crawler, $client->getCrawler(), '->getCrawler() returns the Crawler of the last request');
  118. }
  119. public function testRequestHttpHeaders()
  120. {
  121. $client = new TestClient();
  122. $client->request('GET', '/');
  123. $headers = $client->getRequest()->getServer();
  124. $this->assertEquals('localhost', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header');
  125. $client = new TestClient();
  126. $client->request('GET', 'http://www.example.com');
  127. $headers = $client->getRequest()->getServer();
  128. $this->assertEquals('www.example.com', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header');
  129. $client->request('GET', 'https://www.example.com');
  130. $headers = $client->getRequest()->getServer();
  131. $this->assertTrue($headers['HTTPS'], '->request() sets the HTTPS header');
  132. }
  133. public function testRequestURIConversion()
  134. {
  135. $client = new TestClient();
  136. $client->request('GET', '/foo');
  137. $this->assertEquals('http://localhost/foo', $client->getRequest()->getUri(), '->request() converts the URI to an absolute one');
  138. $client = new TestClient();
  139. $client->request('GET', 'http://www.example.com');
  140. $this->assertEquals('http://www.example.com', $client->getRequest()->getUri(), '->request() does not change absolute URIs');
  141. $client = new TestClient();
  142. $client->request('GET', 'http://www.example.com/');
  143. $client->request('GET', '/foo');
  144. $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
  145. $client = new TestClient();
  146. $client->request('GET', 'http://www.example.com/foo');
  147. $client->request('GET', '#');
  148. $this->assertEquals('http://www.example.com/foo#', $client->getRequest()->getUri(), '->request() uses the previous request for #');
  149. $client->request('GET', '#');
  150. $this->assertEquals('http://www.example.com/foo#', $client->getRequest()->getUri(), '->request() uses the previous request for #');
  151. $client->request('GET', '#foo');
  152. $this->assertEquals('http://www.example.com/foo#foo', $client->getRequest()->getUri(), '->request() uses the previous request for #');
  153. $client = new TestClient();
  154. $client->request('GET', 'http://www.example.com/foo/');
  155. $client->request('GET', 'bar');
  156. $this->assertEquals('http://www.example.com/foo/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
  157. $client = new TestClient();
  158. $client->request('GET', 'http://www.example.com/foo/foobar');
  159. $client->request('GET', 'bar');
  160. $this->assertEquals('http://www.example.com/foo/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
  161. }
  162. public function testRequestReferer()
  163. {
  164. $client = new TestClient();
  165. $client->request('GET', 'http://www.example.com/foo/foobar');
  166. $client->request('GET', 'bar');
  167. $server = $client->getRequest()->getServer();
  168. $this->assertEquals('http://www.example.com/foo/foobar', $server['HTTP_REFERER'], '->request() sets the referer');
  169. }
  170. public function testRequestHistory()
  171. {
  172. $client = new TestClient();
  173. $client->request('GET', 'http://www.example.com/foo/foobar');
  174. $client->request('GET', 'bar');
  175. $this->assertEquals('http://www.example.com/foo/bar', $client->getHistory()->current()->getUri(), '->request() updates the History');
  176. $this->assertEquals('http://www.example.com/foo/foobar', $client->getHistory()->back()->getUri(), '->request() updates the History');
  177. }
  178. public function testRequestCookies()
  179. {
  180. $client = new TestClient();
  181. $client->setNextResponse(new Response('<html><a href="/foo">foo</a></html>', 200, array('Set-Cookie' => 'foo=bar')));
  182. $client->request('GET', 'http://www.example.com/foo/foobar');
  183. $this->assertEquals(array('foo' => 'bar'), $client->getCookieJar()->allValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar');
  184. $client->request('GET', 'bar');
  185. $this->assertEquals(array('foo' => 'bar'), $client->getCookieJar()->allValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar');
  186. }
  187. public function testRequestSecureCookies()
  188. {
  189. $client = new TestClient();
  190. $client->setNextResponse(new Response('<html><a href="/foo">foo</a></html>', 200, array('Set-Cookie' => 'foo=bar; path=/; secure')));
  191. $client->request('GET', 'https://www.example.com/foo/foobar');
  192. $this->assertTrue($client->getCookieJar()->get('foo', '/', 'www.example.com')->isSecure());
  193. }
  194. public function testClick()
  195. {
  196. if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {
  197. $this->markTestSkipped('The "DomCrawler" component is not available');
  198. }
  199. if (!class_exists('Symfony\Component\CssSelector\CssSelector')) {
  200. $this->markTestSkipped('The "CssSelector" component is not available');
  201. }
  202. $client = new TestClient();
  203. $client->setNextResponse(new Response('<html><a href="/foo">foo</a></html>'));
  204. $crawler = $client->request('GET', 'http://www.example.com/foo/foobar');
  205. $client->click($crawler->filter('a')->link());
  206. $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->click() clicks on links');
  207. }
  208. public function testClickForm()
  209. {
  210. if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {
  211. $this->markTestSkipped('The "DomCrawler" component is not available');
  212. }
  213. if (!class_exists('Symfony\Component\CssSelector\CssSelector')) {
  214. $this->markTestSkipped('The "CssSelector" component is not available');
  215. }
  216. $client = new TestClient();
  217. $client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
  218. $crawler = $client->request('GET', 'http://www.example.com/foo/foobar');
  219. $client->click($crawler->filter('input')->form());
  220. $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->click() Form submit forms');
  221. }
  222. public function testSubmit()
  223. {
  224. if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {
  225. $this->markTestSkipped('The "DomCrawler" component is not available');
  226. }
  227. if (!class_exists('Symfony\Component\CssSelector\CssSelector')) {
  228. $this->markTestSkipped('The "CssSelector" component is not available');
  229. }
  230. $client = new TestClient();
  231. $client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
  232. $crawler = $client->request('GET', 'http://www.example.com/foo/foobar');
  233. $client->submit($crawler->filter('input')->form());
  234. $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->submit() submit forms');
  235. }
  236. public function testSubmitPreserveAuth()
  237. {
  238. if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {
  239. $this->markTestSkipped('The "DomCrawler" component is not available');
  240. }
  241. if (!class_exists('Symfony\Component\CssSelector\CssSelector')) {
  242. $this->markTestSkipped('The "CssSelector" component is not available');
  243. }
  244. $client = new TestClient(array('PHP_AUTH_USER' => 'foo', 'PHP_AUTH_PW' => 'bar'));
  245. $client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
  246. $crawler = $client->request('GET', 'http://www.example.com/foo/foobar');
  247. $server = $client->getRequest()->getServer();
  248. $this->assertArrayHasKey('PHP_AUTH_USER', $server);
  249. $this->assertEquals('foo', $server['PHP_AUTH_USER']);
  250. $this->assertArrayHasKey('PHP_AUTH_PW', $server);
  251. $this->assertEquals('bar', $server['PHP_AUTH_PW']);
  252. $client->submit($crawler->filter('input')->form());
  253. $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->submit() submit forms');
  254. $server = $client->getRequest()->getServer();
  255. $this->assertArrayHasKey('PHP_AUTH_USER', $server);
  256. $this->assertEquals('foo', $server['PHP_AUTH_USER']);
  257. $this->assertArrayHasKey('PHP_AUTH_PW', $server);
  258. $this->assertEquals('bar', $server['PHP_AUTH_PW']);
  259. }
  260. public function testFollowRedirect()
  261. {
  262. $client = new TestClient();
  263. $client->followRedirects(false);
  264. $client->request('GET', 'http://www.example.com/foo/foobar');
  265. try {
  266. $client->followRedirect();
  267. $this->fail('->followRedirect() throws a \LogicException if the request was not redirected');
  268. } catch (\Exception $e) {
  269. $this->assertInstanceof('LogicException', $e, '->followRedirect() throws a \LogicException if the request was not redirected');
  270. }
  271. $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected')));
  272. $client->request('GET', 'http://www.example.com/foo/foobar');
  273. $client->followRedirect();
  274. $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any');
  275. $client = new TestClient();
  276. $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected')));
  277. $client->request('GET', 'http://www.example.com/foo/foobar');
  278. $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() automatically follows redirects if followRedirects is true');
  279. $client = new TestClient();
  280. $client->setNextResponse(new Response('', 201, array('Location' => 'http://www.example.com/redirected')));
  281. $client->request('GET', 'http://www.example.com/foo/foobar');
  282. $this->assertEquals('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->followRedirect() does not follow redirect if HTTP Code is not 30x');
  283. $client = new TestClient();
  284. $client->setNextResponse(new Response('', 201, array('Location' => 'http://www.example.com/redirected')));
  285. $client->followRedirects(false);
  286. $client->request('GET', 'http://www.example.com/foo/foobar');
  287. try {
  288. $client->followRedirect();
  289. $this->fail('->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code');
  290. } catch (\Exception $e) {
  291. $this->assertInstanceof('LogicException', $e, '->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code');
  292. }
  293. }
  294. public function testFollowRedirectWithMaxRedirects()
  295. {
  296. $client = new TestClient();
  297. $client->setMaxRedirects(1);
  298. $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected')));
  299. $client->request('GET', 'http://www.example.com/foo/foobar');
  300. $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any');
  301. $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected2')));
  302. try {
  303. $client->followRedirect();
  304. $this->fail('->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached');
  305. } catch (\Exception $e) {
  306. $this->assertInstanceof('LogicException', $e, '->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached');
  307. }
  308. $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected')));
  309. $client->request('GET', 'http://www.example.com/foo/foobar');
  310. $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any');
  311. $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected')));
  312. $client->request('POST', 'http://www.example.com/foo/foobar');
  313. $this->assertEquals('get', $client->getRequest()->getMethod(), '->followRedirect() uses a get for 302');
  314. }
  315. public function testFollowRedirectWithCookies()
  316. {
  317. $client = new TestClient();
  318. $client->followRedirects(false);
  319. $client->setNextResponse(new Response('', 302, array(
  320. 'Location' => 'http://www.example.com/redirected',
  321. 'Set-Cookie' => 'foo=bar',
  322. )));
  323. $client->request('GET', 'http://www.example.com/');
  324. $this->assertEquals(array(), $client->getRequest()->getCookies());
  325. $client->followRedirect();
  326. $this->assertEquals(array('foo' => 'bar'), $client->getRequest()->getCookies());
  327. }
  328. public function testFollowRedirectWithHeaders()
  329. {
  330. $headers = array(
  331. 'HTTP_HOST' => 'www.example.com',
  332. 'HTTP_USER_AGENT' => 'Symfony2 BrowserKit',
  333. 'CONTENT_TYPE' => 'application/vnd.custom+xml',
  334. 'HTTPS' => false,
  335. );
  336. $client = new TestClient();
  337. $client->followRedirects(false);
  338. $client->setNextResponse(new Response('', 302, array(
  339. 'Location' => 'http://www.example.com/redirected',
  340. )));
  341. $client->request('GET', 'http://www.example.com/', array(), array(), array(
  342. 'CONTENT_TYPE' => 'application/vnd.custom+xml',
  343. ));
  344. $this->assertEquals($headers, $client->getRequest()->getServer());
  345. $client->followRedirect();
  346. $headers['HTTP_REFERER'] = 'http://www.example.com/';
  347. $this->assertEquals($headers, $client->getRequest()->getServer());
  348. }
  349. public function testBack()
  350. {
  351. $client = new TestClient();
  352. $parameters = array('foo' => 'bar');
  353. $files = array('myfile.foo' => 'baz');
  354. $server = array('X_TEST_FOO' => 'bazbar');
  355. $content = 'foobarbaz';
  356. $client->request('GET', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content);
  357. $client->request('GET', 'http://www.example.com/foo');
  358. $client->back();
  359. $this->assertEquals('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->back() goes back in the history');
  360. $this->assertArrayHasKey('foo', $client->getRequest()->getParameters(), '->back() keeps parameters');
  361. $this->assertArrayHasKey('myfile.foo', $client->getRequest()->getFiles(), '->back() keeps files');
  362. $this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->back() keeps $_SERVER');
  363. $this->assertEquals($content, $client->getRequest()->getContent(), '->back() keeps content');
  364. }
  365. public function testForward()
  366. {
  367. $client = new TestClient();
  368. $parameters = array('foo' => 'bar');
  369. $files = array('myfile.foo' => 'baz');
  370. $server = array('X_TEST_FOO' => 'bazbar');
  371. $content = 'foobarbaz';
  372. $client->request('GET', 'http://www.example.com/foo/foobar');
  373. $client->request('GET', 'http://www.example.com/foo', $parameters, $files, $server, $content);
  374. $client->back();
  375. $client->forward();
  376. $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->forward() goes forward in the history');
  377. $this->assertArrayHasKey('foo', $client->getRequest()->getParameters(), '->forward() keeps parameters');
  378. $this->assertArrayHasKey('myfile.foo', $client->getRequest()->getFiles(), '->forward() keeps files');
  379. $this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->forward() keeps $_SERVER');
  380. $this->assertEquals($content, $client->getRequest()->getContent(), '->forward() keeps content');
  381. }
  382. public function testReload()
  383. {
  384. $client = new TestClient();
  385. $parameters = array('foo' => 'bar');
  386. $files = array('myfile.foo' => 'baz');
  387. $server = array('X_TEST_FOO' => 'bazbar');
  388. $content = 'foobarbaz';
  389. $client->request('GET', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content);
  390. $client->reload();
  391. $this->assertEquals('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->reload() reloads the current page');
  392. $this->assertArrayHasKey('foo', $client->getRequest()->getParameters(), '->reload() keeps parameters');
  393. $this->assertArrayHasKey('myfile.foo', $client->getRequest()->getFiles(), '->reload() keeps files');
  394. $this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->reload() keeps $_SERVER');
  395. $this->assertEquals($content, $client->getRequest()->getContent(), '->reload() keeps content');
  396. }
  397. public function testRestart()
  398. {
  399. $client = new TestClient();
  400. $client->request('GET', 'http://www.example.com/foo/foobar');
  401. $client->restart();
  402. $this->assertTrue($client->getHistory()->isEmpty(), '->restart() clears the history');
  403. $this->assertEquals(array(), $client->getCookieJar()->all(), '->restart() clears the cookies');
  404. }
  405. public function testInsulatedRequests()
  406. {
  407. if (!class_exists('Symfony\Component\Process\Process')) {
  408. $this->markTestSkipped('The "Process" component is not available');
  409. }
  410. $client = new TestClient();
  411. $client->insulate();
  412. $client->setNextScript("new Symfony\Component\BrowserKit\Response('foobar')");
  413. $client->request('GET', 'http://www.example.com/foo/foobar');
  414. $this->assertEquals('foobar', $client->getResponse()->getContent(), '->insulate() process the request in a forked process');
  415. $client->setNextScript("new Symfony\Component\BrowserKit\Response('foobar)");
  416. try {
  417. $client->request('GET', 'http://www.example.com/foo/foobar');
  418. $this->fail('->request() throws a \RuntimeException if the script has an error');
  419. } catch (\Exception $e) {
  420. $this->assertInstanceof('RuntimeException', $e, '->request() throws a \RuntimeException if the script has an error');
  421. }
  422. }
  423. public function testGetServerParameter()
  424. {
  425. $client = new TestClient();
  426. $this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST'));
  427. $this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
  428. $this->assertEquals('testvalue', $client->getServerParameter('testkey', 'testvalue'));
  429. }
  430. public function testSetServerParameter()
  431. {
  432. $client = new TestClient();
  433. $this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST'));
  434. $this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
  435. $client->setServerParameter('HTTP_HOST', 'testhost');
  436. $this->assertEquals('testhost', $client->getServerParameter('HTTP_HOST'));
  437. $client->setServerParameter('HTTP_USER_AGENT', 'testua');
  438. $this->assertEquals('testua', $client->getServerParameter('HTTP_USER_AGENT'));
  439. }
  440. }