Pull merge.
[yaffs-website] / vendor / jcalderonzumba / gastonjs / tests / unit / BrowserFileTest.php
1 <?php
2
3 namespace Zumba\GastonJS\Tests;
4
5 /**
6  * Class BrowserFileTest
7  * @package Zumba\GastonJS\Tests
8  */
9 class BrowserFileTest extends BrowserCommandsTestCase {
10
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
19     sleep(2);
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"]);
23   }
24 }