Skip to content

Commit cd42394

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: [Serializer] Improve exception message in UnwrappingDenormalizer [PropertyInfo] Update DoctrineExtractor for new DBAL 4 BIGINT type Update security.nl.xlf [Validator] IBAN Check digits should always between 2 and 98 [Security] Populate translations for trans-unit 20 add missing plural translation messages filter out empty HTTP header parts [String] Fix folded in compat mode Remove calls to `getMockForAbstractClass()` [ErrorHandler] Do not call xdebug_get_function_stack() with xdebug >= 3.0 when not in develop mode [Serializer] Fix type for missing property add test for JSON response with null as content [Filesystem] Fix dumpFile `stat failed` error hitting custom handler Return false in isTtySupported() when open_basedir restrictions prevent access to /dev/tty. Remove calls to `TestCase::iniSet()` and calls to deprecated methods of `MockBuilder` [PhpUnitBridge] Fix `DeprecationErrorHandler` with PhpUnit 10
2 parents 0194e06 + 74e9c22 commit cd42394

6 files changed

+67
-24
lines changed

HeaderUtils.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,11 @@ private static function groupParts(array $matches, string $separators, bool $fir
286286
}
287287

288288
foreach ($partMatches as $matches) {
289-
$parts[] = '' === $separators ? self::unquote($matches[0][0]) : self::groupParts($matches, $separators, false);
289+
if ('' === $separators && '' !== $unquoted = self::unquote($matches[0][0])) {
290+
$parts[] = $unquoted;
291+
} elseif ($groupedParts = self::groupParts($matches, $separators, false)) {
292+
$parts[] = $groupedParts;
293+
}
290294
}
291295

292296
return $parts;

Tests/AcceptHeaderTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public static function provideFromStringData()
4141
{
4242
return [
4343
['', []],
44+
[';;;', []],
45+
['0', [new AcceptHeaderItem('0')]],
4446
['gzip', [new AcceptHeaderItem('gzip')]],
4547
['gzip,deflate,sdch', [new AcceptHeaderItem('gzip'), new AcceptHeaderItem('deflate'), new AcceptHeaderItem('sdch')]],
4648
["gzip, deflate\t,sdch", [new AcceptHeaderItem('gzip'), new AcceptHeaderItem('deflate'), new AcceptHeaderItem('sdch')]],

Tests/JsonResponseTest.php

+8
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,14 @@ public function testConstructorWithObjectWithoutToStringMethodThrowsAnException(
190190

191191
new JsonResponse(new \stdClass(), 200, [], true);
192192
}
193+
194+
public function testSetDataWithNull()
195+
{
196+
$response = new JsonResponse();
197+
$response->setData(null);
198+
199+
$this->assertSame('null', $response->getContent());
200+
}
193201
}
194202

195203
class JsonSerializableObject implements \JsonSerializable

Tests/Session/Storage/NativeSessionStorageTest.php

+41-20
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@ class NativeSessionStorageTest extends TestCase
3434
{
3535
private string $savePath;
3636

37+
private $initialSessionSaveHandler;
38+
private $initialSessionSavePath;
39+
3740
protected function setUp(): void
3841
{
39-
$this->iniSet('session.save_handler', 'files');
40-
$this->iniSet('session.save_path', $this->savePath = sys_get_temp_dir().'/sftest');
42+
$this->initialSessionSaveHandler = ini_set('session.save_handler', 'files');
43+
$this->initialSessionSavePath = ini_set('session.save_path', $this->savePath = sys_get_temp_dir().'/sftest');
44+
4145
if (!is_dir($this->savePath)) {
4246
mkdir($this->savePath);
4347
}
@@ -50,6 +54,10 @@ protected function tearDown(): void
5054
if (is_dir($this->savePath)) {
5155
@rmdir($this->savePath);
5256
}
57+
58+
$this->savePath = null;
59+
ini_set('session.save_handler', $this->initialSessionSaveHandler);
60+
ini_set('session.save_path', $this->initialSessionSavePath);
5361
}
5462

5563
protected function getStorage(array $options = []): NativeSessionStorage
@@ -152,18 +160,26 @@ public function testRegenerationFailureDoesNotFlagStorageAsStarted()
152160

153161
public function testDefaultSessionCacheLimiter()
154162
{
155-
$this->iniSet('session.cache_limiter', 'nocache');
163+
$initialLimiter = ini_set('session.cache_limiter', 'nocache');
156164

157-
new NativeSessionStorage();
158-
$this->assertEquals('', \ini_get('session.cache_limiter'));
165+
try {
166+
new NativeSessionStorage();
167+
$this->assertEquals('', \ini_get('session.cache_limiter'));
168+
} finally {
169+
ini_set('session.cache_limiter', $initialLimiter);
170+
}
159171
}
160172

161173
public function testExplicitSessionCacheLimiter()
162174
{
163-
$this->iniSet('session.cache_limiter', 'nocache');
175+
$initialLimiter = ini_set('session.cache_limiter', 'nocache');
164176

165-
new NativeSessionStorage(['cache_limiter' => 'public']);
166-
$this->assertEquals('public', \ini_get('session.cache_limiter'));
177+
try {
178+
new NativeSessionStorage(['cache_limiter' => 'public']);
179+
$this->assertEquals('public', \ini_get('session.cache_limiter'));
180+
} finally {
181+
ini_set('session.cache_limiter', $initialLimiter);
182+
}
167183
}
168184

169185
public function testCookieOptions()
@@ -203,18 +219,23 @@ public function testSessionOptions()
203219

204220
public function testSetSaveHandler()
205221
{
206-
$this->iniSet('session.save_handler', 'files');
207-
$storage = $this->getStorage();
208-
$storage->setSaveHandler(null);
209-
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
210-
$storage->setSaveHandler(new SessionHandlerProxy(new NativeFileSessionHandler()));
211-
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
212-
$storage->setSaveHandler(new NativeFileSessionHandler());
213-
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
214-
$storage->setSaveHandler(new SessionHandlerProxy(new NullSessionHandler()));
215-
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
216-
$storage->setSaveHandler(new NullSessionHandler());
217-
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
222+
$initialSaveHandler = ini_set('session.save_handler', 'files');
223+
224+
try {
225+
$storage = $this->getStorage();
226+
$storage->setSaveHandler(null);
227+
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
228+
$storage->setSaveHandler(new SessionHandlerProxy(new NativeFileSessionHandler()));
229+
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
230+
$storage->setSaveHandler(new NativeFileSessionHandler());
231+
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
232+
$storage->setSaveHandler(new SessionHandlerProxy(new NullSessionHandler()));
233+
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
234+
$storage->setSaveHandler(new NullSessionHandler());
235+
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
236+
} finally {
237+
ini_set('session.save_handler', $initialSaveHandler);
238+
}
218239
}
219240

220241
public function testStarted()

Tests/Session/Storage/PhpBridgeSessionStorageTest.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,14 @@ class PhpBridgeSessionStorageTest extends TestCase
3030
{
3131
private string $savePath;
3232

33+
private $initialSessionSaveHandler;
34+
private $initialSessionSavePath;
35+
3336
protected function setUp(): void
3437
{
35-
$this->iniSet('session.save_handler', 'files');
36-
$this->iniSet('session.save_path', $this->savePath = sys_get_temp_dir().'/sftest');
38+
$this->initialSessionSaveHandler = ini_set('session.save_handler', 'files');
39+
$this->initialSessionSavePath = ini_set('session.save_path', $this->savePath = sys_get_temp_dir().'/sftest');
40+
3741
if (!is_dir($this->savePath)) {
3842
mkdir($this->savePath);
3943
}
@@ -46,6 +50,10 @@ protected function tearDown(): void
4650
if (is_dir($this->savePath)) {
4751
@rmdir($this->savePath);
4852
}
53+
54+
$this->savePath = null;
55+
ini_set('session.save_handler', $this->initialSessionSaveHandler);
56+
ini_set('session.save_path', $this->initialSessionSavePath);
4957
}
5058

5159
protected function getStorage(): PhpBridgeSessionStorage

Tests/Session/Storage/Proxy/AbstractProxyTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class AbstractProxyTest extends TestCase
2727

2828
protected function setUp(): void
2929
{
30-
$this->proxy = $this->getMockForAbstractClass(AbstractProxy::class);
30+
$this->proxy = new class() extends AbstractProxy {};
3131
}
3232

3333
public function testGetSaveHandlerName()

0 commit comments

Comments
 (0)