ProxyAdapterTest.php 2.2 KB

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