public function testLoad() { $data = [10 => 'test']; $this->fetchStrategyMock->expects($this->once())->method('fetchAll')->with($this->selectMock, [])->will($this->returnValue([$data])); $objectMock = $this->getMock('Magento\\Framework\\Object', ['addData'], []); $objectMock->expects($this->once())->method('addData')->with($data); $this->entityFactoryMock->expects($this->once())->method('create')->with('Magento\\Review\\Model\\Review\\Summary')->will($this->returnValue($objectMock)); $this->collection->load(); }
/** * load rows into objects */ public function load($rows = null) { parent::load($rows); if ($this->default_answer) { return; } foreach ($this->children as $answer) { if ($answer->default_answer()) { $this->default_answer = $answer; break; } } //end foreach }
function search($page = 1, $searchQuery = null, $sort = "id") { $m = $this->model; $temp = new $m(); $searchQueryParsed = Options::parse($searchQuery); $where = array(); $queryData = new stdClass(); foreach ($searchQueryParsed as $key => $value) { if (APP_USE_LANGUAGE) { if ($value != "" && $value != null) { if (isset($m->{$key})) { $where[] = $temp->__table__ . ".{$key} LIKE \"%{$value}%\""; } else { $where[] = $temp->__table__ . ".{$key}_{$this->application->language} LIKE \"%{$value}%\""; } } } else { if ($value != "" && $value != null) { $where[] = $temp->__table__ . ".{$key} LIKE \"%{$value}%\""; } } $queryData->{$key} = $value; } $query = array(); //if($this->order!=null) $query["order"] = $this->order; if ($sort != null) { $query["order"] = "{$temp->__table__}.{$sort}"; } $query["group"] = $temp->__table__ . ".id"; $query["limit"] = ($page - 1) * $this->perPage . "," . $this->perPage; $query["founds"] = true; if (count($where) > 0) { $query["where"] = implode(" AND ", $where); } /* if($condition!=null){ $query["where"] = $condition; } */ $this->data["objects"] = Collection::load($this->model, $query, $total); $order = new stdClass(); foreach ($this->orderFields as $key) { $order->{$key} = $key; $sym = $key . "symbol"; $order->{$sym} = "[asc]"; if ($key == $sort) { $order->{$key} .= " desc"; $order->{$sym} = "[desc]"; } } $this->data["order"] = $order; import("data.Pager"); $page = max($page, 1); unset($this->data["objects"]["founds"]); $pager = new Pager($total, $this->perPage); $pager->to = "{$this->controller}/search/{page}/{$searchQuery}"; $this->data["pager"] = $pager->build($page); $this->data["querydata"] = $queryData; $this->data["uri"] = linkForm("/{$this->controller}/search/{$page}/{$searchQuery}"); $this->setView("{$this->folder}/{$this->subView}", $this->data); }