Skip to content

Commit 0fc796a

Browse files
authored
Merge pull request php-webdriver#1034 from OndraM/feature/remove-phpunit-compat
Remove no longer needed compatibility layer with old PHPUnit
2 parents 9e4b703 + 1015581 commit 0fc796a

File tree

4 files changed

+20
-36
lines changed

4 files changed

+20
-36
lines changed

tests/functional/RemoteTargetLocatorTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function testShouldSwitchToWindow()
2424
);
2525

2626
// At first the window should not be switched
27-
$this->compatAssertStringContainsString('open_new_window.html', $this->driver->getCurrentURL());
27+
$this->assertStringContainsString('open_new_window.html', $this->driver->getCurrentURL());
2828
$this->assertSame($originalWindowHandle, $this->driver->getWindowHandle());
2929

3030
/**
@@ -44,7 +44,7 @@ public function testShouldSwitchToWindow()
4444
});
4545

4646
// After switchTo() is called, the active window should be changed
47-
$this->compatAssertStringContainsString('index.html', $this->driver->getCurrentURL());
47+
$this->assertStringContainsString('index.html', $this->driver->getCurrentURL());
4848
$this->assertNotSame($originalWindowHandle, $this->driver->getWindowHandle());
4949
}
5050

@@ -70,25 +70,25 @@ public function testShouldSwitchToFrameByItsId()
7070

7171
$this->driver->get($this->getTestPageUrl(TestPage::PAGE_WITH_FRAME));
7272

73-
$this->compatAssertStringContainsString($parentPage, $this->driver->getPageSource());
73+
$this->assertStringContainsString($parentPage, $this->driver->getPageSource());
7474

7575
$this->driver->switchTo()->frame(0);
76-
$this->compatAssertStringContainsString($firstChildFrame, $this->driver->getPageSource());
76+
$this->assertStringContainsString($firstChildFrame, $this->driver->getPageSource());
7777

7878
$this->driver->switchTo()->frame(null);
79-
$this->compatAssertStringContainsString($parentPage, $this->driver->getPageSource());
79+
$this->assertStringContainsString($parentPage, $this->driver->getPageSource());
8080

8181
$this->driver->switchTo()->frame(1);
82-
$this->compatAssertStringContainsString($secondChildFrame, $this->driver->getPageSource());
82+
$this->assertStringContainsString($secondChildFrame, $this->driver->getPageSource());
8383

8484
$this->driver->switchTo()->frame(null);
85-
$this->compatAssertStringContainsString($parentPage, $this->driver->getPageSource());
85+
$this->assertStringContainsString($parentPage, $this->driver->getPageSource());
8686

8787
$this->driver->switchTo()->frame(0);
88-
$this->compatAssertStringContainsString($firstChildFrame, $this->driver->getPageSource());
88+
$this->assertStringContainsString($firstChildFrame, $this->driver->getPageSource());
8989

9090
$this->driver->switchTo()->defaultContent();
91-
$this->compatAssertStringContainsString($parentPage, $this->driver->getPageSource());
91+
$this->assertStringContainsString($parentPage, $this->driver->getPageSource());
9292
}
9393

9494
public function testShouldSwitchToParentFrame()
@@ -98,13 +98,13 @@ public function testShouldSwitchToParentFrame()
9898

9999
$this->driver->get($this->getTestPageUrl(TestPage::PAGE_WITH_FRAME));
100100

101-
$this->compatAssertStringContainsString($parentPage, $this->driver->getPageSource());
101+
$this->assertStringContainsString($parentPage, $this->driver->getPageSource());
102102

103103
$this->driver->switchTo()->frame(0);
104-
$this->compatAssertStringContainsString($firstChildFrame, $this->driver->getPageSource());
104+
$this->assertStringContainsString($firstChildFrame, $this->driver->getPageSource());
105105

106106
$this->driver->switchTo()->parent();
107-
$this->compatAssertStringContainsString($parentPage, $this->driver->getPageSource());
107+
$this->assertStringContainsString($parentPage, $this->driver->getPageSource());
108108
}
109109

110110
public function testShouldSwitchToFrameByElement()
@@ -114,7 +114,7 @@ public function testShouldSwitchToFrameByElement()
114114
$element = $this->driver->findElement(WebDriverBy::id('iframe_content'));
115115
$this->driver->switchTo()->frame($element);
116116

117-
$this->compatAssertStringContainsString('This is the content of the iFrame', $this->driver->getPageSource());
117+
$this->assertStringContainsString('This is the content of the iFrame', $this->driver->getPageSource());
118118
}
119119

120120
/**
@@ -129,8 +129,8 @@ public function testShouldCreateNewWindow()
129129
$this->driver->get($this->getTestPageUrl(TestPage::INDEX));
130130
$this->assertEquals($this->getTestPageUrl(TestPage::INDEX), $this->driver->getCurrentUrl());
131131
$source = $this->driver->getPageSource();
132-
$this->compatAssertStringContainsString('<h1 id="welcome">', $source);
133-
$this->compatAssertStringContainsString('Welcome to the php-webdriver testing page.', $source);
132+
$this->assertStringContainsString('<h1 id="welcome">', $source);
133+
$this->assertStringContainsString('Welcome to the php-webdriver testing page.', $source);
134134
$windowHandles = $this->driver->getWindowHandles();
135135
$this->assertCount(1, $windowHandles);
136136

@@ -178,6 +178,6 @@ public function testShouldAcceptStringAsFrameIdInJsonWireMode()
178178

179179
$this->driver->switchTo()->frame('iframe_content');
180180

181-
$this->compatAssertStringContainsString('This is the content of the iFrame', $this->driver->getPageSource());
181+
$this->assertStringContainsString('This is the content of the iFrame', $this->driver->getPageSource());
182182
}
183183
}

tests/functional/RemoteWebDriverCreateTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function testShouldCreateInstanceFromExistingSessionId()
111111
$this->requestTimeout
112112
);
113113
$originalDriver->get($this->getTestPageUrl(TestPage::INDEX));
114-
$this->compatAssertStringContainsString('/index.html', $originalDriver->getCurrentURL());
114+
$this->assertStringContainsString('/index.html', $originalDriver->getCurrentURL());
115115

116116
// Store session attributes
117117
$sessionId = $originalDriver->getSessionID();
@@ -150,7 +150,7 @@ public function testShouldCreateInstanceFromExistingSessionId()
150150
$this->assertEqualsCanonicalizing($originalCapabilities, $this->driver->getCapabilities());
151151

152152
// Check we reused the previous instance (window) and it has the same URL
153-
$this->compatAssertStringContainsString('/index.html', $this->driver->getCurrentURL());
153+
$this->assertStringContainsString('/index.html', $this->driver->getCurrentURL());
154154

155155
// Do some interaction with the new driver
156156
$this->assertNotEmpty($this->driver->findElement(WebDriverBy::id('id_test'))->getText());

tests/functional/RemoteWebDriverTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public function testShouldGetPageSource()
4242
$this->driver->get($this->getTestPageUrl(TestPage::INDEX));
4343

4444
$source = $this->driver->getPageSource();
45-
$this->compatAssertStringContainsString('<h1 id="welcome">', $source);
46-
$this->compatAssertStringContainsString('Welcome to the php-webdriver testing page.', $source);
45+
$this->assertStringContainsString('<h1 id="welcome">', $source);
46+
$this->assertStringContainsString('Welcome to the php-webdriver testing page.', $source);
4747
}
4848

4949
/**

tests/functional/WebDriverTestCase.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -240,22 +240,6 @@ protected function setUpSauceLabs()
240240
}
241241
}
242242

243-
/**
244-
* Uses assertStringContainsString when it is available or uses assertContains for old phpunit versions
245-
* @param string $needle
246-
* @param string $haystack
247-
* @param string $message
248-
*/
249-
protected function compatAssertStringContainsString($needle, $haystack, $message = '')
250-
{
251-
if (method_exists($this, 'assertStringContainsString')) {
252-
parent::assertStringContainsString($needle, $haystack, $message);
253-
254-
return;
255-
}
256-
parent::assertContains($needle, $haystack, $message);
257-
}
258-
259243
protected function createWebDriver()
260244
{
261245
$this->driver = RemoteWebDriver::create(

0 commit comments

Comments
 (0)