Pull merge.
[yaffs-website] / vendor / jcalderonzumba / gastonjs / tests / unit / BrowserWindowTest.php
1 <?php
2
3 namespace Zumba\GastonJS\Tests;
4
5 /**
6  * Class BrowserWindowTest
7  * @package Zumba\GastonJS\Tests
8  */
9 class BrowserWindowTest extends BrowserCommandsTestCase {
10
11   public function testWindowHandleNoPage() {
12     $this->assertEquals(0, $this->browser->windowHandle());
13   }
14
15   public function testWindowHandlePage() {
16     $this->visitUrl($this->getTestPageBaseUrl() . "/static/basic.html");
17     $this->assertEquals(0, $this->browser->windowHandle());
18   }
19
20   public function testWindowNameNoPage() {
21     $this->assertEmpty($this->browser->windowName());
22   }
23
24   public function testWindowNamePage() {
25     $this->visitUrl($this->getTestPageBaseUrl() . "/static/basic.html");
26     $this->assertEquals("BASIC_WINDOW", $this->browser->windowName());
27   }
28
29   public function testCloseWindow() {
30     $this->visitUrl($this->getTestPageBaseUrl() . "/static/basic.html");
31     $this->assertEquals(0, $this->browser->windowHandle());
32     $this->browser->closeWindow("0");
33     $this->assertNull($this->browser->windowHandle());
34   }
35
36   public function testWindowHandlesNoPage() {
37     $handles = $this->browser->windowHandles();
38     $this->assertCount(1, $handles);
39     $this->assertEquals($handles[0], "0");
40   }
41
42   public function testOpenNewWindow() {
43     $this->assertTrue($this->browser->openNewWindow());
44     $this->assertEquals("about:blank", $this->browser->currentUrl());
45   }
46
47   public function testWindowHandlesPage() {
48     $this->visitUrl($this->getTestPageBaseUrl() . "/static/basic.html");
49     $this->browser->openNewWindow();
50     $this->visitUrl($this->getTestPageBaseUrl() . "/static/auth_ok.html");
51     $this->assertCount(2, $this->browser->windowHandles());
52   }
53
54   public function testSwitchToWindow() {
55     $this->testWindowHandlesPage();
56     $this->assertEquals(0, $this->browser->windowHandle());
57     $this->assertTrue($this->browser->switchToWindow("1"));
58     $this->assertEquals(1, $this->browser->windowHandle());
59   }
60 }