Skip to content

Commit

Permalink
Try to fix setcookie() tests on 32-bit
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Sep 8, 2020
1 parent a6a9611 commit 2d1b872
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 15 deletions.
20 changes: 12 additions & 8 deletions ext/standard/tests/network/setcookie_array_option_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ try {
} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
// Invalid expiration date
// To go above year 9999: 60 * 60 * 24 * 365 * 9999
try {
setcookie('name', 'value', ['expires' => 315328464000]);
} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
// Invalid path key content
try {
setcookie('name', 'value', ['path' => '/;/']);
Expand All @@ -52,17 +45,28 @@ try {
echo $e->getMessage() . "\n";
}

if (PHP_INT_SIZE == 8) {
try {
// To go above year 9999: 60 * 60 * 24 * 365 * 9999
setrawcookie('name', 'value', ['expires' => 315328464000]);
} catch (\ValueError $e) {
var_dump($e->getMessage() == 'setcookie(): "expires" option cannot have a year greater than 9999');
}
} else {
var_dump(true);
}

var_dump(headers_list());
--EXPECTHEADERS--

--EXPECTF--
setcookie(): option "unknown_key" is invalid
setcookie(): option array cannot have numeric keys
setcookie(): option "foo" is invalid
setcookie(): "expires" option cannot have a year greater than 9999
setcookie(): "path" option cannot contain ",", ";", " ", "\t", "\r", "\n", "\013", or "\014"
setcookie(): "domain" option cannot contain ",", ";", " ", "\t", "\r", "\n", "\013", or "\014"
setcookie(): Expects exactly 3 arguments when argument #3 ($expires_or_options) is an array
bool(false)
array(1) {
[0]=>
string(%s) "X-Powered-By: PHP/%s"
Expand Down
21 changes: 14 additions & 7 deletions ext/standard/tests/network/setcookie_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ try {
} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
// To go above year 9999: 60 * 60 * 24 * 365 * 9999
try {
setcookie('name', 'value', 315328464000);
} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
setcookie('name', 'value', 100, 'invalid;');
} catch (\ValueError $e) {
Expand All @@ -39,15 +33,28 @@ try {
echo $e->getMessage() . "\n";
}

if (PHP_INT_SIZE == 8) {
try {
// To go above year 9999: 60 * 60 * 24 * 365 * 9999
setcookie('name', 'value', 315328464000);
} catch (\ValueError $e) {
var_dump($e->getMessage() == 'setcookie(): "expires" option cannot have a year greater than 9999');
}
} else {
var_dump(true);
}

var_dump(headers_list());

?>
--EXPECTHEADERS--

--EXPECTF--
setcookie(): Argument #1 ($name) cannot be empty
setcookie(): Argument #1 ($name) cannot contain "=", ",", ";", " ", "\t", "\r", "\n", "\013", or "\014"
setcookie(): "expires" option cannot have a year greater than 9999
setcookie(): "path" option cannot contain ",", ";", " ", "\t", "\r", "\n", "\013", or "\014"
setcookie(): "domain" option cannot contain ",", ";", " ", "\t", "\r", "\n", "\013", or "\014"
bool(true)
array(2) {
[0]=>
string(%d) "X-Powered-By: PHP/%s"
Expand Down
14 changes: 14 additions & 0 deletions ext/standard/tests/network/setrawcookie_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,20 @@ try {
echo $e->getMessage() . "\n";
}

if (PHP_INT_SIZE == 8) {
try {
// To go above year 9999: 60 * 60 * 24 * 365 * 9999
setrawcookie('name', 'value', 315328464000);
} catch (\ValueError $e) {
var_dump($e->getMessage() == 'setrawcookie(): "expires" option cannot have a year greater than 9999');
}
} else {
var_dump(true);
}

var_dump(headers_list());

?>
--EXPECTHEADERS--

--EXPECTF--
Expand All @@ -49,6 +62,7 @@ setrawcookie(): Argument #2 ($value) cannot contain ",", ";", " ", "\t", "\r", "
setrawcookie(): "expires" option cannot have a year greater than 9999
setrawcookie(): "path" option cannot contain ",", ";", " ", "\t", "\r", "\n", "\013", or "\014"
setrawcookie(): "domain" option cannot contain ",", ";", " ", "\t", "\r", "\n", "\013", or "\014"
bool(true)
array(1) {
[0]=>
string(%d) "X-Powered-By: PHP/%s"
Expand Down

0 comments on commit 2d1b872

Please sign in to comment.