diff --git a/.github/lang/es-ES/README.md b/.github/lang/es-ES/README.md index 1a8073f..89d227b 100644 --- a/.github/lang/es-ES/README.md +++ b/.github/lang/es-ES/README.md @@ -34,7 +34,9 @@ Biblioteca PHP para el manejo de cookies. ## Requisitos -Esta biblioteca es compatible con las versiones de PHP: 8.1. +- Sistema operativo: Linux. + +- Versiones de PHP: 8.1 | 8.2. ## Instalación @@ -63,9 +65,7 @@ git clone https://github.com/josantonius/php-cookie.git ### Clase Cookie -```php -use Josantonius\Cookie\Cookie; -``` +`Josantonius\Cookie\Cookie` Establece las opciones de las cookies: @@ -88,15 +88,14 @@ Establece las opciones de las cookies: * @see https://www.php.net/manual/en/datetime.formats.php for date formats. * @see https://www.php.net/manual/en/function.setcookie.php for more information. */ - -$cookie = new Cookie( - string $domain = '', - int|string|DateTime $expires = 0, - bool $httpOnly = false, - string $path = '/', - bool $raw = false, - null|string $sameSite = null, - bool $secure = false +public function __construct( + private string $domain = '', + private int|string|DateTime $expires = 0, + private bool $httpOnly = false, + private string $path = '/', + private bool $raw = false, + private null|string $sameSite = null, + private bool $secure = false ); ``` @@ -107,11 +106,11 @@ Establece una cookie por nombre: * @throws CookieException si las cabeceras ya han sido enviadas. * @throws CookieException si falla el análisis de la cadena de fecha/hora. */ -$cookie->set( +public function set( string $name, mixed $value, null|int|string|DateTime $expires = null -): void +): void; ``` Establece varias cookies a la vez: @@ -122,10 +121,10 @@ Establece varias cookies a la vez: * * @throws CookieException si las cabeceras ya han sido enviadas. */ -$cookie->replace( +public function replace( array $data, null|int|string|DateTime $expires = null -): void +): void; ``` Obtiene una cookie por su nombre: @@ -134,19 +133,19 @@ Obtiene una cookie por su nombre: /** * Opcionalmente define un valor por defecto cuando la cookie no existe. */ -$cookie->get(string $name, mixed $default = null): mixed +public function get(string $name, mixed $default = null): mixed; ``` Obtiene todas las cookies: ```php -$cookie->all(): array +public function all(): array; ``` Comprueba si existe una cookie: ```php -$cookie->has(string $name): bool +public function has(string $name): bool; ``` Elimina una cookie por su nombre y devuelve su valor: @@ -157,7 +156,7 @@ Elimina una cookie por su nombre y devuelve su valor: * * @throws CookieException si las cabeceras ya han sido enviadas. */ -$cookie->pull(string $name, mixed $default = null): mixed +public function pull(string $name, mixed $default = null): mixed; ``` Borra una cookie por su nombre: @@ -167,14 +166,12 @@ Borra una cookie por su nombre: * @throws CookieException si las cabeceras ya han sido enviadas. * @throws CookieException si falla el análisis de la cadena de fecha/hora. */ -$cookie->remove(string $name): void +public function remove(string $name): void; ``` ### Fachada Cookie -```php -use Josantonius\Cookie\Facades\Cookie; -``` +`Josantonius\Cookie\Facades\Cookie` Establece las opciones de las cookies: @@ -197,8 +194,7 @@ Establece las opciones de las cookies: * @see https://www.php.net/manual/en/datetime.formats.php for date formats. * @see https://www.php.net/manual/en/function.setcookie.php for more information. */ - -Cookie::options( +public static function options( string $domain = '', int|string|DateTime $expires = 0, bool $httpOnly = false, @@ -206,7 +202,7 @@ Cookie::options( bool $raw = false, null|string $sameSite = null, bool $secure = false -); +): void; ``` Establece una cookie por nombre: @@ -216,11 +212,11 @@ Establece una cookie por nombre: * @throws CookieException si las cabeceras ya han sido enviadas. * @throws CookieException si falla el análisis de la cadena de fecha/hora. */ -Cookie::set( +public static function set( string $name, mixed $value, null|int|string|DateTime $expires = null -): void +): void; ``` Establece varias cookies a la vez: @@ -231,10 +227,10 @@ Establece varias cookies a la vez: * * @throws CookieException si las cabeceras ya han sido enviadas. */ -Cookie::replace( +public static function replace( array $data, null|int|string|DateTime $expires = null -): void +): void; ``` Obtiene una cookie por su nombre: @@ -243,19 +239,19 @@ Obtiene una cookie por su nombre: /** * Opcionalmente define un valor por defecto cuando la cookie no existe. */ -Cookie::get(string $name, mixed $default = null): mixed +public static function get(string $name, mixed $default = null): mixed; ``` Obtiene todas las cookies: ```php -Cookie::all(): array +public static function all(): array; ``` Comprueba si existe una cookie: ```php -Cookie::has(string $name): bool +public static function has(string $name): bool; ``` Elimina una cookie por su nombre y devuelve su valor: @@ -266,7 +262,7 @@ Elimina una cookie por su nombre y devuelve su valor: * * @throws CookieException si las cabeceras ya han sido enviadas. */ -Cookie::pull(string $name, mixed $default = null): mixed +public static function pull(string $name, mixed $default = null): mixed; ``` Borra una cookie por su nombre: @@ -276,7 +272,7 @@ Borra una cookie por su nombre: * @throws CookieException si las cabeceras ya han sido enviadas. * @throws CookieException si falla el análisis de la cadena de fecha/hora. */ -Cookie::remove(string $name): void +public static function remove(string $name): void; ``` ## Excepciones utilizadas @@ -285,7 +281,7 @@ Cookie::remove(string $name): void use Josantonius\Cookie\Exceptions\CookieException; ``` -## Usage +## Uso Ejemplos de uso de esta biblioteca: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 28bbe13..fcdd55d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,6 +46,7 @@ jobs: system: ['ubuntu-latest'] php: - '8.1' + - '8.2' steps: - name: Checkout Code uses: actions/checkout@v3 diff --git a/CHANGELOG.md b/CHANGELOG.md index 744e7dc..c8a79b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # CHANGELOG +## [v2.0.6](https://github.com/josantonius/php-cookie/releases/tag/v2.0.6) (2022-09-29) + +* The notation type in the test function names has been changed from camel to snake case for readability. + +* Functions were added to document the methods and avoid confusion. + +* Disabled the ´CamelCaseMethodName´ rule in ´phpmd.xml´ to avoid warnings about function names in tests. + +* The alignment of the asterisks in the comments has been fixed. + +* Tests for Windows have been added. + +* Tests for PHP 8.2 have been added. + ## [2.0.5](https://github.com/josantonius/php-cookie/releases/tag/2.0.5) (2022-08-11) * Improved documentation. diff --git a/README.md b/README.md index 2ede9ae..75e2943 100644 --- a/README.md +++ b/README.md @@ -27,14 +27,16 @@ PHP library for handling cookies. - [TODO](#todo) - [Changelog](#changelog) - [Contribution](#contribution) -- [Sponsor](#Sponsor) +- [Sponsor](#sponsor) - [License](#license) --- ## Requirements -This library is compatible with the PHP versions: 8.1. +- Operating System: Linux. + +- PHP versions: 8.1 | 8.2. ## Installation @@ -63,9 +65,7 @@ git clone https://github.com/josantonius/php-cookie.git ### Cookie Class -```php -use Josantonius\Cookie\Cookie; -``` +`Josantonius\Cookie\Cookie` Sets cookie options: @@ -88,15 +88,14 @@ Sets cookie options: * @see https://www.php.net/manual/en/datetime.formats.php for date formats. * @see https://www.php.net/manual/en/function.setcookie.php for more information. */ - -$cookie = new Cookie( - string $domain = '', - int|string|DateTime $expires = 0, - bool $httpOnly = false, - string $path = '/', - bool $raw = false, - null|string $sameSite = null, - bool $secure = false +public function __construct( + private string $domain = '', + private int|string|DateTime $expires = 0, + private bool $httpOnly = false, + private string $path = '/', + private bool $raw = false, + private null|string $sameSite = null, + private bool $secure = false ); ``` @@ -107,11 +106,11 @@ Sets a cookie by name: * @throws CookieException if headers already sent. * @throws CookieException if failure in date/time string analysis. */ -$cookie->set( +public function set( string $name, mixed $value, null|int|string|DateTime $expires = null -): void +): void; ``` Sets several cookies at once: @@ -122,10 +121,10 @@ Sets several cookies at once: * * @throws CookieException if headers already sent. */ -$cookie->replace( +public function replace( array $data, null|int|string|DateTime $expires = null -): void +): void; ``` Gets a cookie by name: @@ -134,19 +133,19 @@ Gets a cookie by name: /** * Optionally defines a default value when the cookie does not exist. */ -$cookie->get(string $name, mixed $default = null): mixed +public function get(string $name, mixed $default = null): mixed; ``` Gets all cookies: ```php -$cookie->all(): array +public function all(): array; ``` Check if a cookie exists: ```php -$cookie->has(string $name): bool +public function has(string $name): bool; ``` Deletes a cookie by name and returns its value: @@ -157,7 +156,7 @@ Deletes a cookie by name and returns its value: * * @throws CookieException if headers already sent. */ -$cookie->pull(string $name, mixed $default = null): mixed +public function pull(string $name, mixed $default = null): mixed; ``` Deletes an cookie by name: @@ -167,14 +166,12 @@ Deletes an cookie by name: * @throws CookieException if headers already sent. * @throws CookieException if failure in date/time string analysis. */ -$cookie->remove(string $name): void +public function remove(string $name): void; ``` ### Cookie Facade -```php -use Josantonius\Cookie\Facades\Cookie; -``` +`Josantonius\Cookie\Facades\Cookie` Sets cookie options: @@ -197,8 +194,7 @@ Sets cookie options: * @see https://www.php.net/manual/en/datetime.formats.php for date formats. * @see https://www.php.net/manual/en/function.setcookie.php for more information. */ - -Cookie::options( +public static function options( string $domain = '', int|string|DateTime $expires = 0, bool $httpOnly = false, @@ -206,7 +202,7 @@ Cookie::options( bool $raw = false, null|string $sameSite = null, bool $secure = false -); +): void; ``` Sets a cookie by name: @@ -216,11 +212,11 @@ Sets a cookie by name: * @throws CookieException if headers already sent. * @throws CookieException if failure in date/time string analysis. */ -Cookie::set( +public static function set( string $name, mixed $value, null|int|string|DateTime $expires = null -): void +): void; ``` Sets several cookies at once: @@ -231,10 +227,10 @@ Sets several cookies at once: * * @throws CookieException if headers already sent. */ -Cookie::replace( +public static function replace( array $data, null|int|string|DateTime $expires = null -): void +): void; ``` Gets a cookie by name: @@ -243,19 +239,19 @@ Gets a cookie by name: /** * Optionally defines a default value when the cookie does not exist. */ -Cookie::get(string $name, mixed $default = null): mixed +public static function get(string $name, mixed $default = null): mixed; ``` Gets all cookies: ```php -Cookie::all(): array +public static function all(): array; ``` Check if a cookie exists: ```php -Cookie::has(string $name): bool +public static function has(string $name): bool; ``` Deletes a cookie by name and returns its value: @@ -266,7 +262,7 @@ Deletes a cookie by name and returns its value: * * @throws CookieException if headers already sent. */ -Cookie::pull(string $name, mixed $default = null): mixed +public static function pull(string $name, mixed $default = null): mixed; ``` Deletes an cookie by name: @@ -276,7 +272,7 @@ Deletes an cookie by name: * @throws CookieException if headers already sent. * @throws CookieException if failure in date/time string analysis. */ -Cookie::remove(string $name): void +public static function remove(string $name): void; ``` ## Exceptions Used diff --git a/phpmd.xml b/phpmd.xml index e2f0690..167a9d9 100644 --- a/phpmd.xml +++ b/phpmd.xml @@ -1,5 +1,7 @@ - Coding standard. @@ -33,7 +35,7 @@ - + diff --git a/tests/AllMethodTest.php b/tests/AllMethodTest.php index 448cc60..98cb857 100644 --- a/tests/AllMethodTest.php +++ b/tests/AllMethodTest.php @@ -7,6 +7,8 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. + * + * @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps */ namespace Josantonius\Cookie\Tests; @@ -29,7 +31,7 @@ public function setUp(): void /** * @runInSeparateProcess */ - public function testShouldReturnEmptyArrayWhenThereAreNoCookies(): void + public function test_should_return_empty_array_when_there_are_no_cookies(): void { $this->assertEmpty($this->cookie->all()); } @@ -37,7 +39,7 @@ public function testShouldReturnEmptyArrayWhenThereAreNoCookies(): void /** * @runInSeparateProcess */ - public function testShouldGetAllCookies(): void + public function test_should_get_all_cookies(): void { $this->cookie->set('foo', 'bar'); $this->cookie->set('bar', 'foo'); @@ -51,7 +53,7 @@ public function testShouldGetAllCookies(): void /** * @runInSeparateProcess */ - public function testShouldBeAvailableFromTheFacade(): void + public function test_should_be_available_from_the_facade(): void { $facade = new CookieFacade(); diff --git a/tests/ClearMethodTest.php b/tests/ClearMethodTest.php index 7263f93..8d6c398 100644 --- a/tests/ClearMethodTest.php +++ b/tests/ClearMethodTest.php @@ -7,6 +7,8 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. + * + * @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps */ namespace Josantonius\Cookie\Tests; @@ -29,7 +31,7 @@ public function setUp(): void /** * @runInSeparateProcess */ - public function testShouldClearAllCookies(): void + public function test_should_clear_all_cookies(): void { $this->cookie->set('foo', 'bar'); $this->cookie->set('bar', 'foo'); @@ -42,7 +44,7 @@ public function testShouldClearAllCookies(): void /** * @runInSeparateProcess */ - public function testShouldBeAvailableFromTheFacade(): void + public function test_should_be_available_from_the_facade(): void { $facade = new CookieFacade(); diff --git a/tests/ConstructorTest.php b/tests/ConstructorTest.php index 839afff..3478874 100644 --- a/tests/ConstructorTest.php +++ b/tests/ConstructorTest.php @@ -7,6 +7,8 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. + * + * @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps */ namespace Josantonius\Cookie\Tests; @@ -28,7 +30,7 @@ public function setUp(): void $this->cookie = new Cookie(); } - public function testShouldCreateInstanceWithDefaultValues(): void + public function test_should_create_instance_with_default_values(): void { $cookie = new Cookie(); @@ -43,7 +45,7 @@ public function testShouldCreateInstanceWithDefaultValues(): void $this->assertEquals($this->getPrivateProperty($cookie, 'secure'), false); } - public function testShouldCreateInstanceWithCustomValues(): void + public function test_should_create_instance_with_custom_values(): void { $cookie = new Cookie( domain: 'example.com', @@ -66,7 +68,7 @@ public function testShouldCreateInstanceWithCustomValues(): void $this->assertEquals($this->getPrivateProperty($cookie, 'secure'), true); } - public function testShouldFailIfSameSiteValueIsWrong(): void + public function test_should_fail_if_same_site_value_is_wrong(): void { $this->expectException(CookieException::class); diff --git a/tests/GetMethodTest.php b/tests/GetMethodTest.php index 0e64adf..bdd618b 100644 --- a/tests/GetMethodTest.php +++ b/tests/GetMethodTest.php @@ -7,6 +7,8 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. + * + * @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps */ namespace Josantonius\Cookie\Tests; @@ -29,7 +31,7 @@ public function setUp(): void /** * @runInSeparateProcess */ - public function testShouldReturnValueWhenCookieExists(): void + public function test_should_return_value_when_cookie_exists(): void { $this->cookie->set('foo', 'bar'); @@ -39,7 +41,7 @@ public function testShouldReturnValueWhenCookieExists(): void /** * @runInSeparateProcess */ - public function testShouldReturnDefaultValueWhenCookieNotExists(): void + public function test_should_return_default_value_when_cookie_not_exists(): void { $this->assertNull($this->cookie->get('foo')); } @@ -47,7 +49,7 @@ public function testShouldReturnDefaultValueWhenCookieNotExists(): void /** * @runInSeparateProcess */ - public function testShouldReturnCustomDefaultValueWhenCookieNotExists(): void + public function test_should_return_custom_default_value_when_cookie_not_exists(): void { $this->assertEquals('bar', $this->cookie->get('foo', 'bar')); } @@ -55,7 +57,7 @@ public function testShouldReturnCustomDefaultValueWhenCookieNotExists(): void /** * @runInSeparateProcess */ - public function testShouldBeAvailableFromTheFacade(): void + public function test_should_be_available_from_the_facade(): void { $facade = new CookieFacade(); diff --git a/tests/HasMethodTest.php b/tests/HasMethodTest.php index f528c17..c3f9bea 100644 --- a/tests/HasMethodTest.php +++ b/tests/HasMethodTest.php @@ -7,6 +7,8 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. + * + * @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps */ namespace Josantonius\Cookie\Tests; @@ -29,7 +31,7 @@ public function setUp(): void /** * @runInSeparateProcess */ - public function testShouldCheckIfCookieExists(): void + public function test_should_check_if_cookie_exists(): void { $this->cookie->set('foo', 'bar'); @@ -41,7 +43,7 @@ public function testShouldCheckIfCookieExists(): void /** * @runInSeparateProcess */ - public function testShouldBeAvailableFromTheFacade(): void + public function test_should_be_available_from_the_facade(): void { $facade = new CookieFacade(); diff --git a/tests/OptionsMethodTest.php b/tests/OptionsMethodTest.php index 93c8f5c..b657912 100644 --- a/tests/OptionsMethodTest.php +++ b/tests/OptionsMethodTest.php @@ -7,6 +7,8 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. + * + * @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps */ namespace Josantonius\Cookie\Tests; @@ -19,7 +21,7 @@ class OptionsMethodTest extends TestCase /** * @runInSeparateProcess */ - public function testShouldBehaveSameAsConstructorWithDefaultValues(): void + public function test_should_behave_same_as_constructor_with_default_values(): void { $facade = new CookieFacade(); @@ -31,7 +33,7 @@ public function testShouldBehaveSameAsConstructorWithDefaultValues(): void /** * @runInSeparateProcess */ - public function testShouldBehaveSameAsConstructorWithCustomValues(): void + public function test_should_behave_same_as_constructor_with_custom_values(): void { $facade = new CookieFacade(); diff --git a/tests/PullMethodTest.php b/tests/PullMethodTest.php index c016a40..2c1e8ab 100644 --- a/tests/PullMethodTest.php +++ b/tests/PullMethodTest.php @@ -7,6 +7,8 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. + * + * @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps */ namespace Josantonius\Cookie\Tests; @@ -30,7 +32,7 @@ public function setUp(): void /** * @runInSeparateProcess */ - public function testShouldPullCookieAndReturnTheValueIfExists(): void + public function test_should_pull_cookie_and_return_the_value_if_exists(): void { $this->cookie->set('foo', 'bar'); $this->cookie->set('bar', 'foo'); @@ -46,7 +48,7 @@ public function testShouldPullCookieAndReturnTheValueIfExists(): void /** * @runInSeparateProcess */ - public function testShouldReturnDefaultValueIfCookieNotExists(): void + public function test_should_return_default_value_if_cookie_not_exists(): void { $this->assertNull($this->cookie->pull('foo')); } @@ -54,7 +56,7 @@ public function testShouldReturnDefaultValueIfCookieNotExists(): void /** * @runInSeparateProcess */ - public function testShouldReturnCustomDefaultValueIfCookieNotExists(): void + public function test_should_return_custom_default_value_if_cookie_not_exists(): void { $this->assertEquals('bar', $this->cookie->pull('foo', 'bar')); } @@ -62,7 +64,7 @@ public function testShouldReturnCustomDefaultValueIfCookieNotExists(): void /** * @runInSeparateProcess */ - public function testShouldSetAnExpirationTimeInPast(): void + public function test_should_set_an_expiration_time_in_past(): void { $this->cookie->pull('foo', 'bar'); @@ -71,7 +73,7 @@ public function testShouldSetAnExpirationTimeInPast(): void $this->assertEquals(1, $expires); } - public function testShouldFailWhenHeadersSent(): void + public function test_should_fail_when_headers_sent(): void { $this->expectException(CookieException::class); @@ -81,7 +83,7 @@ public function testShouldFailWhenHeadersSent(): void /** * @runInSeparateProcess */ - public function testShouldBeAvailableFromTheFacade(): void + public function test_should_be_available_from_the_facade(): void { $facade = new CookieFacade(); diff --git a/tests/RemoveMethodTest.php b/tests/RemoveMethodTest.php index f7fae22..0da76d0 100644 --- a/tests/RemoveMethodTest.php +++ b/tests/RemoveMethodTest.php @@ -7,6 +7,8 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. + * + * @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps */ namespace Josantonius\Cookie\Tests; @@ -30,7 +32,7 @@ public function setUp(): void /** * @runInSeparateProcess */ - public function testShouldRemoveCookieIfExist(): void + public function test_should_remove_cookie_if_exist(): void { $this->cookie->set('foo', 'bar'); @@ -42,14 +44,14 @@ public function testShouldRemoveCookieIfExist(): void /** * @runInSeparateProcess */ - public function testShouldRemoveCookieEvenIfNotExist(): void + public function test_should_remove_cookie_even_if_not_exist(): void { $this->cookie->remove('foo'); $this->assertEquals([], $this->cookie->all()); } - public function testShouldFailWhenHeadersSent(): void + public function test_should_fail_when_headers_sent(): void { $this->expectException(CookieException::class); @@ -59,7 +61,7 @@ public function testShouldFailWhenHeadersSent(): void /** * @runInSeparateProcess */ - public function testShouldBeAvailableFromTheFacade(): void + public function test_should_be_available_from_the_facade(): void { $facade = new CookieFacade(); diff --git a/tests/ReplaceMethodTest.php b/tests/ReplaceMethodTest.php index 78a890a..cfb8c96 100644 --- a/tests/ReplaceMethodTest.php +++ b/tests/ReplaceMethodTest.php @@ -7,6 +7,8 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. + * + * @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps */ namespace Josantonius\Cookie\Tests; @@ -31,7 +33,7 @@ public function setUp(): void /** * @runInSeparateProcess */ - public function testShouldAddCookiesIfNotExist(): void + public function test_should_add_cookies_if_not_exist(): void { $this->cookie->replace(['foo' => 'bar']); @@ -43,7 +45,7 @@ public function testShouldAddCookiesIfNotExist(): void /** * @runInSeparateProcess */ - public function testShouldReplaceCookiesIfExist(): void + public function test_should_replace_cookies_if_exist(): void { $this->cookie->set('foo', 'bar'); $this->cookie->set('bar', 'foo'); @@ -59,7 +61,7 @@ public function testShouldReplaceCookiesIfExist(): void /** * @runInSeparateProcess */ - public function testShouldReplaceCookiesWithExpirationTime(): void + public function test_should_replace_cookies_with_expiration_time(): void { $this->cookie->replace(['foo' => 'bar'], time() + 8); $this->cookie->replace(['bar' => 'foo'], 'now +8 seconds'); @@ -72,7 +74,7 @@ public function testShouldReplaceCookiesWithExpirationTime(): void ], $this->cookie->all()); } - public function testShouldFailWhenHeadersSent(): void + public function test_should_fail_when_headers_sent(): void { $this->expectException(CookieException::class); @@ -82,7 +84,7 @@ public function testShouldFailWhenHeadersSent(): void /** * @runInSeparateProcess */ - public function testShouldBeAvailableFromTheFacade(): void + public function test_should_be_available_from_the_facade(): void { $facade = new CookieFacade(); diff --git a/tests/SetMethodTest.php b/tests/SetMethodTest.php index 550a42a..e553b3b 100644 --- a/tests/SetMethodTest.php +++ b/tests/SetMethodTest.php @@ -7,6 +7,8 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. + * + * @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps */ namespace Josantonius\Cookie\Tests; @@ -32,7 +34,7 @@ public function setUp(): void /** * @runInSeparateProcess */ - public function testShouldSetCookieWithDefaultOptions(): void + public function test_should_set_with_default_options(): void { $this->cookie->set('foo', 'bar'); @@ -53,7 +55,7 @@ public function testShouldSetCookieWithDefaultOptions(): void /** * @runInSeparateProcess */ - public function testShouldSetCookieWithCustomOptions(): void + public function test_should_set_with_custom_options(): void { $this->cookie = new CookieProxy( domain: 'localhost', @@ -82,7 +84,7 @@ public function testShouldSetCookieWithCustomOptions(): void /** * @runInSeparateProcess */ - public function testShouldSetCookieWithCustomOptionsFormattingExpiresFromInteger(): void + public function test_should_set_with_custom_options_formatting_expires_from_integer(): void { $this->cookie = new CookieProxy(expires: time() + 8); @@ -96,7 +98,7 @@ public function testShouldSetCookieWithCustomOptionsFormattingExpiresFromInteger /** * @runInSeparateProcess */ - public function testShouldSetCookieWithCustomOptionsFormattingExpiresFromString(): void + public function test_should_set_with_custom_options_formatting_expires_from_string(): void { $this->cookie = new CookieProxy(expires: 'now +8 seconds'); @@ -110,7 +112,7 @@ public function testShouldSetCookieWithCustomOptionsFormattingExpiresFromString( /** * @runInSeparateProcess */ - public function testShouldSetCookieWithCustomOptionsFormattingExpiresFromDateTime(): void + public function test_should_set_with_custom_options_formatting_expires_from_date_time(): void { $this->cookie = new CookieProxy(expires: new DateTime('now +8 seconds')); @@ -124,7 +126,7 @@ public function testShouldSetCookieWithCustomOptionsFormattingExpiresFromDateTim /** * @runInSeparateProcess */ - public function testShouldSetCookieWithExpirationTime(): void + public function test_should_set_with_expiration_time(): void { $this->cookie->set('foo', 'bar', time() + 8); @@ -138,7 +140,7 @@ public function testShouldSetCookieWithExpirationTime(): void /** * @runInSeparateProcess */ - public function testShouldSetCookieReplacingGlobalExpirationValueWhenNewOneIsPassed(): void + public function test_should_set_replacing_global_expiration_value(): void { $this->cookie = new CookieProxy(expires: 'now +8 seconds'); @@ -154,7 +156,7 @@ public function testShouldSetCookieReplacingGlobalExpirationValueWhenNewOneIsPas /** * @runInSeparateProcess */ - public function testShouldSetCookieFormattingExpirationFromStringDateTime(): void + public function test_should_set_formatting_expiration_from_string_date_time(): void { $this->cookie->set('foo', 'bar', 'now + 8 seconds'); @@ -166,7 +168,7 @@ public function testShouldSetCookieFormattingExpirationFromStringDateTime(): voi /** * @runInSeparateProcess */ - public function testShouldSetCookieFormattingExpirationFromInteger(): void + public function test_should_set_formatting_expiration_from_integer(): void { $this->cookie->set('foo', 'bar', time() + 8); @@ -178,7 +180,7 @@ public function testShouldSetCookieFormattingExpirationFromInteger(): void /** * @runInSeparateProcess */ - public function testShouldSetCookieFormattingExpirationFromDateTimeObject(): void + public function test_should_set_formatting_expiration_from_date_time_object(): void { $this->cookie->set('foo', 'bar', new DateTime('now +8 seconds')); @@ -187,7 +189,7 @@ public function testShouldSetCookieFormattingExpirationFromDateTimeObject(): voi $this->assertEquals(time() + 8, $details['expires']); } - public function testShouldFailWhenParseWrongTimeString(): void + public function test_should_fail_when_parse_wrong_time_string(): void { $this->expectException(CookieException::class); @@ -196,7 +198,7 @@ public function testShouldFailWhenParseWrongTimeString(): void $this->cookie->set('foo', 'bar', 'foo'); } - public function testShouldFailWhenHeadersSent(): void + public function test_should_fail_when_headers_sent(): void { $this->expectException(CookieException::class); @@ -206,7 +208,7 @@ public function testShouldFailWhenHeadersSent(): void /** * @runInSeparateProcess */ - public function testShouldBeAvailableFromTheFacade(): void + public function test_should_be_available_from_the_facade(): void { $facade = new CookieFacade();