/** * @covers Imbo\Model\Groups::getCount */ public function testCanCountImages() { $this->assertSame(0, $this->model->getCount()); $this->assertSame($this->model, $this->model->setGroups(['group1' => [], 'group2' => []])); $this->assertSame(2, $this->model->getCount()); }
/** * {@inheritdoc} */ public function formatGroups(Model\Groups $model) { $data = $model->getGroups(); $entries = ''; foreach ($data as $group) { $resources = array_map(array($this, 'formatValue'), $group['resources']); $entries .= '<group>'; $entries .= ' <name>' . $this->formatValue($group['name']) . '</name>'; $entries .= ' <resources>'; $entries .= ' <resource>' . implode($resources, '</resource><resource>') . '</resource>'; $entries .= ' </resources>'; $entries .= '</group>'; } return <<<GROUPS <?xml version="1.0" encoding="UTF-8"?> <imbo> <search> <hits>{$model->getHits()}</hits> <page>{$model->getPage()}</page> <limit>{$model->getLimit()}</limit> <count>{$model->getCount()}</count> </search> <groups>{$entries}</groups> </imbo> GROUPS; }
/** * {@inheritdoc} */ public function formatGroups(Model\Groups $model) { return $this->encode(['search' => ['hits' => $model->getHits(), 'page' => $model->getPage(), 'limit' => $model->getLimit(), 'count' => $model->getCount()], 'groups' => $model->getGroups()]); }