Example #1
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);
    }