CurlFetcherTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * OpenWeatherMap-PHP-API — A php api to parse weather data from http://www.OpenWeatherMap.org .
  4. *
  5. * @license MIT
  6. *
  7. * Please see the LICENSE file distributed with this source code for further
  8. * information regarding copyright and licensing.
  9. *
  10. * Please visit the following links to read about the usage policies and the license of
  11. * OpenWeatherMap before using this class:
  12. *
  13. * @see http://www.OpenWeatherMap.org
  14. * @see http://www.OpenWeatherMap.org/terms
  15. * @see http://openweathermap.org/appid
  16. */
  17. namespace Cmfcmf\OpenWeatherMap\Tests\Fetcher;
  18. use \Cmfcmf\OpenWeatherMap\Fetcher\CurlFetcher;
  19. /**
  20. * @requires function curl_version
  21. */
  22. class CurlFetcherTest extends \PHPUnit_Framework_TestCase
  23. {
  24. public function testInvalidUrl()
  25. {
  26. $fetcher = new CurlFetcher();
  27. $content = $fetcher->fetch('http://notexisting.example.com');
  28. $this->assertSame(false, $content);
  29. }
  30. public function testEmptyUrl()
  31. {
  32. $fetcher = new CurlFetcher();
  33. $content = $fetcher->fetch('');
  34. $this->assertSame(false, $content);
  35. }
  36. public function testValidUrl()
  37. {
  38. $fetcher = new CurlFetcher();
  39. $content = $fetcher->fetch('http://httpbin.org/html');
  40. $this->assertContains('Herman Melville', $content);
  41. }
  42. }