|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Phalcon\Test\Unit\Http; |
| 4 | + |
| 5 | +use Phalcon\Crypt; |
| 6 | +use Phalcon\Http\Cookie; |
| 7 | +use Phalcon\DI\FactoryDefault; |
| 8 | +use Phalcon\Test\Unit\Http\Helper\HttpBase; |
| 9 | + |
| 10 | +/** |
| 11 | + * Phalcon\Test\Unit\Http\CookieTest |
| 12 | + * Tests the Phalcon\Http\Cookie component |
| 13 | + * |
| 14 | + * @copyright (c) 2011-2017 Phalcon Team |
| 15 | + * @link https://phalconphp.com |
| 16 | + * @author Andres Gutierrez <andres@phalconphp.com> |
| 17 | + * @author Nikolaos Dimopoulos <nikos@phalconphp.com> |
| 18 | + * @package Phalcon\Test\Unit\Http |
| 19 | + * |
| 20 | + * The contents of this file are subject to the New BSD License that is |
| 21 | + * bundled with this package in the file LICENSE.txt |
| 22 | + * |
| 23 | + * If you did not receive a copy of the license and are unable to obtain it |
| 24 | + * through the world-wide-web, please send an email to license@phalconphp.com |
| 25 | + * so that we can send you a copy immediately. |
| 26 | + */ |
| 27 | +class CookieTest extends HttpBase |
| 28 | +{ |
| 29 | + /** |
| 30 | + * Tests Cookie::getValue with using encryption and default crypt algo. |
| 31 | + * |
| 32 | + * @test |
| 33 | + * @issue 11259 |
| 34 | + * @author Serghei Iakovlev <serghei@phalconphp.com> |
| 35 | + * @since 2017-10-04 |
| 36 | + */ |
| 37 | + public function shouldDecryptValueByUsingDefaultEncryptionAlgo() |
| 38 | + { |
| 39 | + $this->specify( |
| 40 | + "The cookie value decrypted incorrectly.", |
| 41 | + function () { |
| 42 | + $di = new FactoryDefault(); |
| 43 | + |
| 44 | + $di->set('crypt', function () { |
| 45 | + $crypt = new Crypt(); |
| 46 | + $crypt->setKey('cryptkeycryptkey'); |
| 47 | + |
| 48 | + return $crypt; |
| 49 | + }); |
| 50 | + |
| 51 | + $cookie = new Cookie('test-cookie', 'test', time() + 3600); |
| 52 | + $cookie->setDI($di); |
| 53 | + $cookie->useEncryption(true); |
| 54 | + |
| 55 | + expect($cookie->getValue())->equals('test'); |
| 56 | + } |
| 57 | + ); |
| 58 | + } |
| 59 | +} |
0 commit comments