WeatherTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * Copyright Zikula Foundation 2014 - Zikula Application Framework
  4. *
  5. * This work is contributed to the Zikula Foundation under one or more
  6. * Contributor Agreements and licensed to You under the following license:
  7. *
  8. * @license GNU/LGPv3 (or at your option any later version).
  9. * @package OpenWeatherMap-PHP-Api
  10. *
  11. * Please see the NOTICE file distributed with this source code for further
  12. * information regarding copyright and licensing.
  13. */
  14. namespace Cmfcmf\OpenWeatherMap\Tests\Util;
  15. use \Cmfcmf\OpenWeatherMap\Util\Weather;
  16. class WeatherTest extends \PHPUnit_Framework_TestCase
  17. {
  18. /**
  19. * @var Weather
  20. */
  21. protected $weather;
  22. /**
  23. * @var string
  24. */
  25. protected $description = 'thunderstorm with light rain';
  26. /**
  27. * @var string
  28. */
  29. protected $iconName = '11d';
  30. protected function setUp()
  31. {
  32. $this->weather = new Weather(200, $this->description, $this->iconName);
  33. }
  34. public function test__toString()
  35. {
  36. $expectDescription = $this->description;
  37. $description = $this->weather->__toString();
  38. $this->assertSame($expectDescription, $description);
  39. }
  40. public function testGetIconUrl()
  41. {
  42. $expectIconLink = '//openweathermap.org/img/w/11d.png';
  43. $weather = $this->weather;
  44. $iconLink = $weather->getIconUrl();
  45. $this->assertSame($expectIconLink, $iconLink);
  46. }
  47. public function testSetIconUrlTemplate()
  48. {
  49. $expectIconLink = '//openweathermap.org';
  50. $weather = $this->weather;
  51. $weather::setIconUrlTemplate($expectIconLink);
  52. $resultLink = $weather->getIconUrl();
  53. $this->assertSame($expectIconLink, $resultLink);
  54. }
  55. }