http_socket_lib.test.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. App::import('Lib', 'Tools.HttpSocketLib');
  3. class HttpSocketLibTestCase extends CakeTestCase {
  4. function setUp() {
  5. $this->HttpSocketLib = new HttpSocketLib();
  6. $this->assertTrue(is_object($this->HttpSocketLib));
  7. }
  8. function TearDown() {
  9. unset($this->HttpSocketLib);
  10. }
  11. function testFetch() {
  12. $url = 'http://maps.google.de';
  13. $is = $this->HttpSocketLib->fetch($url);
  14. //echo returns($is);
  15. $this->assertTrue(!empty($is));
  16. $url = 'http://sscfmaps.sfdgoogle.eede';
  17. $is = $this->HttpSocketLib->fetch($url);
  18. echo returns($is);
  19. $this->assertFalse($is);
  20. $error = $this->HttpSocketLib->error();
  21. echo returns($error);
  22. $this->assertTrue(!empty($error));
  23. $this->assertEqual($this->HttpSocketLib->debug, 'curl');
  24. }
  25. function testFetchPhp() {
  26. $this->HttpSocketLib = new HttpSocketLib('php');
  27. $url = 'http://maps.google.ch';
  28. $is = $this->HttpSocketLib->fetch($url);
  29. //echo returns($is);
  30. $this->assertTrue(!empty($is));
  31. $this->assertEqual($this->HttpSocketLib->debug, 'php');
  32. }
  33. function testFetchCake() {
  34. $this->HttpSocketLib = new HttpSocketLib('cake');
  35. $url = 'http://maps.google.at';
  36. $is = $this->HttpSocketLib->fetch($url);
  37. //echo returns($is);
  38. $this->assertTrue(!empty($is));
  39. $this->assertEqual($this->HttpSocketLib->debug, 'cake');
  40. }
  41. }
  42. ?>