2
0

ProxyAdapterTest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. require_once dirname(__FILE__) . '/SocketTest.php';
  3. /**
  4. * Zend_Http_Client_Adapter_Proxy test suite.
  5. *
  6. * In order to run, TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY must point to a working
  7. * proxy server, which can access TESTS_ZEND_HTTP_CLIENT_BASEURI.
  8. *
  9. * See TestConfiguration.php.dist for more information.
  10. *
  11. * @category Zend
  12. * @package Zend_Http_Client
  13. * @subpackage UnitTests
  14. * @version $Id$
  15. * @copyright
  16. * @license http://framework.zend.com/license/new-bsd New BSD License
  17. */
  18. class Zend_Http_Client_ProxyAdapterTest extends Zend_Http_Client_SocketTest
  19. {
  20. /**
  21. * Configuration array
  22. *
  23. * @var array
  24. */
  25. protected function setUp()
  26. {
  27. if (defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY') &&
  28. TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY) {
  29. list($host, $port) = explode(':', TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY, 2);
  30. if (! $host)
  31. $this->markTestSkipped("No valid proxy host name or address specified.");
  32. $port = (int) $port;
  33. if ($port == 0) {
  34. $port = 8080;
  35. } else {
  36. if (($port < 1 || $port > 65535))
  37. $this->markTestSkipped("$port is not a valid proxy port number. Should be between 1 and 65535.");
  38. }
  39. $user = '';
  40. $pass = '';
  41. if (defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER') &&
  42. TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER)
  43. $user = TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER;
  44. if (defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS') &&
  45. TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS)
  46. $pass = TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS;
  47. $this->config = array(
  48. 'adapter' => 'Zend_Http_Client_Adapter_Proxy',
  49. 'proxy_host' => $host,
  50. 'proxy_port' => $port,
  51. 'proxy_user' => $user,
  52. 'proxy_pass' => $pass,
  53. );
  54. parent::setUp();
  55. } else {
  56. $this->markTestSkipped("Zend_Http_Client proxy server tests are not enabled in TestConfiguration.php");
  57. }
  58. }
  59. public function testGetLastRequest()
  60. {
  61. /**
  62. * This test will never work for the proxy adapter (and shouldn't!)
  63. * because the proxy server modifies the request which is sent back in
  64. * the TRACE response
  65. */
  66. }
  67. }