/** * @covers Imbo\Model\ListModel::setEntry * @covers Imbo\Model\ListModel::getEntry */ public function testCanSetAndGetAnEntryValue() { $this->assertNull($this->model->getEntry()); $entry = 'entry'; $this->assertSame($this->model, $this->model->setEntry($entry)); $this->assertSame($entry, $this->model->getEntry()); }
/** * @covers Imbo\Model\ListModel::getData */ public function testGetData() { $list = [1, 2, 3]; $container = 'container'; $entry = 'entry'; $this->model->setList($list)->setContainer($container)->setEntry($entry); $this->assertSame(['list' => $list, 'container' => $container, 'entry' => $entry], $this->model->getData()); }
public function get(EventInterface $event) { $model = new ListModel(); $model->setContainer('foo'); $model->setEntry('bar'); $model->setList([1, 2, 3]); $event->getResponse()->setModel($model); }
/** * {@inheritdoc} */ public function formatListModel(Model\ListModel $model) { $data = ''; $entries = ''; $container = $model->getContainer(); $entry = $model->getEntry(); $list = $model->getList(); foreach ($list as $element) { $entries .= '<' . $entry . '>' . $element . '</' . $entry . '>'; } $data = '<' . $container . '>' . $entries . '</' . $container . '>'; return <<<DATA <?xml version="1.0" encoding="UTF-8"?> <imbo>{$data}</imbo> DATA; }
/** * {@inheritdoc} */ public function formatListModel(Model\ListModel $model) { return $this->encode(array($model->getContainer() => $model->getList())); }