2
0

ProxyAdapterTest.php 2.4 KB

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