/** * @param string $url * @return array **/ public function parse($url) { $data = simplexml_load_file($url); if ($data === false) { throw new \Exception('データを読み込めません'); } $list = array(); foreach ($data->entry as $entry) { $news = new News(); $news->setTitle($entry->title); $news->setUrl($entry->url); $news->setTargetDate($entry->date); $list[] = $news; } return $list; }
/** * @test * @group builder-get-news-date * @group builder */ public function 日付の取得() { $date = date('Y-m-d H:i:s'); $this->news->setTargetDate($date); $this->assertEquals($date, $this->news->getTargetDate()); }