Beispiel #1
0
 public function testContentType()
 {
     $upload = new FormUpload(__DIR__ . '/Fixtures/google.png');
     $upload->setName('company[logo]');
     $upload->setContentType('foo/bar');
     $this->assertEquals(array('Content-Disposition: form-data; name="company[logo]"; filename="google.png"', 'Content-Type: foo/bar'), $upload->getHeaders());
 }
Beispiel #2
0
 public function testFilenamelessUpload()
 {
     $this->setExpectedException('LogicException');
     $upload = new FormUpload();
     $upload->setContent('foobar');
     $request = new FormRequest();
     $request->setField('user[name]', 'Kris');
     $request->setField('user[image]', $upload);
     $content = $request->getContent();
 }
Beispiel #3
0
 public function testMultipartContent()
 {
     $upload = new FormUpload();
     $upload->setContent('foobar');
     $request = new FormRequest();
     $request->setField('user[name]', 'Kris');
     $request->setField('user[image]', $upload);
     $content = $request->getContent();
     $this->assertContains("Content-Disposition: form-data; name=\"user[name]\"\r\n\r\nKris\r\n", $content);
     $this->assertContains("Content-Disposition: form-data; name=\"user[image]\"\r\nContent-Type: text/plain\r\n\r\nfoobar\r\n", $content);
 }
Beispiel #4
0
 public function provideClientAndUpload()
 {
     $stringUpload = new FormUpload();
     $stringUpload->setFilename('google.png');
     $stringUpload->setContent(file_get_contents(__DIR__ . '/../Message/Fixtures/google.png'));
     $uploads = array($stringUpload, new FormUpload(__DIR__ . '/../Message/Fixtures/google.png'));
     $clients = $this->provideClient();
     $data = array();
     foreach ($clients as $client) {
         foreach ($uploads as $upload) {
             $data[] = array($client[0], $upload);
         }
     }
     return $data;
 }