ZendHttpAdapterTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * This file is part of the HttpAdapter library.
  4. *
  5. * (c) Antoine Corcy <contact@sbin.dk>
  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 Tests\HttpAdapter;
  11. use HttpAdapter\ZendHttpAdapter;
  12. use Zend\Http\Client;
  13. /**
  14. * @author William Durand <william.durand1@gmail.com>
  15. * @author Antoine Corcy <contact@sbin.dk>
  16. */
  17. class ZendHttpAdapterTest extends \PHPUnit_Framework_TestCase
  18. {
  19. protected $zend;
  20. protected function setUp()
  21. {
  22. if (!class_exists('Zend\Http\Client')) {
  23. $this->markTestSkipped('Zend library has to be installed');
  24. }
  25. $this->zend = new ZendHttpAdapter();
  26. }
  27. public function testGetNullContent()
  28. {
  29. $this->assertNull($this->zend->getContent(null));
  30. }
  31. public function testGetFalseContent()
  32. {
  33. $this->assertNull($this->zend->getContent(false));
  34. }
  35. public function testGetName()
  36. {
  37. $this->assertEquals('zend', $this->zend->getName());
  38. }
  39. public function testGetContent()
  40. {
  41. try {
  42. $content = $this->zend->getContent('http://www.google.fr');
  43. } catch (\Exception $e) {
  44. $this->fail('Exception catched: ' . $e->getMessage());
  45. }
  46. $this->assertNotNull($content);
  47. $this->assertContains('google', $content);
  48. }
  49. }