Skip to content

Commit 1db0e40

Browse files
sergeyklaychilimatic
authored andcommitted
Added Cookie::getValue test
1 parent de0aae8 commit 1db0e40

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

tests/unit/Http/CookieTest.php

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
}

tests/unit/Http/Response/CookiesTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ class CookiesTest extends HttpBase
2727
/**
2828
* Tests the internal cookies property.
2929
*
30+
* @test
3031
* @issue 12978
3132
* @author Serghei Iakovlev <serghei@phalconphp.com>
3233
* @since 2017-09-02
3334
*/
34-
public function testInternalCookiesProperty()
35+
public function shouldWorkWithoutInitializeInternalCookiesProperty()
3536
{
3637
$this->specify(
3738
"The internal cookies property is not initialized or iterable",

0 commit comments

Comments
 (0)