FileGetContentsFetcherTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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\FileGetContentsFetcher;
  19. class FileGetContentsFetcherTest extends \PHPUnit_Framework_TestCase
  20. {
  21. protected function setUp()
  22. {
  23. if (!ini_get('allow_url_fopen')) {
  24. $this->markTestSkipped('"allow_url_fopen" is set to off.');
  25. }
  26. }
  27. /**
  28. * @expectedException \PHPUnit_Framework_Error_Warning
  29. */
  30. public function testInvalidUrl()
  31. {
  32. $fetcher = new FileGetContentsFetcher();
  33. $fetcher->fetch('http://notexisting.example.com');
  34. }
  35. /**
  36. * @expectedException \PHPUnit_Framework_Error_Warning
  37. */
  38. public function testEmptyUrl()
  39. {
  40. $fetcher = new FileGetContentsFetcher();
  41. $fetcher->fetch('');
  42. }
  43. public function testValidUrl()
  44. {
  45. $fetcher = new FileGetContentsFetcher();
  46. $content = $fetcher->fetch('http://httpbin.org/html');
  47. $this->assertContains('Herman Melville', $content);
  48. }
  49. }