/**
  * Test that we can extract values from a City instance
  *
  * @covers \OpenWeatherMap\Hydrator\Strategy\CityStrategy::extract
  */
 public function testExtract()
 {
     $cityStrategy = new CityStrategy();
     $city = new City();
     $city->setId(123)->setName('Los Angeles');
     $values = $cityStrategy->extract($city);
     $this->assertArrayHasKey('id', $values);
     $this->assertArrayHasKey('name', $values);
 }
 /**
  * Test that we can extract the values from the supplied Current instance
  *
  * @covers \OpenWeatherMap\Hydrator\Strategy\CurrentStrategy::extract
  */
 public function testExtract()
 {
     $name = 'Los Angeles,US';
     $city = new City();
     $city->setName($name);
     $current = new Current();
     $current->setCity($city);
     $strategy = new CurrentStrategy();
     $values = $strategy->extract($current);
     $this->assertArrayHasKey('city', $values);
     $this->assertEquals($name, $values['city']['name']);
 }
Example #3
0
 /**
  * Test that we can get and set the Sun
  *
  * @covers \OpenWeatherMap\Entity\City::getSun
  * @covers \OpenWeatherMap\Entity\City::setSun
  */
 public function testGetSetSun()
 {
     $sun = new Sun();
     $city = new City();
     $this->assertNull($city->getSun());
     $this->assertSame($city, $city->setSun($sun));
     $this->assertSame($sun, $city->getSun());
 }