Skip to content

Commit d663c21

Browse files
committed
Improve SwoftTest\Http\Server\Testing\MockResponse::cookie() method: Swoole 4.5.8.
Use swoole/ide-helper library because swoft/swoole-ide-helper is too old.
1 parent 154fe29 commit d663c21

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
},
3030
"require-dev": {
3131
"phpunit/phpunit": "^7.5",
32-
"swoft/swoole-ide-helper": "dev-master"
32+
"swoole/ide-helper": "dev-master"
3333
},
3434
"replace": {
3535
"swoft/annotation": "self.version",

src/http-server/test/testing/MockResponse.php

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,15 @@ public function header($key, $value, $ucwords = null)
8080
}
8181

8282
/**
83-
* @param string $name
84-
* @param string $value
85-
* @param int|string $expires
86-
* @param string|null $path
87-
* @param string $domain
88-
* @param bool $secure
89-
* @param bool $httpOnly
90-
* @param null $samesite
83+
* @param string $name
84+
* @param string|null $value
85+
* @param int|string|null $expires
86+
* @param string|null $path
87+
* @param string|null $domain
88+
* @param bool|null $secure
89+
* @param bool|null $httpOnly
90+
* @param string|null $samesite
91+
* @param string|null $priority
9192
*/
9293
public function cookie(
9394
$name,
@@ -97,7 +98,8 @@ public function cookie(
9798
$domain = null,
9899
$secure = null,
99100
$httpOnly = null,
100-
$samesite = null
101+
$samesite = null,
102+
$priority = null
101103
) {
102104
$result = \urlencode($name) . '=' . \urlencode($value);
103105

@@ -117,22 +119,26 @@ public function cookie(
117119
}
118120

119121
if ($timestamp !== 0) {
120-
$result .= '; expires=' . \gmdate('D, d-M-Y H:i:s e', $timestamp);
122+
$result .= '; Expires=' . \gmdate('D, d-M-Y H:i:s e', $timestamp);
121123
}
122124
}
123125

124126
if ($secure) {
125-
$result .= '; secure';
127+
$result .= '; Secure';
126128
}
127129

128-
// if ($hostOnly) {
129-
// $result .= '; HostOnly';
130-
// }
131-
132130
if ($httpOnly) {
133131
$result .= '; HttpOnly';
134132
}
135133

134+
if ($samesite) {
135+
$result .= '; SameSite=' . $samesite;
136+
}
137+
138+
if ($priority) {
139+
$result .= '; Priority=' . $priority;
140+
}
141+
136142
$this->cookie[$name] = $result;
137143
}
138144

0 commit comments

Comments
 (0)