You are here

public function MultipartStreamTest::testSerializesFiles in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/psr7/tests/MultipartStreamTest.php \GuzzleHttp\Tests\MultipartStreamTest::testSerializesFiles()

File

vendor/guzzlehttp/psr7/tests/MultipartStreamTest.php, line 69

Class

MultipartStreamTest

Namespace

GuzzleHttp\Tests

Code

public function testSerializesFiles() {
  $f1 = Psr7\FnStream::decorate(Psr7\stream_for('foo'), [
    'getMetadata' => function () {
      return '/foo/bar.txt';
    },
  ]);
  $f2 = Psr7\FnStream::decorate(Psr7\stream_for('baz'), [
    'getMetadata' => function () {
      return '/foo/baz.jpg';
    },
  ]);
  $f3 = Psr7\FnStream::decorate(Psr7\stream_for('bar'), [
    'getMetadata' => function () {
      return '/foo/bar.gif';
    },
  ]);
  $b = new MultipartStream([
    [
      'name' => 'foo',
      'contents' => $f1,
    ],
    [
      'name' => 'qux',
      'contents' => $f2,
    ],
    [
      'name' => 'qux',
      'contents' => $f3,
    ],
  ], 'boundary');
  $expected = <<<EOT
--boundary
Content-Disposition: form-data; name="foo"; filename="bar.txt"
Content-Length: 3
Content-Type: text/plain

foo
--boundary
Content-Disposition: form-data; name="qux"; filename="baz.jpg"
Content-Length: 3
Content-Type: image/jpeg

baz
--boundary
Content-Disposition: form-data; name="qux"; filename="bar.gif"
Content-Length: 3
Content-Type: image/gif

bar
--boundary--

EOT;
  $this
    ->assertEquals($expected, str_replace("\r", '', $b));
}