Skip to content

Commit

Permalink
Merge branch '7.0' into 7.1
Browse files Browse the repository at this point in the history
* 7.0:
  [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
  • Loading branch information
fabpot committed May 17, 2024
2 parents b71e324 + cd42394 commit bab3b44
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 24 deletions.
6 changes: 5 additions & 1 deletion HeaderUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,11 @@ private static function groupParts(array $matches, string $separators, bool $fir
}

foreach ($partMatches as $matches) {
$parts[] = '' === $separators ? self::unquote($matches[0][0]) : self::groupParts($matches, $separators, false);
if ('' === $separators && '' !== $unquoted = self::unquote($matches[0][0])) {
$parts[] = $unquoted;
} elseif ($groupedParts = self::groupParts($matches, $separators, false)) {
$parts[] = $groupedParts;
}
}

return $parts;
Expand Down
2 changes: 2 additions & 0 deletions Tests/AcceptHeaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public static function provideFromStringData()
{
return [
['', []],
[';;;', []],
['0', [new AcceptHeaderItem('0')]],
['gzip', [new AcceptHeaderItem('gzip')]],
['gzip,deflate,sdch', [new AcceptHeaderItem('gzip'), new AcceptHeaderItem('deflate'), new AcceptHeaderItem('sdch')]],
["gzip, deflate\t,sdch", [new AcceptHeaderItem('gzip'), new AcceptHeaderItem('deflate'), new AcceptHeaderItem('sdch')]],
Expand Down
8 changes: 8 additions & 0 deletions Tests/JsonResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,14 @@ public function testConstructorWithObjectWithoutToStringMethodThrowsAnException(

new JsonResponse(new \stdClass(), 200, [], true);
}

public function testSetDataWithNull()
{
$response = new JsonResponse();
$response->setData(null);

$this->assertSame('null', $response->getContent());
}
}

class JsonSerializableObject implements \JsonSerializable
Expand Down
61 changes: 41 additions & 20 deletions Tests/Session/Storage/NativeSessionStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ class NativeSessionStorageTest extends TestCase
{
private string $savePath;

private $initialSessionSaveHandler;
private $initialSessionSavePath;

protected function setUp(): void
{
$this->iniSet('session.save_handler', 'files');
$this->iniSet('session.save_path', $this->savePath = sys_get_temp_dir().'/sftest');
$this->initialSessionSaveHandler = ini_set('session.save_handler', 'files');
$this->initialSessionSavePath = ini_set('session.save_path', $this->savePath = sys_get_temp_dir().'/sftest');

if (!is_dir($this->savePath)) {
mkdir($this->savePath);
}
Expand All @@ -50,6 +54,10 @@ protected function tearDown(): void
if (is_dir($this->savePath)) {
@rmdir($this->savePath);
}

$this->savePath = null;
ini_set('session.save_handler', $this->initialSessionSaveHandler);
ini_set('session.save_path', $this->initialSessionSavePath);
}

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

public function testDefaultSessionCacheLimiter()
{
$this->iniSet('session.cache_limiter', 'nocache');
$initialLimiter = ini_set('session.cache_limiter', 'nocache');

new NativeSessionStorage();
$this->assertEquals('', \ini_get('session.cache_limiter'));
try {
new NativeSessionStorage();
$this->assertEquals('', \ini_get('session.cache_limiter'));
} finally {
ini_set('session.cache_limiter', $initialLimiter);
}
}

public function testExplicitSessionCacheLimiter()
{
$this->iniSet('session.cache_limiter', 'nocache');
$initialLimiter = ini_set('session.cache_limiter', 'nocache');

new NativeSessionStorage(['cache_limiter' => 'public']);
$this->assertEquals('public', \ini_get('session.cache_limiter'));
try {
new NativeSessionStorage(['cache_limiter' => 'public']);
$this->assertEquals('public', \ini_get('session.cache_limiter'));
} finally {
ini_set('session.cache_limiter', $initialLimiter);
}
}

public function testCookieOptions()
Expand Down Expand Up @@ -203,18 +219,23 @@ public function testSessionOptions()

public function testSetSaveHandler()
{
$this->iniSet('session.save_handler', 'files');
$storage = $this->getStorage();
$storage->setSaveHandler(null);
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
$storage->setSaveHandler(new SessionHandlerProxy(new NativeFileSessionHandler()));
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
$storage->setSaveHandler(new NativeFileSessionHandler());
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
$storage->setSaveHandler(new SessionHandlerProxy(new NullSessionHandler()));
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
$storage->setSaveHandler(new NullSessionHandler());
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
$initialSaveHandler = ini_set('session.save_handler', 'files');

try {
$storage = $this->getStorage();
$storage->setSaveHandler(null);
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
$storage->setSaveHandler(new SessionHandlerProxy(new NativeFileSessionHandler()));
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
$storage->setSaveHandler(new NativeFileSessionHandler());
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
$storage->setSaveHandler(new SessionHandlerProxy(new NullSessionHandler()));
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
$storage->setSaveHandler(new NullSessionHandler());
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
} finally {
ini_set('session.save_handler', $initialSaveHandler);
}
}

public function testStarted()
Expand Down
12 changes: 10 additions & 2 deletions Tests/Session/Storage/PhpBridgeSessionStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ class PhpBridgeSessionStorageTest extends TestCase
{
private string $savePath;

private $initialSessionSaveHandler;
private $initialSessionSavePath;

protected function setUp(): void
{
$this->iniSet('session.save_handler', 'files');
$this->iniSet('session.save_path', $this->savePath = sys_get_temp_dir().'/sftest');
$this->initialSessionSaveHandler = ini_set('session.save_handler', 'files');
$this->initialSessionSavePath = ini_set('session.save_path', $this->savePath = sys_get_temp_dir().'/sftest');

if (!is_dir($this->savePath)) {
mkdir($this->savePath);
}
Expand All @@ -46,6 +50,10 @@ protected function tearDown(): void
if (is_dir($this->savePath)) {
@rmdir($this->savePath);
}

$this->savePath = null;
ini_set('session.save_handler', $this->initialSessionSaveHandler);
ini_set('session.save_path', $this->initialSessionSavePath);
}

protected function getStorage(): PhpBridgeSessionStorage
Expand Down
2 changes: 1 addition & 1 deletion Tests/Session/Storage/Proxy/AbstractProxyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AbstractProxyTest extends TestCase

protected function setUp(): void
{
$this->proxy = $this->getMockForAbstractClass(AbstractProxy::class);
$this->proxy = new class() extends AbstractProxy {};
}

public function testGetSaveHandlerName()
Expand Down

0 comments on commit bab3b44

Please sign in to comment.