OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
firebase
/
vendor
/
guzzlehttp
/
psr7
/
tests
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
08/12/2024 10:34:10 AM
rwxr-xr-x
📄
AppendStreamTest.php
6.91 KB
08/12/2024 10:33:22 AM
rw-r--r--
📄
BufferStreamTest.php
1.98 KB
08/12/2024 10:33:22 AM
rw-r--r--
📄
CachingStreamTest.php
6.62 KB
08/12/2024 10:33:22 AM
rw-r--r--
📄
DroppingStreamTest.php
964 bytes
08/12/2024 10:33:22 AM
rw-r--r--
📄
FnStreamTest.php
3.75 KB
08/12/2024 10:33:22 AM
rw-r--r--
📄
HasToString.php
177 bytes
08/12/2024 10:33:22 AM
rw-r--r--
📄
HeaderTest.php
6.14 KB
08/12/2024 10:33:22 AM
rw-r--r--
📄
InflateStreamTest.php
3.06 KB
08/12/2024 10:33:22 AM
rw-r--r--
📁
Integration
-
08/12/2024 10:34:10 AM
rwxr-xr-x
📄
LazyOpenStreamTest.php
1.88 KB
08/12/2024 10:33:22 AM
rw-r--r--
📄
LimitStreamTest.php
4.94 KB
08/12/2024 10:33:22 AM
rw-r--r--
📄
MessageTest.php
12.73 KB
08/12/2024 10:33:22 AM
rw-r--r--
📄
MimeTypeTest.php
617 bytes
08/12/2024 10:33:22 AM
rw-r--r--
📄
MultipartStreamTest.php
9.67 KB
08/12/2024 10:33:22 AM
rw-r--r--
📄
NoSeekStreamTest.php
1.05 KB
08/12/2024 10:33:22 AM
rw-r--r--
📄
PumpStreamTest.php
3.13 KB
08/12/2024 10:33:22 AM
rw-r--r--
📄
QueryTest.php
4.29 KB
08/12/2024 10:33:22 AM
rw-r--r--
📄
ReadSeekOnlyStream.php
460 bytes
08/12/2024 10:33:22 AM
rw-r--r--
📄
RequestTest.php
10.78 KB
08/12/2024 10:33:22 AM
rw-r--r--
📄
ResponseTest.php
13.89 KB
08/12/2024 10:33:23 AM
rw-r--r--
📄
ServerRequestTest.php
20.07 KB
08/12/2024 10:33:23 AM
rw-r--r--
📄
StreamDecoratorTraitTest.php
3.81 KB
08/12/2024 10:33:23 AM
rw-r--r--
📄
StreamTest.php
12.89 KB
08/12/2024 10:33:23 AM
rw-r--r--
📄
StreamWrapperTest.php
5.9 KB
08/12/2024 10:33:23 AM
rw-r--r--
📄
UploadedFileTest.php
6.63 KB
08/12/2024 10:33:23 AM
rw-r--r--
📄
UriComparatorTest.php
1.81 KB
08/12/2024 10:33:23 AM
rw-r--r--
📄
UriNormalizerTest.php
7.06 KB
08/12/2024 10:33:23 AM
rw-r--r--
📄
UriResolverTest.php
10.89 KB
08/12/2024 10:33:23 AM
rw-r--r--
📄
UriTest.php
27.18 KB
08/12/2024 10:33:23 AM
rw-r--r--
📄
UtilsTest.php
18.31 KB
08/12/2024 10:33:23 AM
rw-r--r--
Editing: MultipartStreamTest.php
Close
<?php declare(strict_types=1); namespace GuzzleHttp\Tests\Psr7; use GuzzleHttp\Psr7; use GuzzleHttp\Psr7\MultipartStream; use PHPUnit\Framework\TestCase; class MultipartStreamTest extends TestCase { public function testCreatesDefaultBoundary(): void { $b = new MultipartStream(); self::assertNotEmpty($b->getBoundary()); } public function testCanProvideBoundary(): void { $b = new MultipartStream([], 'foo'); self::assertSame('foo', $b->getBoundary()); } public function testIsNotWritable(): void { $b = new MultipartStream(); self::assertFalse($b->isWritable()); } public function testCanCreateEmptyStream(): void { $b = new MultipartStream(); $boundary = $b->getBoundary(); self::assertSame("--{$boundary}--\r\n", $b->getContents()); self::assertSame(strlen($boundary) + 6, $b->getSize()); } public function testValidatesFilesArrayElement(): void { $this->expectException(\InvalidArgumentException::class); new MultipartStream([['foo' => 'bar']]); } public function testEnsuresFileHasName(): void { $this->expectException(\InvalidArgumentException::class); new MultipartStream([['contents' => 'bar']]); } public function testSerializesFields(): void { $b = new MultipartStream([ [ 'name' => 'foo', 'contents' => 'bar', ], [ 'name' => 'baz', 'contents' => 'bam', ], ], 'boundary'); $expected = \implode('', [ "--boundary\r\n", "Content-Disposition: form-data; name=\"foo\"\r\n", "Content-Length: 3\r\n", "\r\n", "bar\r\n", "--boundary\r\n", "Content-Disposition: form-data; name=\"baz\"\r\n", "Content-Length: 3\r\n", "\r\n", "bam\r\n", "--boundary--\r\n", ]); self::assertSame($expected, (string) $b); } public function testSerializesNonStringFields(): void { $b = new MultipartStream([ [ 'name' => 'int', 'contents' => (int) 1, ], [ 'name' => 'bool', 'contents' => (bool) false, ], [ 'name' => 'bool2', 'contents' => (bool) true, ], [ 'name' => 'float', 'contents' => (float) 1.1, ], ], 'boundary'); $expected = \implode('', [ "--boundary\r\n", "Content-Disposition: form-data; name=\"int\"\r\n", "Content-Length: 1\r\n", "\r\n", "1\r\n", "--boundary\r\n", "Content-Disposition: form-data; name=\"bool\"\r\n", "\r\n", "\r\n", '--boundary', "\r\n", "Content-Disposition: form-data; name=\"bool2\"\r\n", "Content-Length: 1\r\n", "\r\n", "1\r\n", "--boundary\r\n", "Content-Disposition: form-data; name=\"float\"\r\n", "Content-Length: 3\r\n", "\r\n", "1.1\r\n", "--boundary--\r\n", '', ]); self::assertSame($expected, (string) $b); } public function testSerializesFiles(): void { $f1 = Psr7\FnStream::decorate(Psr7\Utils::streamFor('foo'), [ 'getMetadata' => static function (): string { return '/foo/bar.txt'; }, ]); $f2 = Psr7\FnStream::decorate(Psr7\Utils::streamFor('baz'), [ 'getMetadata' => static function (): string { return '/foo/baz.jpg'; }, ]); $f3 = Psr7\FnStream::decorate(Psr7\Utils::streamFor('bar'), [ 'getMetadata' => static function (): string { return '/foo/bar.unknown'; }, ]); $b = new MultipartStream([ [ 'name' => 'foo', 'contents' => $f1, ], [ 'name' => 'qux', 'contents' => $f2, ], [ 'name' => 'qux', 'contents' => $f3, ], ], 'boundary'); $expected = \implode('', [ "--boundary\r\n", "Content-Disposition: form-data; name=\"foo\"; filename=\"bar.txt\"\r\n", "Content-Length: 3\r\n", "Content-Type: text/plain\r\n", "\r\n", "foo\r\n", "--boundary\r\n", "Content-Disposition: form-data; name=\"qux\"; filename=\"baz.jpg\"\r\n", "Content-Length: 3\r\n", "Content-Type: image/jpeg\r\n", "\r\n", "baz\r\n", "--boundary\r\n", "Content-Disposition: form-data; name=\"qux\"; filename=\"bar.unknown\"\r\n", "Content-Length: 3\r\n", "Content-Type: application/octet-stream\r\n", "\r\n", "bar\r\n", "--boundary--\r\n", ]); self::assertSame($expected, (string) $b); } public function testSerializesFilesWithMixedNewlines(): void { $content = "LF\nCRLF\r\nCR\r"; $contentLength = \strlen($content); $f1 = Psr7\FnStream::decorate(Psr7\Utils::streamFor($content), [ 'getMetadata' => static function (): string { return '/foo/newlines.txt'; }, ]); $b = new MultipartStream([ [ 'name' => 'newlines', 'contents' => $f1, ], ], 'boundary'); $expected = \implode('', [ "--boundary\r\n", "Content-Disposition: form-data; name=\"newlines\"; filename=\"newlines.txt\"\r\n", "Content-Length: {$contentLength}\r\n", "Content-Type: text/plain\r\n", "\r\n", "{$content}\r\n", "--boundary--\r\n", ]); // Do not perform newline normalization in the assertion! The `$content` must // be embedded as-is in the payload. self::assertSame($expected, (string) $b); } public function testSerializesFilesWithCustomHeaders(): void { $f1 = Psr7\FnStream::decorate(Psr7\Utils::streamFor('foo'), [ 'getMetadata' => static function (): string { return '/foo/bar.txt'; }, ]); $b = new MultipartStream([ [ 'name' => 'foo', 'contents' => $f1, 'headers' => [ 'x-foo' => 'bar', 'content-disposition' => 'custom', ], ], ], 'boundary'); $expected = \implode('', [ "--boundary\r\n", "x-foo: bar\r\n", "content-disposition: custom\r\n", "Content-Length: 3\r\n", "Content-Type: text/plain\r\n", "\r\n", "foo\r\n", "--boundary--\r\n", ]); self::assertSame($expected, (string) $b); } public function testSerializesFilesWithCustomHeadersAndMultipleValues(): void { $f1 = Psr7\FnStream::decorate(Psr7\Utils::streamFor('foo'), [ 'getMetadata' => static function (): string { return '/foo/bar.txt'; }, ]); $f2 = Psr7\FnStream::decorate(Psr7\Utils::streamFor('baz'), [ 'getMetadata' => static function (): string { return '/foo/baz.jpg'; }, ]); $b = new MultipartStream([ [ 'name' => 'foo', 'contents' => $f1, 'headers' => [ 'x-foo' => 'bar', 'content-disposition' => 'custom', ], ], [ 'name' => 'foo', 'contents' => $f2, 'headers' => ['cOntenT-Type' => 'custom'], ], ], 'boundary'); $expected = \implode('', [ "--boundary\r\n", "x-foo: bar\r\n", "content-disposition: custom\r\n", "Content-Length: 3\r\n", "Content-Type: text/plain\r\n", "\r\n", "foo\r\n", "--boundary\r\n", "cOntenT-Type: custom\r\n", "Content-Disposition: form-data; name=\"foo\"; filename=\"baz.jpg\"\r\n", "Content-Length: 3\r\n", "\r\n", "baz\r\n", "--boundary--\r\n", ]); self::assertSame($expected, (string) $b); } public function testCanCreateWithNoneMetadataStreamField(): void { $str = 'dummy text'; $a = Psr7\Utils::streamFor(static function () use ($str): string { return $str; }); $b = new Psr7\LimitStream($a, \strlen($str)); $c = new MultipartStream([ [ 'name' => 'foo', 'contents' => $b, ], ], 'boundary'); $expected = \implode('', [ "--boundary\r\n", "Content-Disposition: form-data; name=\"foo\"\r\n", "\r\n", $str."\r\n", "--boundary--\r\n", ]); self::assertSame($expected, (string) $c); } }