Esempio n. 1
0
 function configureTableRendering()
 {
     $this->renderers->add(new ElementRenderer());
     $this->renderers->add(new PrimitiveRenderer());
     $data = [json_decode('{"one":"uno","two":"dos","three":"tres"}'), json_decode('{"one":"un","two":"deux","three":"trois"}')];
     $table = (new ObjectTable($data, $this->types))->selectProperties(['three', 'one'])->setHeader('one', '1')->setFilter('three', function ($s) {
         return strtoupper($s);
     });
     $this->assert->contains($this->tableRenderer->render($table), "<th>Three</th>\n<th>1</th>");
     $this->assert->contains($this->tableRenderer->render($table), "<td>TRES</td>\n<td>uno</td>");
     $this->assert->contains($this->tableRenderer->render($table), "<td>TROIS</td>\n<td>un</td>");
 }
Esempio n. 2
0
 function collectsHeadElementsOfItems()
 {
     $itemRenderer = Mockster::of(WebRenderer::class);
     $this->registry->add(Mockster::mock($itemRenderer));
     Mockster::stub($itemRenderer->handles(Argument::any()))->will()->return_(true);
     Mockster::stub($itemRenderer->headElements('foo'))->will()->return_([new Element('foo')]);
     Mockster::stub($itemRenderer->headElements(Argument::object(\DateTime::class)))->will()->return_([new Element('bar')]);
     $elements = $this->renderer->headElements(['foo', new \DateTime()]);
     $this->assert->size($elements, 2);
     $this->assert((string) $elements[0], '<foo></foo>');
     $this->assert((string) $elements[1], '<bar></bar>');
 }
Esempio n. 3
0
 private function registerRenderers()
 {
     $links = new LinkPrinter($this->links, $this->actions, $this->parser, $this->token);
     $this->renderers->add(new ElementRenderer());
     $this->renderers->add(new BooleanRenderer());
     $this->renderers->add(new ColorRenderer());
     $this->renderers->add(new PrimitiveRenderer());
     $this->renderers->add(new DateTimeRenderer());
     $this->renderers->add(new DateIntervalRenderer());
     $this->renderers->add(new TextRenderer());
     $this->renderers->add(new HtmlRenderer());
     $this->renderers->add(new IdentifierRenderer($links));
     $this->renderers->add(new FileRenderer());
     $this->renderers->add(new ImageRenderer());
     $this->renderers->add(new ScatterChartRenderer());
     $this->renderers->add(new ChartRenderer());
     $this->renderers->add(new DelayedOutputRenderer());
     $this->renderers->add(new DashboardItemRenderer($this->renderers));
     $this->renderers->add(new ActionListRenderer($this->parser));
     $this->renderers->add(new ActionPanelRenderer($this->renderers, $this->actions, $this->fields));
     $this->renderers->add(new DataTableRenderer($this->renderers));
     $this->renderers->add(new TableRenderer($this->renderers, $links));
     $this->renderers->add(new ListRenderer($this->renderers, $links));
     $this->renderers->add(new MapRenderer($this->renderers, $links));
     $this->renderers->add(new ObjectRenderer($this->renderers, $this->types, $links));
 }
Esempio n. 4
0
 function nestedTables()
 {
     $this->renderers->add(new PrimitiveRenderer());
     $this->renderers->add($this->tableRenderer);
     $tableInTable = new ArrayTable([['table' => new ArrayTable([['one' => 'uno', 'two' => 'dos']])]]);
     $this->tableRenderer->render($tableInTable);
     $this->tableRenderer->headElements($tableInTable);
     $this->assert->pass();
 }
Esempio n. 5
0
 function collectHeadElementsOfProperties()
 {
     $propertyRenderer = Mockster::of(WebRenderer::class);
     $this->renderers->add(Mockster::mock($propertyRenderer));
     Mockster::stub($propertyRenderer->handles(Argument::any()))->will()->return_(true);
     Mockster::stub($propertyRenderer->headElements('uno'))->will()->return_([new Element('one')]);
     Mockster::stub($propertyRenderer->headElements('bar'))->will()->return_([new Element('foo')]);
     $elements = $this->renderer->headElements(json_decode('{"one":"uno", "foo":"bar"}'));
     $this->assert->size($elements, 2);
     $this->assert((string) $elements[0], '<one></one>');
     $this->assert((string) $elements[1], '<foo></foo>');
 }
Esempio n. 6
0
 private function registerRenderers()
 {
     $this->renderers->add(new BooleanRenderer());
     $this->renderers->add(new PrimitiveRenderer());
     $this->renderers->add(new DateTimeRenderer());
     $this->renderers->add(new DateIntervalRenderer());
     $this->renderers->add(new HtmlRenderer());
     $this->renderers->add(new IdentifierRenderer());
     $this->renderers->add(new FileRenderer(''));
     $this->renderers->add(new DelayedOutputRenderer());
     $this->renderers->add(new ObjectTableRenderer($this->renderers));
     $this->renderers->add(new DataTableRenderer($this->renderers));
     $this->renderers->add(new TableRenderer($this->renderers));
     $this->renderers->add(new ChartRenderer($this->renderers));
     $this->renderers->add(new ArrayRenderer($this->renderers));
     $this->renderers->add(new ObjectRenderer($this->renderers, $this->types));
 }
Esempio n. 7
0
 private function givenARendererFor_RenderingWith($value, $callback)
 {
     $renderer = Mockster::of(Renderer::class);
     $this->renderers->add(Mockster::mock($renderer));
     Mockster::stub($renderer->handles($value))->will()->return_(true);
     Mockster::stub($renderer->render(Argument::any()))->will()->forwardTo($callback);
 }
Esempio n. 8
0
 private function givenAllValuesAreRenderedWith($callback)
 {
     $renderer = Mockster::of(Renderer::class);
     $this->renderers->add(Mockster::mock($renderer));
     Mockster::stub($renderer->handles(Arg::any()))->will()->return_(true);
     Mockster::stub($renderer->render(Arg::any()))->will()->forwardTo($callback);
 }
Esempio n. 9
0
 private function whenIExecute($id)
 {
     $fields = new FieldRegistry();
     foreach ($this->fields as $field) {
         $fields->add(Mockster::mock($field));
     }
     $renderers = new RendererRegistry();
     foreach ($this->renderers as $renderer) {
         $renderers->add(Mockster::mock($renderer));
     }
     $executor = new Executor($this->action->registry, $fields, $renderers, Mockster::mock($this->reader));
     $this->result = $executor->execute($id);
 }