Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 3581da1

Browse files
committed
Use only PHPUnit 5.4+, drop deprecated calls
1 parent 9482a3e commit 3581da1

File tree

7 files changed

+31
-54
lines changed

7 files changed

+31
-54
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
"source": "https://github.com/facebook/php-webdriver"
1212
},
1313
"require": {
14-
"php": "^5.5 || ~7.0",
14+
"php": "^5.6 || ~7.0",
1515
"symfony/process": "^2.8 || ^3.1",
1616
"ext-curl": "*",
1717
"ext-zip": "*"
1818
},
1919
"require-dev": {
20-
"phpunit/phpunit": "4.6.* || ~5.0",
20+
"phpunit/phpunit": "^5.4",
2121
"friendsofphp/php-cs-fixer": "^2.0",
2222
"squizlabs/php_codesniffer": "^2.6",
2323
"php-mock/php-mock-phpunit": "^1.1",

tests/functional/RemoteWebDriverFindElementTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testShouldThrowExceptionOfElementCannotBeFound()
2828
{
2929
$this->driver->get($this->getTestPageUrl('index.html'));
3030

31-
$this->setExpectedException(NoSuchElementException::class);
31+
$this->expectException(NoSuchElementException::class);
3232
$this->driver->findElement(WebDriverBy::id('not_existing'));
3333
}
3434

tests/functional/WebDriverAlertTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function testShouldAcceptAlert()
4848

4949
$this->driver->switchTo()->alert()->accept();
5050

51-
$this->setExpectedException(NoAlertOpenException::class);
51+
$this->expectException(NoAlertOpenException::class);
5252
$this->driver->switchTo()->alert()->accept();
5353
}
5454

tests/functional/WebDriverSelectTest.php

Lines changed: 22 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,8 @@ public function testShouldThrowExceptionWhenNotInstantiatedOnSelectElement()
5151
{
5252
$notSelectElement = $this->driver->findElement(WebDriverBy::cssSelector('textarea'));
5353

54-
$this->setExpectedException(
55-
UnexpectedTagNameException::class,
56-
'Element should have been "select" but was "textarea"'
57-
);
54+
$this->expectException(UnexpectedTagNameException::class);
55+
$this->expectExceptionMessage('Element should have been "select" but was "textarea"');
5856
new WebDriverSelect($notSelectElement);
5957
}
6058

@@ -109,10 +107,8 @@ public function testShouldThrowExceptionIfThereIsNoFirstSelectedOptionOfMultiple
109107
{
110108
$select = $this->getWebDriverSelectForMultipleSelect();
111109

112-
$this->setExpectedException(
113-
NoSuchElementException::class,
114-
'No options are selected'
115-
);
110+
$this->expectException(NoSuchElementException::class);
111+
$this->expectExceptionMessage('No options are selected');
116112
$select->getFirstSelectedOption();
117113
}
118114

@@ -155,10 +151,8 @@ public function testShouldThrowExceptionIfThereIsNoOptionIndexToSelect()
155151
{
156152
$select = $this->getWebDriverSelectForSimpleSelect();
157153

158-
$this->setExpectedException(
159-
NoSuchElementException::class,
160-
'Cannot locate option with index: 1337'
161-
);
154+
$this->expectException(NoSuchElementException::class);
155+
$this->expectExceptionMessage('Cannot locate option with index: 1337');
162156
$select->selectByIndex(1337);
163157
}
164158

@@ -201,10 +195,8 @@ public function testShouldThrowExceptionIfThereIsNoOptionValueToSelect()
201195
{
202196
$select = $this->getWebDriverSelectForSimpleSelect();
203197

204-
$this->setExpectedException(
205-
NoSuchElementException::class,
206-
'Cannot locate option with value: 1337'
207-
);
198+
$this->expectException(NoSuchElementException::class);
199+
$this->expectExceptionMessage('Cannot locate option with value: 1337');
208200
$select->selectByValue(1337);
209201
}
210202

@@ -247,10 +239,8 @@ public function testShouldThrowExceptionIfThereIsNoOptionVisibleTextToSelect()
247239
{
248240
$select = $this->getWebDriverSelectForSimpleSelect();
249241

250-
$this->setExpectedException(
251-
NoSuchElementException::class,
252-
'Cannot locate option with text: second'
253-
);
242+
$this->expectException(NoSuchElementException::class);
243+
$this->expectExceptionMessage('Cannot locate option with text: second');
254244
$select->selectByVisibleText('second'); // the option is "This is second option"
255245
}
256246

@@ -296,21 +286,17 @@ public function testShouldThrowExceptionIfThereIsNoOptionVisiblePartialTextToSel
296286
{
297287
$select = $this->getWebDriverSelectForSimpleSelect();
298288

299-
$this->setExpectedException(
300-
NoSuchElementException::class,
301-
'Cannot locate option with text: Not existing option'
302-
);
289+
$this->expectException(NoSuchElementException::class);
290+
$this->expectExceptionMessage('Cannot locate option with text: Not existing option');
303291
$select->selectByVisiblePartialText('Not existing option');
304292
}
305293

306294
public function testShouldThrowExceptionWhenDeselectingOnSimpleSelect()
307295
{
308296
$select = $this->getWebDriverSelectForSimpleSelect();
309297

310-
$this->setExpectedException(
311-
UnsupportedOperationException::class,
312-
'You may only deselect all options of a multi-select'
313-
);
298+
$this->expectException(UnsupportedOperationException::class);
299+
$this->expectExceptionMessage('You may only deselect all options of a multi-select');
314300
$select->deselectAll();
315301
}
316302

@@ -353,10 +339,8 @@ public function testShouldThrowExceptionIfDeselectingSimpleSelectByIndex()
353339
{
354340
$select = $this->getWebDriverSelectForSimpleSelect();
355341

356-
$this->setExpectedException(
357-
UnsupportedOperationException::class,
358-
'You may only deselect options of a multi-select'
359-
);
342+
$this->expectException(UnsupportedOperationException::class);
343+
$this->expectExceptionMessage('You may only deselect options of a multi-select');
360344
$select->deselectByIndex(0);
361345
}
362346

@@ -381,10 +365,8 @@ public function testShouldThrowExceptionIfDeselectingSimpleSelectByValue()
381365
{
382366
$select = $this->getWebDriverSelectForSimpleSelect();
383367

384-
$this->setExpectedException(
385-
UnsupportedOperationException::class,
386-
'You may only deselect options of a multi-select'
387-
);
368+
$this->expectException(UnsupportedOperationException::class);
369+
$this->expectExceptionMessage('You may only deselect options of a multi-select');
388370
$select->deselectByValue('first');
389371
}
390372

@@ -411,10 +393,8 @@ public function testShouldThrowExceptionIfDeselectingSimpleSelectByVisibleText()
411393
{
412394
$select = $this->getWebDriverSelectForSimpleSelect();
413395

414-
$this->setExpectedException(
415-
UnsupportedOperationException::class,
416-
'You may only deselect options of a multi-select'
417-
);
396+
$this->expectException(UnsupportedOperationException::class);
397+
$this->expectExceptionMessage('You may only deselect options of a multi-select');
418398
$select->deselectByVisibleText('First');
419399
}
420400

@@ -447,10 +427,8 @@ public function testShouldThrowExceptionIfDeselectingSimpleSelectByVisiblePartia
447427
{
448428
$select = $this->getWebDriverSelectForSimpleSelect();
449429

450-
$this->setExpectedException(
451-
UnsupportedOperationException::class,
452-
'You may only deselect options of a multi-select'
453-
);
430+
$this->expectException(UnsupportedOperationException::class);
431+
$this->expectExceptionMessage('You may only deselect options of a multi-select');
454432
$select->deselectByVisiblePartialText('First');
455433
}
456434

tests/functional/WebDriverTimeoutsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testShouldFailGettingDelayedElementWithoutWait()
3030
{
3131
$this->driver->get($this->getTestPageUrl('delayed_element.html'));
3232

33-
$this->setExpectedException(NoSuchElementException::class);
33+
$this->expectException(NoSuchElementException::class);
3434
$this->driver->findElement(WebDriverBy::id('delayed'));
3535
}
3636

tests/unit/CookieTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ public function testShouldBeCreatableFromAnArrayWithAllValues()
146146
public function testShouldValidateCookie($name, $value, $domain, $expectedMessage)
147147
{
148148
if ($expectedMessage) {
149-
$this->setExpectedException(\InvalidArgumentException::class, $expectedMessage);
149+
$this->expectException(\InvalidArgumentException::class);
150+
$this->expectExceptionMessage($expectedMessage);
150151
}
151152

152153
$cookie = new Cookie($name, $value);

tests/unit/WebDriverOptionsTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,8 @@ public function testShouldNotAllowToCreateCookieFromDifferentObjectThanCookie()
8888

8989
$options = new WebDriverOptions($this->executor);
9090

91-
$this->setExpectedException(
92-
\InvalidArgumentException::class,
93-
'Cookie must be set from instance of Cookie class or from array.'
94-
);
91+
$this->expectException(\InvalidArgumentException::class);
92+
$this->expectExceptionMessage('Cookie must be set from instance of Cookie class or from array.');
9593
$options->addCookie($notCookie);
9694
}
9795

0 commit comments

Comments
 (0)