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\Http\Response\Cookies;
15
16use Phalcon\Http\Response\Cookies;
17use Phalcon\Test\Fixtures\Traits\CookieTrait;
18use Phalcon\Test\Unit\Http\Helper\HttpBase;
19use UnitTester;
20
21class UseEncryptionIsUsingEncryptionCest extends HttpBase
22{
23    use CookieTrait;
24
25    /**
26     * executed before each test
27     */
28    public function _before(UnitTester $I)
29    {
30        parent::_before($I);
31        $this->setDiService('sessionStream');
32    }
33
34    /**
35     * Tests Phalcon\Http\Response\Cookies :: useEncryption /
36     * isUsingEncryption()
37     *
38     * @author Jeremy PASTOURET <https://github.com/jenovateurs>
39     * @since  2020-01-06
40     */
41    public function httpResponseCookiesUseEncryptionIsUsingEncryption(UnitTester $I)
42    {
43        $I->wantToTest('Http\Response\Cookies - useEncryption / isUsingEncryption()');
44
45        $sName  = 'framework';
46        $sValue = 'phalcon';
47
48        $this->setDiService('crypt');
49        $container = $this->getDi();
50
51        $oCookie = new Cookies(false);
52        $oCookie->setDI($container);
53
54        $I->assertFalse($oCookie->isUsingEncryption());
55
56        $oCookie->useEncryption(true);
57
58        $I->assertTrue($oCookie->isUsingEncryption());
59    }
60}
61