prefix
stringlengths
512
512
suffix
stringlengths
256
256
middle
stringlengths
14
229
meta
dict
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\Tests; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\Context\ContextInterface; use Symfo...
s->assertSame($expected, $package->getUrl($path)); } public static function getConfigs() { return [ ['/foo', '', 'http://example.com/foo', 'http://example.com/foo'], ['/foo', '', 'https://example.com/foo', 'http
extends TestCase { #[DataProvider('getConfigs')] public function testGetUrl($basePath, $format, $path, $expected) { $package = new PathPackage($basePath, new StaticVersionStrategy('v1', $format)); $thi
{ "filepath": "src/Symfony/Component/Asset/Tests/PathPackageTest.php", "language": "php", "file_size": 3428, "cut_index": 614, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\Tests\Context; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\Context\RequestStackCon...
h = 'test-path'; $request = $this->createStub(Request::class); $request->method('getBasePath') ->willReturn($testBasePath); $requestStack = new RequestStack(); $requestStack->push($request); $requestSta
y() { $requestStackContext = new RequestStackContext(new RequestStack()); $this->assertSame('', $requestStackContext->getBasePath()); } public function testGetBasePathSet() { $testBasePat
{ "filepath": "src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php", "language": "php", "file_size": 2066, "cut_index": 563, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\Tests\VersionStrategy; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\Exception\AssetNotF...
tegy) { $this->assertSame('main.123abc.js', $strategy->getVersion('main.js')); } #[DataProvider('provideValidStrategies')] public function testApplyVersion(JsonManifestVersionStrategy $strategy) { $this->assertSame('css
use Symfony\Component\HttpClient\Response\MockResponse; class JsonManifestVersionStrategyTest extends TestCase { #[DataProvider('provideValidStrategies')] public function testGetVersion(JsonManifestVersionStrategy $stra
{ "filepath": "src/Symfony/Component/Asset/Tests/VersionStrategy/JsonManifestVersionStrategyTest.php", "language": "php", "file_size": 4997, "cut_index": 614, "middle_length": 229 }
This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\Tests\VersionStrategy; use PHPUnit\Framework\Attributes\Dat...
[DataProvider('getConfigs')] public function testApplyVersion($path, $version, $format) { $staticVersionStrategy = new StaticVersionStrategy($version, $format); $formatted = \sprintf($format ?: '%s?%s', $path, $version); $th
sion() { $version = 'v1'; $path = 'test-path'; $staticVersionStrategy = new StaticVersionStrategy($version); $this->assertSame($version, $staticVersionStrategy->getVersion($path)); } #
{ "filepath": "src/Symfony/Component/Asset/Tests/VersionStrategy/StaticVersionStrategyTest.php", "language": "php", "file_size": 1256, "cut_index": 524, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation; /** * Represents an Accept-* header item. * * @author Jean-François Simon <contact@jfsimon.fr> */ class AcceptHeaderItem { private ...
g(?string $itemValue): self { $parts = HeaderUtils::split($itemValue ?? '', ';='); $part = array_shift($parts); $attributes = HeaderUtils::combine($parts); return new self($part[0], $attributes); } /** *
foreach ($attributes as $name => $value) { $this->setAttribute($name, $value); } } /** * Builds an AcceptHeaderInstance instance from a string. */ public static function fromStrin
{ "filepath": "src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php", "language": "php", "file_size": 3234, "cut_index": 614, "middle_length": 229 }
ackage. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation; /** * ChainRequestMatcher verifies that all checks match against a Request instance...
$matchers) { } public function matches(Request $request): bool { foreach ($this->matchers as $matcher) { if (!$matcher->matches($request)) { return false; } } return true;
*/ public function __construct(private iterable
{ "filepath": "src/Symfony/Component/HttpFoundation/ChainRequestMatcher.php", "language": "php", "file_size": 873, "cut_index": 559, "middle_length": 52 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation; use Symfony\Component\HttpFoundation\File\UploadedFile; /** * FileBag is a container for uploaded files. * * @author Fabien Potencier <...
ace(array $files = []): void { $this->parameters = []; $this->add($files); } public function set(string $key, mixed $value): void { if (!\is_array($value) && !$value instanceof UploadedFile) { throw new
', 'type']; /** * @param array|UploadedFile[] $parameters An array of HTTP files */ public function __construct(array $parameters = []) { $this->replace($parameters); } public function repl
{ "filepath": "src/Symfony/Component/HttpFoundation/FileBag.php", "language": "php", "file_size": 3857, "cut_index": 614, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpFoundation; /** * HeaderBag is a container for HTTP headers. * * @author Fabien Potencier <fabien@symfony.com> * * @implements \IteratorAggregate<string, list<string|null>> */ class HeaderBag implements \IteratorAggregate, \Countable, \Stringable ...
/** * Returns the headers as a string. */ public function __toString(): string { if (!$headers = $this->all()) { return ''; } ksort($headers); $max = max(array_map('strlen', array_keys($hea
ted array $headers = []; protected array $cacheControl = []; public function __construct(array $headers = []) { foreach ($headers as $key => $values) { $this->set($key, $values); } }
{ "filepath": "src/Symfony/Component/HttpFoundation/HeaderBag.php", "language": "php", "file_size": 7103, "cut_index": 716, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpFoundation; use Symfony\Component\HttpFoundation\Exception\BadRequestException; use Symfony\Component\HttpFoundation\Exception\UnexpectedValueException; /** * InputBag is a container for user input values such as $_GET, $_POST, $_REQUEST, and $_COOKIE...
s BadRequestException if the input contains a non-scalar value */ public function get(string $key, mixed $default = null): string|int|float|bool|null { if (null !== $default && !\is_scalar($default) && !$default instanceof \Stringable)
put value by name. * * @template TDefault of string|int|float|bool|null * * @param TDefault $default The default value if the input key does not exist * * @return TDefault|TInput * * @throw
{ "filepath": "src/Symfony/Component/HttpFoundation/InputBag.php", "language": "php", "file_size": 6313, "cut_index": 716, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpFoundation; use Symfony\Component\HttpFoundation\Exception\BadRequestException; use Symfony\Component\HttpFoundation\Exception\UnexpectedValueException; /** * ParameterBag is a container for key/value pairs. * * @author Fabien Potencier <fabien@symf...
to return or null to get them all * * @return (TKey is null ? array<string, mixed> : array<mixed>) * * @throws BadRequestException if the value is not an array */ public function all(?string $key = null): array { if
public function __construct( protected array $parameters = [], ) { } /** * Returns the parameters. * * @template TKey of string|null * * @param TKey $key The name of the parameter
{ "filepath": "src/Symfony/Component/HttpFoundation/ParameterBag.php", "language": "php", "file_size": 8475, "cut_index": 716, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation; use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException; use Symfony\Component\HttpFoundation\Session\SessionInterface; /*...
* * Pushes a Request on the stack. * * This method should generally not be called directly as the stack * management should be taken care of by the application itself. */ public function push(Request $request): void {
y $requests = []; /** * @param Request[] $requests */ public function __construct(array $requests = []) { foreach ($requests as $request) { $this->push($request); } } /*
{ "filepath": "src/Symfony/Component/HttpFoundation/RequestStack.php", "language": "php", "file_size": 3124, "cut_index": 614, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpFoundation; /** * ResponseHeaderBag is a container for Response HTTP headers. * * @author Fabien Potencier <fabien@symfony.com> */ class ResponseHeaderBag extends HeaderBag { public const COOKIES_FLAT = 'flat'; public const COOKIES_ARRAY = '...
Control', ''); } /* RFC2616 - 14.18 says all Responses need to have a Date */ if (!isset($this->headers['date'])) { $this->initDate(); } } /** * Returns the headers, with original capitalizations.
[]; protected array $headerNames = []; public function __construct(array $headers = []) { parent::__construct($headers); if (!isset($this->headers['cache-control'])) { $this->set('Cache-
{ "filepath": "src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php", "language": "php", "file_size": 7858, "cut_index": 716, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation; /** * StreamedResponse represents a streamed HTTP response. * * A StreamedResponse uses a callback or an iterable of strings for its con...
* @param callable|iterable<string>|null $callbackOrChunks * @param int $status The HTTP status code (200 "OK" by default) */ public function __construct(callable|iterable|null $callbackOrChunks = null, in
* @author Fabien Potencier <fabien@symfony.com> */ class StreamedResponse extends Response { protected ?\Closure $callback = null; protected bool $streamed = false; private bool $headersSent = false; /**
{ "filepath": "src/Symfony/Component/HttpFoundation/StreamedResponse.php", "language": "php", "file_size": 3654, "cut_index": 614, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation; use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\RequestContextAwareInterface; /** * A helper service for mani...
/') || str_starts_with($path, '//')) { return $path; } if (null === $request = $this->requestStack->getMainRequest()) { return $this->getAbsoluteUrlFromContext($path); } if ('#' === $path[0]) {
equestStack $requestStack, private RequestContextAwareInterface|RequestContext|null $requestContext = null, ) { } public function getAbsoluteUrl(string $path): string { if (str_contains($path, ':/
{ "filepath": "src/Symfony/Component/HttpFoundation/UrlHelper.php", "language": "php", "file_size": 3124, "cut_index": 614, "middle_length": 229 }
ackage. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\Tests\VersionStrategy; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\VersionStra...
ptyVersionStrategy->getVersion($path)); } public function testApplyVersion() { $emptyVersionStrategy = new EmptyVersionStrategy(); $path = 'test-path'; $this->assertSame($path, $emptyVersionStrategy->applyVersion($path
th = 'test-path'; $this->assertSame('', $em
{ "filepath": "src/Symfony/Component/Asset/Tests/VersionStrategy/EmptyVersionStrategyTest.php", "language": "php", "file_size": 879, "cut_index": 559, "middle_length": 52 }
buted with this source code. */ namespace Symfony\Component\HttpFoundation; // Help opcache.preload discover always-needed symbols class_exists(AcceptHeaderItem::class); /** * Represents an Accept-* header. * * An accept header is compound with a list of items, * sorted by descending quality. * * @author Jean...
tance from a string. */ public static function fromString(?string $headerValue): self { $items = []; foreach (HeaderUtils::split($headerValue ?? '', ',;=') as $i => $parts) { $part = array_shift($parts);
/** * @param AcceptHeaderItem[] $items */ public function __construct(array $items) { foreach ($items as $item) { $this->add($item); } } /** * Builds an AcceptHeader ins
{ "filepath": "src/Symfony/Component/HttpFoundation/AcceptHeader.php", "language": "php", "file_size": 9022, "cut_index": 716, "middle_length": 229 }
ITE_NONE = 'none'; public const SAMESITE_LAX = 'lax'; public const SAMESITE_STRICT = 'strict'; protected int $expire; protected string $path; private ?string $sameSite = null; private bool $secureDefault = false; private const RESERVED_CHARS_LIST = "=,; \t\r\n\v\f"; private const RESE...
> null, 'secure' => false, 'httponly' => false, 'raw' => !$decode, 'samesite' => null, 'partitioned' => false, ]; $parts = HeaderUtils::split($cookie, ';='); $part = array
ates cookie from raw header string. */ public static function fromString(string $cookie, bool $decode = false): static { $data = [ 'expires' => 0, 'path' => '/', 'domain' =
{ "filepath": "src/Symfony/Component/HttpFoundation/Cookie.php", "language": "php", "file_size": 11807, "cut_index": 921, "middle_length": 229 }
t DISPOSITION_ATTACHMENT = 'attachment'; public const DISPOSITION_INLINE = 'inline'; /** * This class should not be instantiated. */ private function __construct() { } /** * Splits an HTTP header by one or more separators. * * Example: * * HeaderUtils::sp...
arators): array { if ('' === $separators) { throw new \InvalidArgumentException('At least one separator must be specified.'); } $quotedSeparators = preg_quote($separators, '/'); preg_match_all('
precedence, e.g. ',', ';=', or ',;=' * * @return array Nested array with as many levels as there are characters in * $separators */ public static function split(string $header, string $sep
{ "filepath": "src/Symfony/Component/HttpFoundation/HeaderUtils.php", "language": "php", "file_size": 9291, "cut_index": 921, "middle_length": 229 }
en no exact MIME match is found in $formats. * * It enables mappings like application/soap+xml -> xml. * * @see https://datatracker.ietf.org/doc/html/rfc6839 * @see https://datatracker.ietf.org/doc/html/rfc7303 * @see https://www.iana.org/assignments/media-types/media-types.xhtml */ ...
_deprecation('symfony/http-foundation', '8.1', 'Directly setting property "attributes" of "%s" is deprecated; pass attributes as a constructor argument or call "initialize()" instead.', static::class); $this->attributes = $value; }
asn1', 'der' => 'asn1', 'tlv' => 'tlv', 'wbxml' => 'xml', 'yaml' => 'yaml', ]; /** * Custom parameters. */ public ParameterBag $attributes { set { trigger
{ "filepath": "src/Symfony/Component/HttpFoundation/Request.php", "language": "php", "file_size": 78219, "cut_index": 3790, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\Exception\InvalidArgumentExcept...
->createStub(PackageInterface::class)); $packages->addPackage('a', $a = $this->createStub(PackageInterface::class)); $this->assertSame($default, $packages->getPackage()); $this->assertSame($a, $packages->getPackage('a'));
Component\Asset\VersionStrategy\StaticVersionStrategy; class PackagesTest extends TestCase { public function testGetterSetters() { $packages = new Packages(); $packages->setDefaultPackage($default = $this
{ "filepath": "src/Symfony/Component/Asset/Tests/PackagesTest.php", "language": "php", "file_size": 2282, "cut_index": 563, "middle_length": 229 }
FoundException; use Symfony\Component\HttpFoundation\File\File; /** * BinaryFileResponse represents an HTTP response delivering a file. * * @author Niklas Fiekas <niklas.fiekas@tu-clausthal.de> * @author stealth35 <stealth35-php@live.fr> * @author Igor Wiedler <igor@wiedler.ch> * @author Jordan Alliot <jordan.al...
* @param \SplFileInfo|string $file The file to stream * @param int $status The response status code (200 "OK" by default) * @param array $headers An array of response headers
file; protected ?\SplTempFileObject $tempFileObject = null; protected int $offset = 0; protected int $maxlen = -1; protected bool $deleteFileAfterSend = false; protected int $chunkSize = 16 * 1024; /**
{ "filepath": "src/Symfony/Component/HttpFoundation/BinaryFileResponse.php", "language": "php", "file_size": 14032, "cut_index": 921, "middle_length": 229 }
E_SUBNETS = [ '127.0.0.0/8', // RFC1700 (Loopback) '10.0.0.0/8', // RFC1918 '192.168.0.0/16', // RFC1918 '172.16.0.0/12', // RFC1918 '169.254.0.0/16', // RFC3927 '0.0.0.0/8', // RFC5735 '240.0.0.0/4', // RFC1112 '::1/128', // Loopbac...
'64:ff9b::/96', // NAT64 well-known prefix (RFC 6052) '64:ff9b:1::/48', // NAT64 local-use prefix (RFC 8215) ]; private static array $checkedIps = []; /** * This class should not be instantiated. */ private fun
::/128', // Unspecified address '::/96', // IPv4-compatible IPv6 addresses (RFC 4291 section 2.5.5.1) '2002::/16', // 6to4 (RFC 3056) '2001::/32', // Teredo tunneling (RFC 4380)
{ "filepath": "src/Symfony/Component/HttpFoundation/IpUtils.php", "language": "php", "file_size": 9427, "cut_index": 921, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation; /** * An event generated on the server intended for streaming to the client * as part of the SSE streaming technique. * * @implements \...
before reconnecting in case of network failure * @param string|null $id The event ID to set the EventSource object's last event ID value * @param string|null $comment The event comment */ public function _
ata field for the message * @param string|null $type The event type * @param int|null $retry The number of milliseconds the client should wait *
{ "filepath": "src/Symfony/Component/HttpFoundation/ServerEvent.php", "language": "php", "file_size": 3378, "cut_index": 614, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\Asset\Tests; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\Context\ContextInterface; use Symfony\Component\Asset\Exception\InvalidArgumentException; use Symfony\Component\Asset\Exception\LogicExce...
$package = new UrlPackage($baseUrls, new StaticVersionStrategy('v1', $format)); $this->assertSame($expected, $package->getUrl($path)); } public static function getConfigs(): array { return [ ['http://example
Component\Asset\VersionStrategy\VersionStrategyInterface; class UrlPackageTest extends TestCase { #[DataProvider('getConfigs')] public function testGetUrl($baseUrls, string $format, string $path, string $expected) {
{ "filepath": "src/Symfony/Component/Asset/Tests/UrlPackageTest.php", "language": "php", "file_size": 5918, "cut_index": 716, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpFoundation; /** * Response represents an HTTP response in JSON format. * * Note that this class does not force the returned JSON content to be an * object. It is however recommended that you do return an object as it * protects yourself against XSS...
be embedded into HTML. // 15 === JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT public const DEFAULT_ENCODING_OPTIONS = 15; protected int $encodingOptions = self::DEFAULT_ENCODING_OPTIONS; /** * @param bool $json If the
* @author Igor Wiedler <igor@wiedler.ch> */ class JsonResponse extends Response { protected mixed $data; protected ?string $callback = null; // Encode <, >, ', &, and " characters in the JSON, making it also safe to
{ "filepath": "src/Symfony/Component/HttpFoundation/JsonResponse.php", "language": "php", "file_size": 6601, "cut_index": 716, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation; /** * Represents a streaming HTTP response for sending server events * as part of the ...
w EventStreamResponse(function () { * yield new ServerEvent(time()); * * sleep(1); * * yield new ServerEvent(time()); * }); */ class EventStreamResponse extends StreamedResponse { /** * @param int|null $retry The
mfony Component, which relies on Software designed for these use * cases: https://symfony.com/doc/current/mercure.html * * @see ServerEvent * * @author Yonel Ceruto <open@yceruto.dev> * * Example usage: * * return ne
{ "filepath": "src/Symfony/Component/HttpFoundation/EventStreamResponse.php", "language": "php", "file_size": 2945, "cut_index": 563, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpFoundation\Tests; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\AcceptHeader; use Symfony\Component\HttpFoundation\AcceptHeaderItem; class AcceptHeaderTest extends TestCase { pub...
; // reset index since the fixtures don't have them set foreach ($parsed as $item) { $item->setIndex(0); } $this->assertEquals($items, $parsed); } public static function provideFromStringData() {
>getValue()); } #[DataProvider('provideFromStringData')] public function testFromString($string, array $items) { $header = AcceptHeader::fromString($string); $parsed = array_values($header->all())
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/AcceptHeaderTest.php", "language": "php", "file_size": 8728, "cut_index": 716, "middle_length": 229 }
Symfony\Component\HttpFoundation\ResponseHeaderBag; #[Group('time-sensitive')] class ResponseHeaderBagTest extends TestCase { public function testAllPreserveCase() { $headers = [ 'fOo' => 'BAR', 'ETag' => 'xyzzy', 'Content-MD5' => 'Q2hlY2sgSW50ZWdyaXR5IQ==', ...
allPreservedCase, '->allPreserveCase() gets all input keys in original case'); } } public function testCacheControlHeader() { $bag = new ResponseHeaderBag([]); $this->assertEquals('no-cache, private', $bag->get('Cache-C
block', ]; $bag = new ResponseHeaderBag($headers); $allPreservedCase = $bag->allPreserveCase(); foreach (array_keys($headers) as $headerName) { $this->assertArrayHasKey($headerName, $
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php", "language": "php", "file_size": 12782, "cut_index": 921, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\EventStreamResponse; use Symfony\Component\HttpFoundation\Server...
ve', $response->headers->get('connection')); $this->assertSame(200, $response->getStatusCode()); $this->assertNull($response->getRetry()); } public function testPresentOfExpiresHeader() { $response = new EventStreamRes
me('text/event-stream', $response->headers->get('content-type')); $this->assertSame('max-age=0, must-revalidate, no-cache, no-store, private', $response->headers->get('cache-control')); $this->assertSame('keep-ali
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/EventStreamResponseTest.php", "language": "php", "file_size": 4189, "cut_index": 614, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpFoundation\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\HeaderBag; class HeaderBagTest extends TestCase { public function testConstructor() { $bag = new HeaderBag(['foo' => 'bar']); $this->assertTr...
$keys = $bag->keys(); $this->assertEquals('foo', $keys[0]); } public function testGetDate() { $bag = new HeaderBag(['foo' => 'Tue, 4 Sep 2012 20:00:00 +0200']); $headerDate = $bag->getDate('foo'); $this->a
StringNotNull() { $bag = new HeaderBag(['foo' => 'bar']); $this->assertEquals("Foo: bar\r\n", $bag->__toString()); } public function testKeys() { $bag = new HeaderBag(['foo' => 'bar']);
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php", "language": "php", "file_size": 7731, "cut_index": 716, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpFoundation\Tests; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\HeaderUtils; class HeaderUtilsTest extends TestCase { #[DataProvider('provideHeaderToSplit')] public function ...
123'], ['bar']], 'foo=123, bar', ',;'], [['foo', '123, bar'], 'foo=123, bar', '='], [['foo', '123, bar'], ' foo = 123, bar ', '='], [[['foo', '123'], ['bar']], 'foo=123, bar', ',='], [[[['foo', '123']], [['ba
erToSplit(): array { return [ [['foo=123', 'bar'], 'foo=123,bar', ','], [['foo=123', 'bar'], 'foo=123, bar', ','], [[['foo=123', 'bar']], 'foo=123; bar', ',;'], [[['foo=
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/HeaderUtilsTest.php", "language": "php", "file_size": 7959, "cut_index": 716, "middle_length": 229 }
ork\TestCase; use Symfony\Component\HttpFoundation\IpUtils; class IpUtilsTest extends TestCase { public function testSeparateCachesPerProtocol() { $ip = '192.168.52.1'; $subnet = '192.168.0.0/16'; $this->assertFalse(IpUtils::checkIp6($ip, $subnet)); $this->assertTrue(IpUtils::c...
} public static function getIpv4Data() { return [ [true, '192.168.1.1', '192.168.1.1'], [true, '192.168.1.1', '192.168.1.1/1'], [true, '192.168.1.1', '192.168.1.0/24'], [false, '192.168.
s->assertTrue(IpUtils::checkIp6($ip, $subnet)); } #[DataProvider('getIpv4Data')] public function testIpv4($matches, $remoteAddr, $cidr) { $this->assertSame($matches, IpUtils::checkIp($remoteAddr, $cidr));
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php", "language": "php", "file_size": 10223, "cut_index": 921, "middle_length": 229 }
t\HttpFoundation\Exception\UnexpectedValueException; use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Tests\Fixtures\FooEnum; class ParameterBagTest extends TestCase { public function testConstructor() { $this->testAll(); } public function testAll() {...
unknown'), '->all() returns an empty array if a parameter is not defined'); } public function testAllThrowsForNonArrayValues() { $this->expectException(BadRequestException::class); $bag = new ParameterBag(['foo' => 'bar', 'null
{ $bag = new ParameterBag(['foo' => ['bar', 'baz'], 'null' => null]); $this->assertEquals(['bar', 'baz'], $bag->all('foo'), '->all() gets the value of a parameter'); $this->assertEquals([], $bag->all('
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php", "language": "php", "file_size": 15963, "cut_index": 921, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use ...
sertNull($requestStack->getCurrentRequest()); $request = Request::create('/foo'); $requestStack->push($request); $this->assertSame($request, $requestStack->getCurrentRequest()); $this->assertSame($request, $requestStack->
Stack = new RequestStack([$request]); $this->assertSame($request, $requestStack->getCurrentRequest()); } public function testGetCurrentRequest() { $requestStack = new RequestStack(); $this->as
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/RequestStackTest.php", "language": "php", "file_size": 2664, "cut_index": 563, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Gr...
(!self::$server = @proc_open('exec '.\PHP_BINARY.' -S localhost:8054', $spec, $pipes, __DIR__.'/Fixtures/response-functional')) { self::markTestSkipped('PHP server unable to start.'); } sleep(1); } public static functio
ce|false */ private static $server; public static function setUpBeforeClass(): void { $spec = [ 1 => ['file', '/dev/null', 'w'], 2 => ['file', '/dev/null', 'w'], ]; if
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php", "language": "php", "file_size": 2679, "cut_index": 563, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Session\Storage\Proxy; use Symfony\Component\HttpFoundation\Session\Storage\Handler\Stric...
SessionHandler && $handler->isWrapper()) ? \ini_get('session.save_handler') : 'user'; } public function getHandler(): \SessionHandlerInterface { return $this->handler; } // \SessionHandlerInterface public function open(st
ublic function __construct( protected \SessionHandlerInterface $handler, ) { $this->wrapper = $handler instanceof \SessionHandler; $this->saveHandlerName = $this->wrapper || ($handler instanceof Strict
{ "filepath": "src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php", "language": "php", "file_size": 2307, "cut_index": 563, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; use Symfony\Component\Cache\Marshaller...
return $this->handler->open($savePath, $name); } public function close(): bool { return $this->handler->close(); } public function destroy(#[\SensitiveParameter] string $sessionId): bool { return $this->handler-
erface { public function __construct( private AbstractSessionHandler $handler, private MarshallerInterface $marshaller, ) { } public function open(string $savePath, string $name): bool {
{ "filepath": "src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MarshallingSessionHandler.php", "language": "php", "file_size": 2016, "cut_index": 537, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; /** * Memcached based session storage handler based on the Memcached class * provided by the PHP memcached extens...
se for the memcached keys in order to avoid collision * * ttl: The time to live in seconds. * * @throws \InvalidArgumentException When unsupported options are passed */ public function __construct( private \Memcached $memca
/ private int|\Closure|null $ttl; /** * Key prefix for shared environments. */ private string $prefix; /** * Constructor. * * List of available options: * * prefix: The prefix to u
{ "filepath": "src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php", "language": "php", "file_size": 3237, "cut_index": 614, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; use MongoDB\BSON\Binary; use MongoDB\BSON\UTCDateTime; use MongoDB\Client; use MongoDB\Driver\BulkWrite; use MongoDB\Driver\Manager; use MongoDB\Driver\Query; /** * Session handler using the MongoDB driver extension...
ase: The name of the database [required] * * collection: The name of the collection [required] * * id_field: The field name for storing the session id [default: _id] * * data_field: The field name for storing the session data [default: da
ctSessionHandler { private Manager $manager; private string $namespace; private array $options; private int|\Closure|null $ttl; /** * Constructor. * * List of available options: * * datab
{ "filepath": "src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php", "language": "php", "file_size": 6096, "cut_index": 716, "middle_length": 229 }
atabase like BLOB in MySQL. * Saving it in a character column could corrupt the data. You can use createTable() * to initialize a correctly defined table. * * @see https://php.net/sessionhandlerinterface * * @author Fabien Potencier <fabien@symfony.com> * @author Michael Williams <michael.williams@funsational.co...
ch. */ public const LOCK_NONE = 0; /** * Creates an application-level lock on a session. The disadvantage is that the * lock is not enforced by the database and thus other, unaware parts of the * application could still concurr
ue to * race conditions of concurrent requests to the same session. The last session * write will win in this case. It might be useful when you implement your own * logic to deal with this like an optimistic approa
{ "filepath": "src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php", "language": "php", "file_size": 40634, "cut_index": 2151, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; use Doctrine\DBAL\Configuration; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Schema\DefaultSchemaManagerFact...
query'] ?? '', $query); if (($options['ttl'] ?? null) instanceof \Closure) { $query['ttl'] = $options['ttl']; } } $options = ($query ?: []) + $options; switch (true) { case $conn
public static function createHandler(object|string $connection, array $options = []): AbstractSessionHandler { if ($query = \is_string($connection) ? parse_url($connection) : false) { parse_str($query['
{ "filepath": "src/Symfony/Component/HttpFoundation/Session/Storage/Handler/SessionHandlerFactory.php", "language": "php", "file_size": 4351, "cut_index": 614, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\File; use Symfony\Component\HttpFoundation\File\Exception\FileException; use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundExc...
not a file */ public function __construct(string $path, bool $checkPath = true) { if ($checkPath && !is_file($path)) { throw new FileNotFoundException($path); } parent::__construct($path); } /**
tructs a new file from the given path. * * @param string $path The path to the file * @param bool $checkPath Whether to check the path or not * * @throws FileNotFoundException If the given path is
{ "filepath": "src/Symfony/Component/HttpFoundation/File/File.php", "language": "php", "file_size": 4566, "cut_index": 614, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\AcceptHeaderItem;...
turn [ [ 'text/html', 'text/html', [], ], [ '"this;should,not=matter"', 'this;should,not=matter', [], ], [ "text/pla
HeaderItem::fromString($string); $this->assertEquals($value, $item->getValue()); $this->assertEquals($attributes, $item->getAttributes()); } public static function provideFromStringData() { re
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/AcceptHeaderItemTest.php", "language": "php", "file_size": 3524, "cut_index": 614, "middle_length": 229 }
xception\ExtensionFileException; use Symfony\Component\HttpFoundation\File\Exception\FileException; use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; use Symfony\Component\HttpFoundation\File\Exception\FormSizeFileException; use Symfony\Component\HttpFoundation\File\Exception\IniSizeFileExcepti...
or Fabien Potencier <fabien@symfony.com> */ class UploadedFile extends File { private string $originalName; private string $mimeType; private int $error; private string $originalPath; /** * Accepts the information of the uploaded
ception\PartialFileException; use Symfony\Component\Mime\MimeTypes; /** * A file uploaded through a form. * * @author Bernhard Schussek <bschussek@gmail.com> * @author Florian Eckerstorfer <florian@eckerstorfer.org> * @auth
{ "filepath": "src/Symfony/Component/HttpFoundation/File/UploadedFile.php", "language": "php", "file_size": 10895, "cut_index": 921, "middle_length": 229 }
inaryFileResponse($file, 404, ['X-Header' => 'Foo'], true, null, true, true); $this->assertEquals(404, $response->getStatusCode()); $this->assertEquals('Foo', $response->headers->get('X-Header')); $this->assertTrue($response->headers->has('ETag')); $this->assertTrue($response->headers->h...
position')); } public function testConstructWithNonAsciiFilename() { touch(sys_get_temp_dir().'/fööö.html'); $response = new BinaryFileResponse(sys_get_temp_dir().'/fööö.html', 200, [], true, 'attachment'); @unlink(sy
ON_INLINE); $this->assertEquals(404, $response->getStatusCode()); $this->assertFalse($response->headers->has('ETag')); $this->assertEquals('inline; filename=README.md', $response->headers->get('Content-Dis
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php", "language": "php", "file_size": 18495, "cut_index": 1331, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpFoundation\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Exception\BadRequestException; use Symfony\Component\HttpFoundation\InputBag; use Symfony\Component\HttpFoundation\Tests\Fixtures\FooEnum; class InputBagTest extends...
eter'); $this->assertSame('default', $bag->get('unknown', 'default'), '->get() returns second argument as default if a parameter is not defined'); $this->assertNull($bag->get('null', 'default'), '->get() returns null if null is set');
Stringable { public function __toString(): string { return 'strval'; } }]); $this->assertSame('bar', $bag->get('foo'), '->get() gets the value of a string param
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/InputBagTest.php", "language": "php", "file_size": 8423, "cut_index": 716, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\RedirectRespo...
Exception(\InvalidArgumentException::class); $this->expectExceptionMessage('Cannot redirect to an empty URL.'); new RedirectResponse(''); } public function testRedirectResponseConstructorWrongStatusCode() { $this->expec
arExpression('#<meta http-equiv="refresh" content="\d+;url=\'foo\.bar\'" />#', preg_replace('/\s+/', ' ', $response->getContent())); } public function testRedirectResponseConstructorEmptyUrl() { $this->expect
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php", "language": "php", "file_size": 2886, "cut_index": 563, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class RequestFunctionalTest extends TestCase { /*...
le to start.'); } sleep(1); } public static function tearDownAfterClass(): void { if (self::$server) { proc_terminate(self::$server); proc_close(self::$server); } } public static
['file', '/dev/null', 'w'], ]; if (!self::$server = @proc_open('exec '.\PHP_BINARY.' -S localhost:8054', $spec, $pipes, __DIR__.'/Fixtures/request-functional')) { self::markTestSkipped('PHP server unab
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/RequestFunctionalTest.php", "language": "php", "file_size": 3051, "cut_index": 614, "middle_length": 229 }
he Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; use Symfony\Component\Cache\Marshaller\Marshalle...
=> $value) { if (!\is_string($value)) { throw new \LogicException(\sprintf('%s accepts only string as data.', __METHOD__)); } } return $values; } public function unmarshall(string $value):
ailed): array { foreach ($values as $key
{ "filepath": "src/Symfony/Component/HttpFoundation/Session/Storage/Handler/IdentityMarshaller.php", "language": "php", "file_size": 899, "cut_index": 547, "middle_length": 52 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; /** * Native session handler using PH...
figuration#ini.session.save-path for further details. * * @throws \InvalidArgumentException On invalid $savePath * @throws \RuntimeException When failing to create the save directory */ public function __construct(?string $s
ve session files * Default null will leave setting as defined by PHP. * '/path', 'N;/path', or 'N;octal-mode;/path * * @see https://php.net/session.con
{ "filepath": "src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php", "language": "php", "file_size": 1928, "cut_index": 537, "middle_length": 229 }
This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; /** * Can be used in uni...
): string { return ''; } public function updateTimestamp(#[\SensitiveParameter] string $sessionId, string $data): bool { return true; } protected function doWrite(#[\SensitiveParameter] string $sessionId, string $d
ose(): bool { return true; } public function validateId(#[\SensitiveParameter] string $sessionId): bool { return true; } protected function doRead(#[\SensitiveParameter] string $sessionId
{ "filepath": "src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php", "language": "php", "file_size": 1253, "cut_index": 524, "middle_length": 229 }
["\rMyName"], ["\nMyName"], ["\013MyName"], ["\014MyName"], ]; } #[DataProvider('namesWithSpecialCharacters')] public function testInstantiationThrowsExceptionIfRawCookieNameContainsSpecialCharacters($name) { $this->expectException(\InvalidArgument...
unction testInstantiationSucceedNonRawCookieNameContainsSpecialCharacters($name) { $this->assertInstanceOf(Cookie::class, Cookie::create($name)); } public function testInstantiationThrowsExceptionIfCookieNameIsEmpty() { $th
nIfCookieNameContainsSpecialCharacters($name) { $this->expectException(\InvalidArgumentException::class); Cookie::create($name)->withRaw(); } #[DataProvider('namesWithSpecialCharacters')] public f
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/CookieTest.php", "language": "php", "file_size": 17677, "cut_index": 1331, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpFoundation\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\JsonResponse; class JsonResponseTest extends TestCase { public function testConstructorEmptyCreatesJsonObject() { $response = new JsonResponse(); ...
bar"}', $response->getContent()); } public function testConstructorWithSimpleTypes() { $response = new JsonResponse('foo'); $this->assertSame('"foo"', $response->getContent()); $response = new JsonResponse(0);
this->assertSame('[0,1,2,3]', $response->getContent()); } public function testConstructorWithAssocArrayCreatesJsonObject() { $response = new JsonResponse(['foo' => 'bar']); $this->assertSame('{"foo":"
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php", "language": "php", "file_size": 6560, "cut_index": 716, "middle_length": 229 }
$this->assertFalse($isNoCache); } public function testGetContentTypeFormat() { $request = new Request(); $this->assertNull($request->getContentTypeFormat()); $server = ['HTTP_CONTENT_TYPE' => 'application/json']; $request = new Request([], [], [], [], [], $server); ...
ale(); $this->assertEquals('pl', $locale); } public function testCreate() { $request = Request::create('http://test.com/foo?bar=baz'); $this->assertEquals('http://test.com/foo?bar=baz', $request->getUri()); $th
$this->assertEquals('html', $request->getContentTypeFormat()); } public function testSetDefaultLocale() { $request = new Request(); $request->setDefaultLocale('pl'); $locale = $request->getLoc
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/RequestTest.php", "language": "php", "file_size": 127382, "cut_index": 3790, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; use Symfony\Component\HttpFoundation\Session\SessionUtils; /** * This abstract session handler provides a generic...
null; private string $igbinaryEmptyData; public function open(string $savePath, string $sessionName): bool { $this->sessionName = $sessionName; if (!headers_sent() && !\ini_get('session.cache_limiter') && '0' !== \ini_get('sess
SessionHandler implements \SessionHandlerInterface, \SessionUpdateTimestampHandlerInterface { private string $sessionName; private string $prefetchId; private string $prefetchData; private ?string $newSessionId =
{ "filepath": "src/Symfony/Component/HttpFoundation/Session/Storage/Handler/AbstractSessionHandler.php", "language": "php", "file_size": 4460, "cut_index": 614, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; /** * Adds basic `SessionUpdateTimestampHandlerInterface` behav...
nce of "SessionUpdateTimestampHandlerInterface", you cannot wrap it with "%s".', get_debug_type($handler), self::class)); } } /** * Returns true if this handler wraps an internal PHP session save handler using \SessionHandler. *
function __construct( private \SessionHandlerInterface $handler, ) { if ($handler instanceof \SessionUpdateTimestampHandlerInterface) { throw new \LogicException(\sprintf('"%s" is already an insta
{ "filepath": "src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php", "language": "php", "file_size": 2472, "cut_index": 563, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpFoundation\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\FileBag; /** * FileBagTest. * * @author Fabien Potencier <fabien@symfony.com> * @author Bulat Shakirzyano...
File, $name, 'text/plain'); $bag = new FileBag(['file' => [ 'name' => $name, 'type' => 'text/plain', 'tmp_name' => $tmpFile, 'error' => 0, 'size' => null, ]]); $this->ass
s); new FileBag(['file' => 'foo']); } public function testShouldConvertsUploadedFiles() { $tmpFile = $this->createTempFile(); $name = basename($tmpFile); $file = new UploadedFile($tmp
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php", "language": "php", "file_size": 6307, "cut_index": 716, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; use Predis\Response\ErrorInterface; use Relay\Relay; /** * Red...
options: * * prefix: The prefix to use for the keys in order to avoid collision on the Redis server * * ttl: The time to live in seconds. * * @throws \InvalidArgumentException When unsupported client or options are passed */
stractSessionHandler { /** * Key prefix for shared environments. */ private string $prefix; /** * Time to live in seconds. */ private int|\Closure|null $ttl; /** * List of available
{ "filepath": "src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php", "language": "php", "file_size": 2996, "cut_index": 563, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; /** * Migrating session handler for migrating from one handler to another. It reads * from the current handler an...
erInterface&\SessionUpdateTimestampHandlerInterface $writeOnlyHandler; public function __construct(\SessionHandlerInterface $currentHandler, \SessionHandlerInterface $writeOnlyHandler) { if (!$currentHandler instanceof \SessionUpdateTimest
class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdateTimestampHandlerInterface { private \SessionHandlerInterface&\SessionUpdateTimestampHandlerInterface $currentHandler; private \SessionHandl
{ "filepath": "src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php", "language": "php", "file_size": 3314, "cut_index": 614, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\StreamedResponse; ...
$chunks = ['foo', 'bar', 'baz']; $callback = (new StreamedResponse($chunks))->getCallback(); $buffer = ''; ob_start(static function (string $chunk) use (&$buffer) { return $buffer .= $chunk; }); $call
'text/plain']); $this->assertEquals(404, $response->getStatusCode()); $this->assertEquals('text/plain', $response->headers->get('Content-Type')); } public function testConstructorWithChunks() {
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php", "language": "php", "file_size": 5040, "cut_index": 614, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\PreserveGlobalState; use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; use PHPUnit\Framework\TestCase; use Symfony\Compon...
ublic function testOpenTrue() { $handler = $this->createMock(\SessionHandlerInterface::class); $proxy = new SessionHandlerProxy($handler); $handler->expects($this->once()) ->method('open') ->willReturn(tr
\Proxy\SessionHandlerProxy; /** * Tests for SessionHandlerProxy class. * * @author Drak <drak@zikula.org> */ #[PreserveGlobalState(false)] #[RunTestsInSeparateProcesses] class SessionHandlerProxyTest extends TestCase { p
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php", "language": "php", "file_size": 6196, "cut_index": 716, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Relay\Relay; use Symfony\Component\HttpFoundation\Session\Storage\Handler\RedisSessionHa...
p(): void { if (!\extension_loaded('redis')) { self::markTestSkipped('Extension redis required.'); } try { (new \Redis())->connect(...explode(':', getenv('REDIS_HOST'))); } catch (\Exception $e) {
protected \Redis|Relay|\RedisArray|\RedisCluster|\Predis\Client $redisClient; abstract protected function createRedisClient(string $host): \Redis|Relay|\RedisArray|\RedisCluster|\Predis\Client; protected function setU
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php", "language": "php", "file_size": 5153, "cut_index": 716, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; use PHPUnit\Framework\Attributes...
pec, $pipes, __DIR__.'/Fixtures')) { self::markTestSkipped('PHP server unable to start.'); } sleep(1); } public static function tearDownAfterClass(): void { if (self::$server) { proc_terminate(se
BeforeClass(): void { $spec = [ 1 => ['file', '/dev/null', 'w'], 2 => ['file', '/dev/null', 'w'], ]; if (!self::$server = @proc_open('exec '.\PHP_BINARY.' -S localhost:8053', $s
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php", "language": "php", "file_size": 1978, "cut_index": 537, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; use PHPUnit\Framework\Attributes...
tSame($values, $marshaller->marshall($values, $failed)); } #[DataProvider('invalidMarshallDataProvider')] public function testMarshallInvalidData($values) { $marshaller = new IdentityMarshaller(); $failed = []; $th
*/ class IdentityMarshallerTest extends TestCase { public function testMarshall() { $marshaller = new IdentityMarshaller(); $values = ['data' => 'string_data']; $failed = []; $this->asser
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/IdentityMarshallerTest.php", "language": "php", "file_size": 1637, "cut_index": 537, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Cache\Mars...
{ $this->handler = $this->createMock(AbstractSessionHandler::class); } public function testOpen() { $marshallingSessionHandler = new MarshallingSessionHandler($this->handler, $this->createStub(MarshallerInterface::class));
Handler; /** * @author Ahmed TAILOULOUTE <ahmed.tailouloute@gmail.com> */ class MarshallingSessionHandlerTest extends TestCase { protected MockObject&\SessionHandlerInterface $handler; protected function setUp(): void
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MarshallingSessionHandlerTest.php", "language": "php", "file_size": 4212, "cut_index": 614, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\Te...
('memcached'), '3.0.0b1', '<')) { $this->markTestSkipped('Tests can only be run with memcached extension 2.1.0 or lower, or 3.0.0b1 or higher'); } } public function testOpenSession() { $this->assertTrue($this->getSe
extends TestCase { private const PREFIX = 'prefix_'; private const TTL = 1000; protected function setUp(): void { if (version_compare(phpversion('memcached'), '2.2.0', '>=') && version_compare(phpversion
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php", "language": "php", "file_size": 5185, "cut_index": 716, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Session\Storage\Handler\MigratingSessionHandler; class MigratingSessionHandlerTest extends TestCase { public function testInstanceOf() ...
ock(\SessionHandlerInterface::class); $currentHandler->expects($this->once()) ->method('close') ->willReturn(true); $writeOnlyHandler = $this->createMock(\SessionHandlerInterface::class); $writeOnlyHandler->
(\SessionHandlerInterface::class, $dualHandler); $this->assertInstanceOf(\SessionUpdateTimestampHandlerInterface::class, $dualHandler); } public function testClose() { $currentHandler = $this->createM
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MigratingSessionHandlerTest.php", "language": "php", "file_size": 6556, "cut_index": 716, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; use MongoDB\BSON\Binary; use MongoDB\BSON\UTCDateTime; use MongoDB\Client; use MongoDB\Driver\BulkWrite; use MongoDB\Driver\Command; use MongoDB\Driver\Exception\CommandException; use MongoDB\Driver\Exception\Co...
nn@bachi.biz> */ #[RequiresPhpExtension('mongodb')] #[Group('integration')] #[Group('time-sensitive')] class MongoDbSessionHandlerTest extends TestCase { private const DABASE_NAME = 'sf-test'; private const COLLECTION_NAME = 'session-test'; p
\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler; require_once __DIR__.'/stubs/mongodb.php'; /** * @author Markus Bachmann <markus.bachma
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php", "language": "php", "file_size": 7027, "cut_index": 716, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit...
RunTestsInSeparateProcesses] class NativeFileSessionHandlerTest extends TestCase { public function testConstruct() { new NativeSessionStorage(['name' => 'TESTING'], new NativeFileSessionHandler(sys_get_temp_dir())); $this->assertEq
ndler\NativeFileSessionHandler; use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; /** * Test class for NativeFileSessionHandler. * * @author Drak <drak@zikula.org> */ #[PreserveGlobalState(false)] #[
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php", "language": "php", "file_size": 2360, "cut_index": 563, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; use PHPUnit\Framework\Attributes...
lobalState(false)] #[RunTestsInSeparateProcesses] class NullSessionHandlerTest extends TestCase { public function testSaveHandlers() { $this->getStorage(); $this->assertEquals('user', \ini_get('session.save_handler')); } pu
HttpFoundation\Session\Storage\Handler\NullSessionHandler; use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; /** * Test class for NullSessionHandler. * * @author Drak <drak@zikula.org> */ #[PreserveG
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php", "language": "php", "file_size": 1807, "cut_index": 537, "middle_length": 229 }
function tearDown(): void { // make sure the temporary database file is deleted when it has been created (even when a test fails) if ($this->dbFile) { @unlink($this->dbFile); } } protected function getPersistentSqliteDsn() { $this->dbFile = tempnam(sys_get_te...
expectException(\InvalidArgumentException::class); $pdo = $this->getMemorySqlitePdo(); $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT); new PdoSessionHandler($pdo); } public function testInexistentTable()
Attribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); $storage = new PdoSessionHandler($pdo); $storage->createTable(); return $pdo; } public function testWrongPdoErrMode() { $this->
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php", "language": "php", "file_size": 17844, "cut_index": 1331, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; use PHPUnit\Framework\Attributes...
explode(':', getenv('REDIS_HOST')) + [1 => 6379])); } public function testNoDuplicatePrefixWhenUsingDsn() { $host = getenv('REDIS_HOST') ?: 'localhost'; $dsn = 'redis://'.$host.'?prefix=my_session_prefix_&class='.urlencode(Cli
#[Group('integration')] class PredisSessionHandlerTest extends AbstractRedisSessionHandlerTestCase { protected function createRedisClient(string $host): Client { return new Client(array_combine(['host', 'port'],
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PredisSessionHandlerTest.php", "language": "php", "file_size": 1602, "cut_index": 537, "middle_length": 229 }
n Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; use PHPUnit\Framework\Attributes\Group; #[Group('integration')] class RedisC...
uired.'); } if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) { self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.'); } } protected function createRedisClient(string $host): \RedisCluster {
self::markTestSkipped('The RedisCluster class is req
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/RedisClusterSessionHandlerTest.php", "language": "php", "file_size": 978, "cut_index": 582, "middle_length": 52 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\PreserveGlobalState; use PHPU...
andlerFactory. * * @author Simon <simon.chrzanowski@quentic.com> */ #[PreserveGlobalState(false)] #[RunTestsInSeparateProcesses] class SessionHandlerFactoryTest extends TestCase { #[DataProvider('provideConnectionDSN')] public function testCreat
e\Handler\RedisSessionHandler; use Symfony\Component\HttpFoundation\Session\Storage\Handler\SessionHandlerFactory; use Symfony\Component\HttpFoundation\Session\Storage\Handler\StrictSessionHandler; /** * Test class for SessionH
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/SessionHandlerFactoryTest.php", "language": "php", "file_size": 3088, "cut_index": 614, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Session\Storage\Handler\AbstractSessionHandler; use Symfony\Component\HttpFoundation\Session\Storage\Handler\StrictSessionHandler; class Stri...
rtInstanceOf(AbstractSessionHandler::class, $proxy); $this->assertTrue($proxy->open('path', 'name')); } public function testCloseSession() { $handler = $this->createMock(\SessionHandlerInterface::class); $handler->expec
thod('open') ->with('path', 'name')->willReturn(true); $proxy = new StrictSessionHandler($handler); $this->assertInstanceOf(\SessionUpdateTimestampHandlerInterface::class, $proxy); $this->asse
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/StrictSessionHandlerTest.php", "language": "php", "file_size": 7250, "cut_index": 716, "middle_length": 229 }
ackage. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\File; use Symfony\Component\HttpFoundation\File\File as OrigFile; class FakeFi...
bool { return true; } public function getRealpath(): string { return $this->realpath; } public function getSize(): int { return 42; } public function getMTime(): int { return time()
h, false); } public function isReadable():
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/File/FakeFile.php", "language": "php", "file_size": 877, "cut_index": 559, "middle_length": 52 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\File; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\Test...
xtensionWithoutGuesser() { $file = new File(__DIR__.'/Fixtures/directory/.empty'); $this->assertNull($file->guessExtension()); } public function testGuessExtensionIsBasedOnMimeType() { $file = new File(__DIR__.'/Fix
tCase { public function testGetMimeTypeUsesMimeTypeGuessers() { $file = new File(__DIR__.'/Fixtures/test.gif'); $this->assertEquals('image/gif', $file->getMimeType()); } public function testGuessE
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php", "language": "php", "file_size": 4679, "cut_index": 614, "middle_length": 229 }
\File\Exception\CannotWriteFileException; use Symfony\Component\HttpFoundation\File\Exception\ExtensionFileException; use Symfony\Component\HttpFoundation\File\Exception\FileException; use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; use Symfony\Component\HttpFoundation\File\Exception\FormSize...
unction setUp(): void { if (!\ini_get('file_uploads')) { $this->markTestSkipped('file_uploads is disabled in php.ini'); } } public function testConstructWhenFileNotExists() { $this->expectException(FileN
on\File\Exception\NoTmpDirFileException; use Symfony\Component\HttpFoundation\File\Exception\PartialFileException; use Symfony\Component\HttpFoundation\File\UploadedFile; class UploadedFileTest extends TestCase { protected f
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php", "language": "php", "file_size": 10377, "cut_index": 921, "middle_length": 229 }
/* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Test\Constraint; use PHPUnit\Framework...
'foo', 'bar'); $this->assertTrue($constraint->evaluate($request, '', true)); $constraint = new RequestAttributeValueSame('bar', 'foo'); $this->assertFalse($constraint->evaluate($request, '', true)); $this->expectException(E
s RequestAttributeValueSameTest extends TestCase { public function testConstraint() { $request = new Request(); $request->attributes->set('foo', 'bar'); $constraint = new RequestAttributeValueSame(
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Test/Constraint/RequestAttributeValueSameTest.php", "language": "php", "file_size": 1202, "cut_index": 518, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Test\Constraint; use PHPUnit\Framework\ExpectationFailedE...
')); $constraint = new ResponseCookieValueSame('foo', 'bar', '/path'); $this->assertTrue($constraint->evaluate($response, '', true)); $constraint = new ResponseCookieValueSame('foo', 'bar', '/path'); $this->assertTrue($const
nseCookieValueSame; class ResponseCookieValueSameTest extends TestCase { public function testConstraint() { $response = new Response(); $response->headers->setCookie(Cookie::create('foo', 'bar', 0, '/path
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Test/Constraint/ResponseCookieValueSameTest.php", "language": "php", "file_size": 1768, "cut_index": 537, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Test\Constraint; use PHPUnit\Framework\ExpectationFailedException; use PHPUnit\Fram...
mat']); $constraint = new ResponseFormatSame($request, 'custom'); $this->assertTrue($constraint->evaluate(new Response('', 200, ['Content-Type' => 'application/vnd.myformat']), '', true)); $this->assertFalse($constraint->evaluate(n
uthor Kévin Dunglas <kevin@dunglas.fr> */ class ResponseFormatSameTest extends TestCase { public function testConstraint() { $request = new Request(); $request->setFormat('custom', ['application/vnd.myfor
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Test/Constraint/ResponseFormatSameTest.php", "language": "php", "file_size": 2260, "cut_index": 563, "middle_length": 229 }
/* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Test\Constraint; use PHPUnit\Framework...
$constraint = new ResponseHasCookie('foo'); $this->assertTrue($constraint->evaluate($response, '', true)); $constraint = new ResponseHasCookie('bar'); $this->assertFalse($constraint->evaluate($response, '', true));
st\Constraint\ResponseHasCookie; class ResponseHasCookieTest extends TestCase { public function testConstraint() { $response = new Response(); $response->headers->setCookie(Cookie::create('foo', 'bar'));
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Test/Constraint/ResponseHasCookieTest.php", "language": "php", "file_size": 1208, "cut_index": 518, "middle_length": 229 }
hp /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Test\Constraint; use PHPUnit\Framew...
t = new ResponseHasHeader('X-Date'); $this->assertFalse($constraint->evaluate(new Response(), '', true)); $this->expectException(ExpectationFailedException::class); $this->expectExceptionMessage('Failed asserting that the Response
sponseHasHeaderTest extends TestCase { public function testConstraint() { $constraint = new ResponseHasHeader('Date'); $this->assertTrue($constraint->evaluate(new Response(), '', true)); $constrain
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Test/Constraint/ResponseHasHeaderTest.php", "language": "php", "file_size": 1080, "cut_index": 515, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Test\Constraint; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\ExpectationFailedException; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Respons...
$response->headers->set('Location', $location); } $constraint = new ResponseHeaderLocationSame($request, $expectedLocation); self::assertTrue($constraint->evaluate($response, '', true)); } public static function p
ic function testConstraintSuccess(string $requestUrl, ?string $location, string $expectedLocation) { $request = Request::create($requestUrl); $response = new Response(); if (null !== $location) {
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Test/Constraint/ResponseHeaderLocationSameTest.php", "language": "php", "file_size": 6480, "cut_index": 716, "middle_length": 229 }
/* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Test\Constraint; use PHPUnit\Framework...
'', true)); $constraint = new ResponseHeaderSame('Cache-Control', 'public'); $this->assertFalse($constraint->evaluate(new Response(), '', true)); $this->expectException(ExpectationFailedException::class); $this->expectExcep
onseHeaderSameTest extends TestCase { public function testConstraint() { $constraint = new ResponseHeaderSame('Cache-Control', 'no-cache, private'); $this->assertTrue($constraint->evaluate(new Response(),
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Test/Constraint/ResponseHeaderSameTest.php", "language": "php", "file_size": 1158, "cut_index": 518, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Test\Constraint; use PHPUnit\Framework\ExpectationFailedE...
onstraint->evaluate(new Response(), '', true)); $this->expectException(ExpectationFailedException::class); $this->expectExceptionMessageMatches('/Failed asserting that the Response is redirected.\nHTTP\/1.0 200 OK.+Body content/s');
est extends TestCase { public function testConstraint() { $constraint = new ResponseIsRedirected(); $this->assertTrue($constraint->evaluate(new Response('', 301), '', true)); $this->assertFalse($c
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Test/Constraint/ResponseIsRedirectedTest.php", "language": "php", "file_size": 1600, "cut_index": 537, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Test\Constraint; use PHPUnit\Framework\ExpectationFailedE...
nt->evaluate(new Response('', 404), '', true)); $this->expectException(ExpectationFailedException::class); $this->expectExceptionMessageMatches('/Failed asserting that the Response is successful.\nHTTP\/1.0 404 Not Found.+Response body/s')
est extends TestCase { public function testConstraint() { $constraint = new ResponseIsSuccessful(); $this->assertTrue($constraint->evaluate(new Response(), '', true)); $this->assertFalse($constrai
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Test/Constraint/ResponseIsSuccessfulTest.php", "language": "php", "file_size": 1629, "cut_index": 537, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Test\Constraint; use PHPUnit\Framework\ExpectationFailedE...
tFalse($constraint->evaluate(new Response(), '', true)); $this->expectException(ExpectationFailedException::class); $this->expectExceptionMessageMatches('/Failed asserting that the Response is unprocessable.\nHTTP\/1.0 200 OK.+Response bod
sableTest extends TestCase { public function testConstraint() { $constraint = new ResponseIsUnprocessable(); $this->assertTrue($constraint->evaluate(new Response('', 422), '', true)); $this->asser
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Test/Constraint/ResponseIsUnprocessableTest.php", "language": "php", "file_size": 1623, "cut_index": 537, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Test\Constraint; use PHPUnit\Framework\ExpectationFailedE...
constraint->evaluate(new Response('', 404), '', true)); $constraint = new ResponseStatusCodeSame(404); $this->assertTrue($constraint->evaluate(new Response('', 404), '', true)); $constraint = new ResponseStatusCodeSame(200);
ameTest extends TestCase { public function testConstraint() { $constraint = new ResponseStatusCodeSame(200); $this->assertTrue($constraint->evaluate(new Response(), '', true)); $this->assertFalse($
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Test/Constraint/ResponseStatusCodeSameTest.php", "language": "php", "file_size": 1857, "cut_index": 537, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Test\Constraint; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\ExpectationFailedException; use PHPUnit\Framewor...
public function testSuccessfulCase(string|array $flashMessages) { $request = new Request(); $session = new Session(new MockArraySessionStorage()); $request->setSession($session); $session->getFlashBag()->set('foo',
nent\HttpFoundation\Session\Storage\MockArraySessionStorage; use Symfony\Component\HttpFoundation\Test\Constraint\SessionHasFlashMessage; class SessionHasFlashMessageTest extends TestCase { #[DataProvider('provideMessages')]
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Test/Constraint/SessionHasFlashMessageTest.php", "language": "php", "file_size": 3405, "cut_index": 614, "middle_length": 229 }
?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Test\Constraint; use PHPUnit\Framework\...
*/ protected function matches($request): bool { return $this->value === $request->attributes->get($this->name); } /** * @param Request $request */ protected function failureDescription($request): string {
private string $value, ) { } public function toString(): string { return \sprintf('has attribute "%s" with value "%s"', $this->name, $this->value); } /** * @param Request $request
{ "filepath": "src/Symfony/Component/HttpFoundation/Test/Constraint/RequestAttributeValueSame.php", "language": "php", "file_size": 1050, "cut_index": 513, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Test\Constraint; use PHPUnit\Framework\Constraint\Constraint; u...
$this->name); if ('/' !== $this->path) { $str .= \sprintf(' with path "%s"', $this->path); } if ($this->domain) { $str .= \sprintf(' for domain "%s"', $this->domain); } return $str.\sprintf(
ivate string $name, private string $value, private string $path = '/', private ?string $domain = null, ) { } public function toString(): string { $str = \sprintf('has cookie "%s"',
{ "filepath": "src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseCookieValueSame.php", "language": "php", "file_size": 1886, "cut_index": 537, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpFoundation\Tests; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\UrlHelper; use Symfony...
$expected, $helper->getAbsoluteUrl($path)); } public static function getGenerateAbsoluteUrlData() { return [ ['http://localhost/foo.png', '/foo.png', '/foo/bar.html'], ['http://localhost/foo/foo.png', 'foo.png',
lic function testGenerateAbsoluteUrl($expected, $path, $pathinfo) { $stack = new RequestStack(); $stack->push(Request::create($pathinfo)); $helper = new UrlHelper($stack); $this->assertEquals(
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/UrlHelperTest.php", "language": "php", "file_size": 6722, "cut_index": 716, "middle_length": 229 }
* This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\RateLimiter; use Symfony\Component\HttpFoun...
terInterface[] */ private array $limiters; public function __construct(array $limiters) { $this->limiters = $limiters; } protected function getLimiters(Request $request): array { return $this->limiters; }
bstractRequestRateLimiter { /** * @var Limi
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/RateLimiter/MockAbstractRequestRateLimiter.php", "language": "php", "file_size": 833, "cut_index": 523, "middle_length": 52 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\RequestMatcher; use PHPUnit\Framework\Attributes\DataProv...
= Request::create('/foo'); $expressionRequestMatcher = new ExpressionRequestMatcher(new ExpressionLanguage(), $expression); $this->assertSame($expected, $expressionRequestMatcher->matches($request)); } public static function provi
cher\ExpressionRequestMatcher; class ExpressionRequestMatcherTest extends TestCase { #[DataProvider('provideExpressions')] public function testMatchesWhenParentMatchesIsTrue($expression, $expected) { $request
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/RequestMatcher/ExpressionRequestMatcherTest.php", "language": "php", "file_size": 1781, "cut_index": 537, "middle_length": 229 }
This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\RequestMatcher; use PHPUnit\Framework\Attrib...
T' => 'foo.example.com']); $this->assertSame($isMatch, $matcher->matches($request)); } public static function getData() { return [ ['.*\.example\.com', true], ['\.example\.com$', true], ['^.*
erTest extends TestCase { #[DataProvider('getData')] public function test($pattern, $isMatch) { $matcher = new HostRequestMatcher($pattern); $request = Request::create('', 'get', [], [], [], ['HTTP_HOS
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/RequestMatcher/HostRequestMatcherTest.php", "language": "php", "file_size": 1254, "cut_index": 524, "middle_length": 229 }
?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\RequestMatcher; use PHPUnit\Frame...
[], $json); $this->assertSame($isValid, $matcher->matches($request)); } public static function getData() { return [ ['not json', false], ['"json_string"', true], ['11', true], ['
sonRequestMatcherTest extends TestCase { #[DataProvider('getData')] public function test($json, bool $isValid) { $matcher = new IsJsonRequestMatcher(); $request = Request::create('', 'GET', [], [], [],
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/RequestMatcher/IsJsonRequestMatcherTest.php", "language": "php", "file_size": 1044, "cut_index": 513, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\RequestMatcher; use PHPUnit\Framework\Attributes\DataProv...
tSame($expected, $matcher->matches($request)); } public static function getData() { return [ ['/admin/.*', true], ['/admin', true], ['^/admin/.*$', true], ['/blog/.*', false], ];
s TestCase { #[DataProvider('getData')] public function test(string $regexp, bool $expected) { $matcher = new PathRequestMatcher($regexp); $request = Request::create('/admin/foo'); $this->asser
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/RequestMatcher/PathRequestMatcherTest.php", "language": "php", "file_size": 1531, "cut_index": 537, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\RequestMatcher; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framewor...
$this->assertSame($matches, $matcher->matches($request)); } #[DataProvider('getDataForArray')] public function testCommaSeparatedString(string $uri, bool $matches) { $matcher = new QueryParameterRequestMatcher('foo, bar');
Case { #[DataProvider('getDataForArray')] public function testArray(string $uri, bool $matches) { $matcher = new QueryParameterRequestMatcher(['foo', 'bar']); $request = Request::create($uri);
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/RequestMatcher/QueryParameterRequestMatcherTest.php", "language": "php", "file_size": 2151, "cut_index": 563, "middle_length": 229 }
hp use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; $parent = __DIR__; while (!@file_exists($parent.'/vendor/autoload.php')) { if (!@file_exists($parent)) { // open_basedir restriction in effect ...
$r = new JsonResponse([ 'request' => $request->request->all(), 'files' => array_map( static fn (UploadedFile $file) => [ 'clientOriginalName' => $file->getClientOriginalName(), 'clientMimeType' => $file->getClientM
ad.php'; error_reporting(-1); ini_set('html_errors', 0); ini_set('display_errors', 1); if (filter_var(ini_get('xdebug.default_enable'), \FILTER_VALIDATE_BOOL)) { xdebug_disable(); } $request = Request::createFromGlobals();
{ "filepath": "src/Symfony/Component/HttpFoundation/Tests/Fixtures/request-functional/index.php", "language": "php", "file_size": 1123, "cut_index": 515, "middle_length": 229 }