Skip to content

Commit

Permalink
Test setting new invalid value
Browse files Browse the repository at this point in the history
  • Loading branch information
g105b committed Jan 16, 2018
1 parent 1fa49d3 commit 88f7fb7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Validity.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public static function isValidName(string $name):bool {
public static function isValidValue(string $value):bool {
$valid = true;

if($value === "") {
return $valid;
}

$nameChars = str_split($value, 1);
$validChars = self::getValidNameCharacters();
foreach($nameChars as $c) {
Expand Down
21 changes: 21 additions & 0 deletions test/unit/CookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,27 @@ public function testConstructInvalidName(string $name, string $value) {
new Cookie($name);
}

/**
* @dataProvider dataNameValue
*/
public function testConstructInvalidValue(string $name, string $value) {
$value = $this->injectInvalidCharacters($value);

self::expectException(InvalidCharactersException::class);
new Cookie($name, $value);
}

/**
* @dataProvider dataNameValue
*/
public function testSetInvalidValue(string $name, string $value) {
$value = $this->injectInvalidCharacters($value);

$cookie = new Cookie($name);
self::expectException(InvalidCharactersException::class);
$cookie->withValue($value);
}

public static function dataNameValue():array {
$data = [];

Expand Down

0 comments on commit 88f7fb7

Please sign in to comment.