Example #1
0
 public function testPlacementPrepend()
 {
     $context = new Context();
     $context->add('content', array('name' => 'one', 'placement' => 'prepend'));
     $context->add('content', array('name' => 'two'));
     $context->setContent('one', 'outer');
     $context->setContent('two', 'inner');
     $expected = 'outerinner';
     $actual = $context->render();
     $this->assertEquals($expected, $actual);
 }
 public function testTableWithIds()
 {
     $context = new Context('table');
     $context->add('table');
     $context->add('contexts', 'row');
     $context->select('row')->add('tr')->add('contexts', 'column');
     $context->select('column')->add('td')->add('content');
     $context->ids('column', 'name,email');
     $data = array(array('id' => 23, 'name' => 'Peter', 'email' => '*****@*****.**'), array('id' => 17, 'name' => 'Heidi', 'email' => '*****@*****.**'));
     $context->setContent($data);
     $expected = '<table><tr><td>Peter</td><td>peter@alps.ch</td></tr><tr><td>Heidi</td><td>heidi@alps.ch</td></tr></table>';
     $actual = $context->render();
     $this->assertEquals($expected, $actual);
 }
Example #3
0
    public function testLog()
    {
        $context = new Context('dialog');
        $context->add('div', array('class' => 'dialog'));
        $context->add('context', 'title');
        $context->add('context', 'body');
        $context->select('title')->add('div', array('class' => 'title'));
        $context->select('title')->add('content');
        $body = $context->select('body');
        $body->add('div', array('class' => 'body'));
        $body->add('content');
        $content = array('title' => 'My title', 'body' => 'My first contextual view');
        Context::clearLog();
        $context->render($content);
        $actual = implode("\n", Context::getLog());
        $expected = <<<END
[Render] Rendering dialog#dialog
[Selector] Selector dialog applies
[Decorator] Rendering decorator Context with name body
[Context] Creating context body with id body
[Render] Rendering body#body
[Selector] Selector body applies
[Decorator] Rendering decorator Content with name content
[Decorator] Rendering decorator HtmlTag with name div
[Decorator] Rendering decorator Context with name title
[Context] Creating context title with id title
[Render] Rendering title#title
[Selector] Selector title applies
[Decorator] Rendering decorator Content with name content
[Decorator] Rendering decorator HtmlTag with name div
[Decorator] Rendering decorator HtmlTag with name div
END;
        // Normalize line endings
        $expected = str_replace("\r\n", "\n", $expected);
        $actual = str_replace("\r\n", "\n", $actual);
        $this->assertEquals($expected, $actual);
    }
Example #4
0
 /**
  * @used-by log()
  * @used-by mail()
  * @return string
  */
 private function report()
 {
     if (!isset($this->{__METHOD__})) {
         $this->{__METHOD__} = $this->sections(Context::render(), $this->preface(), $this->main(), $this->postface());
     }
     return $this->{__METHOD__};
 }