コード例 #1
0
ファイル: FormDataTest.php プロジェクト: maitrepylos/nazeweb
 /**
  * Test adding a part with a filehandle.
  *
  * @return void
  */
 public function testAddFileHandle()
 {
     $file = CORE_PATH . 'VERSION.txt';
     $fh = fopen($file, 'r');
     $data = new FormData();
     $data->add('upload', $fh);
     $boundary = $data->boundary();
     $result = (string) $data;
     rewind($fh);
     $contents = stream_get_contents($fh);
     $expected = array('--' . $boundary, 'Content-Disposition: form-data; name="upload"', 'Content-Type: application/octet-stream', '', $contents, '--' . $boundary . '--', '', '');
     $this->assertEquals(implode("\r\n", $expected), $result);
 }
コード例 #2
0
 /**
  * Test adding a part with a filehandle.
  *
  * @return void
  */
 public function testAddFileHandle()
 {
     $file = CORE_PATH . 'VERSION.txt';
     $fh = fopen($file, 'r');
     $data = new FormData();
     $data->add('upload', $fh);
     $boundary = $data->boundary();
     $result = (string) $data;
     rewind($fh);
     $contents = stream_get_contents($fh);
     $expected = ['--' . $boundary, 'Content-Disposition: form-data; name="upload"; filename="VERSION.txt"', 'Content-Type: text/plain; charset=us-ascii', '', $contents, '--' . $boundary . '--', '', ''];
     $this->assertEquals(implode("\r\n", $expected), $result);
 }