/** * @param Widget $widget * * @return Widget */ public function saveWidget(Widget $widget) { $widget->filters = Input::get("filter", []); $widget->name = Input::get("name", ""); $widget->charttype = Input::get("charttype", ""); $widget->metric = Input::get("metric", ""); $widget->submetric = Input::get("submetric", ""); $widget->timegroup = Input::get("timegroup", ""); if (!$widget->exists) { $widget->col = 0; $widget->row = 0; $widget->size_x = Input::get("size_x", ""); $widget->size_y = Input::get("size_y", ""); } $widget->save(); return $widget; }
public function testCanShowWidgetWithTimeranges() { $widget = new Widget(); $widget->name = "New widget"; $widget->metric = "Users"; $widget->submetric = "per_time"; $widget->charttype = "LineChart"; $widget->filters = []; $widget->timegroup = "DAY"; $widget->col = 0; $widget->row = 0; $widget->size_x = 1; $widget->size_y = 2; $widget->save(); $timeranges = ["all", "today", "yesterday", "last_7", "this_week", "last_week", "this_month", "last_month", "this_year", "last_year"]; foreach ($timeranges as $timerange) { Session::set("cockpit.time_range", $timerange); $this->visit("/cockpit/api/" . $widget->getKey()); $this->seeStatusCode(200); $this->assertContains('<div id="chart_' . $widget->getKey() . '">', $this->response->getContent()); } }