업로드 방법에 대한 BDD 테스트를 수행하려고합니다. symfony2 프로젝트에서 Behat with Mink를 사용하고 있습니다. Guzzle 클라이언트로 파일을 업로드하는 방법은 무엇입니까?
는 지금이 클라이언트에 간단한 요청을 할 수 있어요 :$this->client = $this->mink->getSession('goutte')->getDriver()->getClient();
하고 문제없이
$this->client->request("POST", $url, array('content-type' => 'application/json'), array(), array(), $fields);
.
파일 요청은 어떻게하나요? 나는이 시도 :
$file = new \Symfony\Component\HttpFoundation\File\UploadedFile($path, "video");
$fields = json_encode($table->getColumnsHash()[0]);
$this->client->request("POST", $url, array('content-type' => 'multipart/form-data'), array($file), array(), $fields);
을 그리고 나타나는 오류는 다음과 같습니다
PHP Fatal error: Call to undefined method GuzzleHttp\Stream\Stream::addFile()
실수는 무엇입니까? 감사합니다.
$ table 변수는 무엇입니까? – jedema
Behat \ Gherkin \ Node \ TableNode 개체입니다. 이 표기법 (http://docs.behat.org/en/v3.0/guides/2.definitions.html#transforming-tables)을 사용할 때와 같은 객체가 있습니다. – stuzzo