/** * @covers Component\Remote\BurzeDzisNet\WeatherAlert::toArray */ public function testToArray() { $alert = (new WeatherAlert())->withAlert('storm', new Alert(1, '2015-02-12', '2015-02-13'))->withAlert('wind', new Alert(2, '2015-02-12', '2015-02-13')); $this->assertEquals(['storm' => new Alert(1, '2015-02-12', '2015-02-13'), 'wind' => new Alert(2, '2015-02-12', '2015-02-13')], $alert->toArray()); $alert2 = new WeatherAlert(); $this->assertEquals([], $alert2->toArray()); }
/** * WeatherAlert * * @param WeatherAlert|null $alert set of alerts */ public function __construct(WeatherAlert $alert = null) { $this->alerts = $alert != null ? $alert->toArray() : []; }