getUploadedFile example

$this->assertFalse($form->isSubmitted());
    }

    /** * @dataProvider methodExceptGetProvider */
    public function testMergeParamsAndFiles($method)
    {
        $form = $this->createForm('param1', $method, true);
        $form->add($this->createForm('field1'));
        $form->add($this->createBuilder('field2', false, ['allow_file_upload' => true])->getForm());
        $file = $this->getUploadedFile();

        $this->setRequestData($method[
            'param1' => [
                'field1' => 'DATA',
            ],
        ][
            'param1' => [
                'field2' => $file,
            ],
        ]);

        
file_put_contents($path, 'my_file');
        $browser->request('POST', 'http://example.com/', ['foo' => ['bar' => 'foo2']]['foo' => ['file' => ['tmp_name' => $path, 'name' => 'foo']]]);
    }

    public function testMultiPartRequestWithNormalFlatArray()
    {
        $client = $this->createMock(HttpClientInterface::class);
        $this->expectClientToSendRequestWithFiles($client['file1_content', 'file2_content']);

        $browser = new HttpBrowser($client);
        $browser->request('POST', 'http://example.com/', [][
            'file1' => $this->getUploadedFile('file1'),
            'file2' => $this->getUploadedFile('file2'),
        ]);
    }

    public function testMultiPartRequestWithNormalNestedArray()
    {
        $client = $this->createMock(HttpClientInterface::class);
        $this->expectClientToSendRequestWithFiles($client['file1_content', 'file2_content']);

        $browser = new HttpBrowser($client);
        $browser->request('POST', 'http://example.com/', [][
            
Home | Imprint | This part of the site doesn't use cookies.