Phalcon\Test\Unit\Flash\SessionTest::testMessageFormat PHP Method

testMessageFormat() public method

Test output formatted messages
Since: 2015-10-26
Author: Iván Guillén ([email protected])
public testMessageFormat ( )
    public function testMessageFormat()
    {
        $this->specify("The output() method outputs formatted messages incorrectly", function ($function) {
            $flash = $this->getFlash();
            $template = ' class="%s"';
            $class = sprintf($template, $this->classes[$function]);
            $template = '<div%s>%s</div>' . PHP_EOL;
            $message = 'sample message';
            $expected = sprintf($template, $class, $message);
            ob_start();
            $flash->{$function}($message);
            $flash->output();
            $actual = ob_get_contents();
            ob_end_clean();
            expect($actual)->equals($expected);
        }, ['examples' => ['error' => ['function' => 'error'], 'success' => ['function' => 'success'], 'notice' => ['function' => 'notice']]]);
    }