1<?php
2
3/**
4 * This file is part of the Phalcon Framework.
5 *
6 * (c) Phalcon Team <team@phalcon.io>
7 *
8 * For the full copyright and license information, please view the LICENSE.txt
9 * file that was distributed with this source code.
10 */
11
12declare(strict_types=1);
13
14namespace Phalcon\Test\Unit\Flash\Session;
15
16use Phalcon\Flash\Session;
17use Phalcon\Test\Fixtures\Traits\DiTrait;
18use UnitTester;
19
20class OutputCest
21{
22    use DiTrait;
23
24    /**
25     * @var array
26     */
27    protected $classes = [
28        'success' => 'successMessage',
29        'notice'  => 'noticeMessage',
30        'warning' => 'warningMessage',
31        'error'   => 'errorMessage',
32    ];
33
34    public function _before(UnitTester $I)
35    {
36        $this->newDi();
37        $this->setDiService('escaper');
38        $this->setDiService('sessionStream');
39    }
40
41    /**
42     * Tests Phalcon\Flash\Session :: output()
43     *
44     * @author Phalcon Team <team@phalcon.io>
45     * @since  2018-11-13
46     */
47    public function flashSessionOutput(UnitTester $I)
48    {
49        $I->wantToTest('Flash\Session - output()');
50        $I->skipTest('Need implementation');
51    }
52
53    /**
54     * Tests Phalcon\Flash\Session :: output() in case the session is empty
55     *
56     * @author Balázs Németh <https://github.com/zsilbi>
57     * @since  2019-04-29
58     */
59    public function emptyFlashSessionOutput(UnitTester $I)
60    {
61        $I->wantToTest('Flash\Session - output() when session is empty');
62
63        $flash = $this->getFlash();
64
65        $flash->clear();
66
67        ob_start();
68        $flash->output();
69        $result = ob_get_contents();
70        ob_end_clean();
71
72        $I->assertEmpty($result);
73    }
74
75    /**
76     * Return flash instance
77     */
78    protected function getFlash()
79    {
80        $container = $this->getDi();
81        $flash     = new Session();
82        $flash->setDI($container);
83        $flash->setCssClasses($this->classes);
84
85        return $flash;
86    }
87}
88