InputBagTest.php in Drupal 9
File
core/tests/Drupal/Tests/Core/Http/InputBagTest.php
View source
<?php
namespace Drupal\Tests\Core\Http;
use Drupal\Core\Http\InputBag;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\HttpFoundation\Request;
class InputBagTest extends UnitTestCase {
public function testAll() {
$input = [
'bad' => 'bad',
'good' => [
'good',
],
];
$input_bag = new InputBag();
$input_bag
->replace($input);
$this
->assertSame($input_bag
->all(), $input);
$this
->assertSame($input_bag
->all('good'), [
'good',
]);
$this
->expectException(\UnexpectedValueException::class);
$input_bag
->all('bad');
}
public function testRequestFactory() {
$request = Request::create('');
$this
->assertInstanceOf(InputBag::class, $request->query);
}
}