3 namespace Zumba\GastonJS\Tests;
6 * Class BrowserFileTest
7 * @package Zumba\GastonJS\Tests
9 class BrowserFileTest extends BrowserCommandsTestCase {
11 public function testFileUpload() {
12 $this->visitUrl($this->getTestPageBaseUrl() . "/test/standard_form/form.html");
13 $fileLocation = sprintf("%s/Server/www/web/test/standard_form/image_for_test.png", __DIR__);
14 $this->assertCount(2, $this->browser->find("xpath", '//*[@id="element_2"]'));
15 $this->assertTrue($this->browser->selectFile(1, 0, $fileLocation));
16 $this->assertCount(2, $this->browser->find("xpath", '//*[@id="form_1014473"]'));
17 $this->assertEquals("submit", $this->browser->trigger(1, 1, "submit"));
18 //STUFF works like that, lets give 2 seconds to the browser for the page to load
20 $requestResponse = json_decode(strip_tags($this->browser->getBody()), true);
21 $expectedResponse = array("image_for_test.png" => array("file_name" => "image_for_test.png", "is_valid" => 1, "mime_type" => "image/png"));
22 $this->assertArraySubset($expectedResponse, $requestResponse["files"]);