Skip to content

Commit 0a651b3

Browse files
committed
Updated to 1.1.5 version
1 parent 0943537 commit 0a651b3

File tree

5 files changed

+72
-9
lines changed

5 files changed

+72
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
* Implemented `PHP Coding Standards Fixer` to organize PHP code automatically according to PSR standards.
1010

11+
* Added `Josantonius\Cookie\Cookie::getCookiePrefix()` method.
12+
1113
## 1.1.4 - 2017-10-25
1214

1315
* Implemented `PSR-4 autoloader standard` from all library files.

README-ES.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ Cookie::destroy($key);
102102

103103
**# Return** (boolean)
104104

105+
### - Obtener prefijo de cookies:
106+
107+
```php
108+
Cookie::getCookiePrefix();
109+
```
110+
111+
**# Return** (string) → prefijo de cookies
112+
105113
## Cómo empezar
106114

107115
Para utilizar esta clase con `Composer`:
@@ -160,7 +168,13 @@ Cookie::destroy('cookie_name');
160168
Cookie::destroy();
161169
```
162170

163-
## Tests
171+
### - Obtener prefijo de cookies:
172+
173+
```php
174+
Cookie::getCookiePrefix();
175+
```
176+
177+
## Tests
164178

165179
Para ejecutar las [pruebas](tests) necesitarás [Composer](http://getcomposer.org/download/) y seguir los siguientes pasos:
166180

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ Cookie::destroy($key);
102102

103103
**# Return** (boolean)
104104

105+
### - Get cookie prefix:
106+
107+
```php
108+
Cookie::getCookiePrefix();
109+
```
110+
111+
**# Return** (string) → cookie prefix
112+
105113
## Quick Start
106114

107115
To use this class with **Composer**:
@@ -160,6 +168,12 @@ Cookie::destroy('cookie_name');
160168
Cookie::destroy();
161169
```
162170

171+
### - Get cookie prefix:
172+
173+
```php
174+
Cookie::getCookiePrefix();
175+
```
176+
163177
## Tests
164178

165179
To run [tests](tests) you just need [composer](http://getcomposer.org/download/) and to execute the following:

src/Cookie.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,16 @@ public static function destroy($key = '')
109109

110110
return false;
111111
}
112+
113+
/**
114+
* Get cookie prefix.
115+
*
116+
* @since 1.1.5
117+
*
118+
* @return string
119+
*/
120+
public static function getCookiePrefix()
121+
{
122+
return self::$prefix;
123+
}
112124
}

tests/CookieTest.php

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ final class CookieTest extends TestCase
2828
*/
2929
protected $Cookie;
3030

31+
/**
32+
* Cookie prefix.
33+
*
34+
* @since 1.1.5
35+
*
36+
* @var string
37+
*/
38+
protected $cookiePrefix;
39+
3140
/**
3241
* Set up.
3342
*
@@ -38,6 +47,18 @@ public function setUp()
3847
parent::setUp();
3948

4049
$this->Cookie = new Cookie;
50+
$this->cookiePrefix = $this->Cookie->getCookiePrefix();
51+
}
52+
53+
/**
54+
* Check if it is an instance of __Package__.
55+
*
56+
* @since 1.1.5
57+
*/
58+
public function testIsInstanceOfCookie()
59+
{
60+
$actual = $this->Cookie;
61+
$this->assertInstanceOf('\Josantonius\Cookie\Cookie', $actual);
4162
}
4263

4364
/**
@@ -61,7 +82,7 @@ public function testSetCookie()
6182
*/
6283
public function testGetCookie()
6384
{
64-
$_COOKIE[$this->Cookie::$prefix . 'cookie_name'] = 'value';
85+
$_COOKIE[$this->cookiePrefix . 'cookie_name'] = 'value';
6586

6687
$this->assertContains($this->Cookie->get('cookie_name'), 'value');
6788
}
@@ -75,11 +96,11 @@ public function testGetCookie()
7596
*/
7697
public function testGetAllCookies()
7798
{
78-
$_COOKIE[$this->Cookie::$prefix . 'cookie_name_one'] = 'value';
79-
$_COOKIE[$this->Cookie::$prefix . 'cookie_name_two'] = 'value';
99+
$_COOKIE[$this->cookiePrefix . 'cookie_name_one'] = 'value';
100+
$_COOKIE[$this->cookiePrefix . 'cookie_name_two'] = 'value';
80101

81102
$this->assertArrayHasKey(
82-
$this->Cookie::$prefix . 'cookie_name_two',
103+
$this->cookiePrefix . 'cookie_name_two',
83104
$this->Cookie->get()
84105
);
85106
}
@@ -105,7 +126,7 @@ public function testGetAllCookiesNonExistents()
105126
*/
106127
public function testPullCookie()
107128
{
108-
$_COOKIE[$this->Cookie::$prefix . 'cookie_name'] = 'value';
129+
$_COOKIE[$this->cookiePrefix . 'cookie_name'] = 'value';
109130

110131
$this->assertContains($this->Cookie->pull('cookie_name'), 'value');
111132
}
@@ -131,7 +152,7 @@ public function testPullCookieNonExistent()
131152
*/
132153
public function testDestroyOneCookie()
133154
{
134-
$_COOKIE[$this->Cookie::$prefix . 'cookie_name'] = 'value';
155+
$_COOKIE[$this->cookiePrefix . 'cookie_name'] = 'value';
135156

136157
$this->assertTrue($this->Cookie->destroy('cookie_name'));
137158
}
@@ -157,8 +178,8 @@ public function testDestroyOneCookieNonExistent()
157178
*/
158179
public function testDestroyAllCookies()
159180
{
160-
$_COOKIE[$this->Cookie::$prefix . 'cookie_name_one'] = 'value';
161-
$_COOKIE[$this->Cookie::$prefix . 'cookie_name_two'] = 'value';
181+
$_COOKIE[$this->cookiePrefix . 'cookie_name_one'] = 'value';
182+
$_COOKIE[$this->cookiePrefix . 'cookie_name_two'] = 'value';
162183

163184
$this->assertTrue($this->Cookie->destroy());
164185
}

0 commit comments

Comments
 (0)