public function testGetForecast()
 {
     $cityWoeid = $this->getMock('\\Th3Mouk\\YahooWeatherBundle\\Entity\\City');
     $cityWoeid->expects($this->any())->method('getWoeid')->will($this->returnValue(12726473));
     $forecastRepository = $this->getMockBuilder('\\Doctrine\\ORM\\EntityRepository')->setMethods(array('findOneBy'))->disableOriginalConstructor()->getMock();
     $forecastRepository->expects($this->any())->method('findOneBy')->will($this->returnValue(null));
     $entityManager = $this->getMockBuilder('\\Doctrine\\ORM\\EntityManager')->setMethods(array('getRepository', 'persist', 'flush'))->disableOriginalConstructor()->getMock();
     $entityManager->expects($this->any())->method('getRepository')->will($this->returnValue($forecastRepository));
     $entityManager->expects($this->any())->method('persist')->will($this->returnValue(null));
     $entityManager->expects($this->any())->method('flush')->will($this->returnValue(null));
     $historyManager = new HistoryManager($this->api, $entityManager);
     $forecasts = $historyManager->getForecast($cityWoeid);
     $currentDate = new \DateTime();
     $dateInterval = new \DateInterval('P1D');
     $this->assertSame(count($forecasts), 10);
     foreach ($forecasts as $forecast) {
         $this->assertSame($forecast->getDate()->format('Y-m-d'), $currentDate->format('Y-m-d'));
         $this->assertNotNull($forecast->getCode());
         $this->assertNotNull($forecast->getLow());
         $this->assertNotNull($forecast->getHigh());
         $this->assertNotNull($forecast->getText());
         $this->assertNotNull($forecast->getUnit());
         $this->assertNotNull($forecast->getCity());
         $currentDate = $currentDate->add($dateInterval);
     }
     $cityName = $this->getMock('\\Th3Mouk\\YahooWeatherBundle\\Entity\\City');
     $cityName->expects($this->any())->method('getName')->will($this->returnValue('Clermont-Ferrand'));
     $historyManager = new HistoryManager($this->api, $entityManager);
     $forecasts = $historyManager->getForecast($cityName);
     $currentDate = new \DateTime();
     $dateInterval = new \DateInterval('P1D');
     $this->assertSame(count($forecasts), 10);
     foreach ($forecasts as $forecast) {
         $this->assertSame($forecast->getDate()->format('Y-m-d'), $currentDate->format('Y-m-d'));
         $this->assertNotNull($forecast->getCode());
         $this->assertNotNull($forecast->getLow());
         $this->assertNotNull($forecast->getHigh());
         $this->assertNotNull($forecast->getText());
         $this->assertNotNull($forecast->getUnit());
         $this->assertNotNull($forecast->getCity());
         $currentDate = $currentDate->add($dateInterval);
     }
 }
 public function getForecast(City $city, $unit = 'c')
 {
     return $this->history_manager->getForecast($city, $unit);
 }