Skip to content

Commit 1dcec4b

Browse files
committed
Minor codestyle improvements and unifications
1 parent 5135379 commit 1dcec4b

30 files changed

+90
-76
lines changed

.php_cs.dist

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ return PhpCsFixer\Config::create()
1313
'concat_space' => ['spacing' => 'one'],
1414
'function_typehint_space' => true,
1515
'general_phpdoc_annotation_remove' => ['author'],
16+
'implode_call' => true,
17+
'is_null' => true,
1618
'linebreak_after_opening_tag' => true,
1719
'lowercase_cast' => true,
1820
'mb_str_functions' => true,
@@ -51,9 +53,15 @@ return PhpCsFixer\Config::create()
5153
'ordered_imports' => true,
5254
'php_unit_construct' => true,
5355
'php_unit_dedicate_assert' => true,
54-
'php_unit_expectation' => true,
56+
'php_unit_expectation' => ['target' => '5.6'],
57+
'php_unit_method_casing' => ['case' => 'camel_case'],
5558
'php_unit_mock' => true,
59+
'php_unit_mock_short_will_return' => true,
60+
'php_unit_namespaced' => ['target' => '5.7'],
5661
'php_unit_no_expectation_annotation' => true,
62+
'php_unit_ordered_covers' => true,
63+
'php_unit_set_up_tear_down_visibility' => true,
64+
'php_unit_test_case_static_method_calls' => ['call_type' => 'this'],
5765
'phpdoc_add_missing_param_annotation' => true,
5866
'phpdoc_indent' => true,
5967
'phpdoc_no_access' => true,

phpstan.neon

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
parameters:
2-
ignoreErrors:
3-
- '#Class Symfony\\Component\\Process\\ProcessBuilder not found.#'
4-
- '#Instantiated class Symfony\\Component\\Process\\ProcessBuilder not found.#'
5-
- '#Call to method setPrefix\(\) on an unknown class Symfony\\Component\\Process\\ProcessBuilder#'
2+
ignoreErrors:
3+
- '#Class Symfony\\Component\\Process\\ProcessBuilder not found.#'
4+
- '#Instantiated class Symfony\\Component\\Process\\ProcessBuilder not found.#'
5+
- '#Call to method setPrefix\(\) on an unknown class Symfony\\Component\\Process\\ProcessBuilder#'
66
# To be fixed:
7-
- '#Call to an undefined method RecursiveIteratorIterator::getSubPathName\(\)#'
8-
- '#Call to an undefined method Facebook\\WebDriver\\WebDriver::getTouch\(\)#'
9-
- '#Call to an undefined method Facebook\\WebDriver\\WebDriverElement::getCoordinates\(\)#'
10-
- '#Call to an undefined method Facebook\\WebDriver\\WebDriverElement::equals\(\)#'
7+
- '#Call to an undefined method RecursiveIteratorIterator::getSubPathName\(\)#'
8+
- '#Call to an undefined method Facebook\\WebDriver\\WebDriver::getTouch\(\)#'
9+
- '#Call to an undefined method Facebook\\WebDriver\\WebDriverElement::getCoordinates\(\)#'
10+
- '#Call to an undefined method Facebook\\WebDriver\\WebDriverElement::equals\(\)#'

tests/functional/RemoteWebDriverCreateTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
use Facebook\WebDriver\Remote\RemoteWebDriver;
2121

2222
/**
23-
* @covers \Facebook\WebDriver\Remote\RemoteWebDriver
2423
* @covers \Facebook\WebDriver\Remote\HttpCommandExecutor
24+
* @covers \Facebook\WebDriver\Remote\RemoteWebDriver
2525
*/
2626
class RemoteWebDriverCreateTest extends WebDriverTestCase
2727
{

tests/functional/RemoteWebDriverTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public function testShouldGetPageTitle()
3838
}
3939

4040
/**
41-
* @covers ::getCurrentURL
4241
* @covers ::get
42+
* @covers ::getCurrentURL
4343
*/
4444
public function testShouldGetCurrentUrl()
4545
{

tests/functional/WebDriverActionsTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public function testShouldClickOnElement()
6161
/**
6262
* @covers ::__construct
6363
* @covers ::clickAndHold
64-
* @covers ::release
6564
* @covers ::perform
65+
* @covers ::release
6666
*/
6767
public function testShouldClickAndHoldOnElementAndRelease()
6868
{

tests/functional/WebDriverAlertTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
use Facebook\WebDriver\Remote\WebDriverBrowserType;
2121

2222
/**
23-
* @covers \Facebook\WebDriver\WebDriverAlert
2423
* @covers \Facebook\WebDriver\Remote\RemoteTargetLocator
24+
* @covers \Facebook\WebDriver\WebDriverAlert
2525
*/
2626
class WebDriverAlertTest extends WebDriverTestCase
2727
{

tests/functional/WebDriverByTest.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
class WebDriverByTest extends WebDriverTestCase
2525
{
2626
/**
27-
* @dataProvider textElementsProvider
27+
* @dataProvider provideTextElements
2828
* @param string $webDriverByLocatorMethod
2929
* @param string $webDriverByLocatorValue
3030
* @param string $expectedText
@@ -52,7 +52,10 @@ public function testShouldFindTextElementByLocator(
5252
}
5353
}
5454

55-
public function textElementsProvider()
55+
/**
56+
* @return array[]
57+
*/
58+
public function provideTextElements()
5659
{
5760
return [
5861
'id' => ['id', 'id_test', 'Test by ID'],

tests/functional/WebDriverCheckboxesTest.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
use Facebook\WebDriver\Exception\NoSuchElementException;
1919

2020
/**
21-
* @covers \Facebook\WebDriver\WebDriverCheckboxes
2221
* @covers \Facebook\WebDriver\AbstractWebDriverCheckboxOrRadio
22+
* @covers \Facebook\WebDriver\WebDriverCheckboxes
2323
* @group exclude-edge
2424
*/
2525
class WebDriverCheckboxesTest extends WebDriverTestCase
@@ -137,7 +137,7 @@ public function testSelectByIndexInvalid()
137137
}
138138

139139
/**
140-
* @dataProvider selectByVisibleTextDataProvider
140+
* @dataProvider provideSelectByVisibleTextData
141141
*
142142
* @param string $text
143143
* @param string $value
@@ -154,9 +154,9 @@ public function testSelectByVisibleText($text, $value)
154154
}
155155

156156
/**
157-
* @return array
157+
* @return array[]
158158
*/
159-
public function selectByVisibleTextDataProvider()
159+
public function provideSelectByVisibleTextData()
160160
{
161161
return [
162162
['J 2 B', 'j2b'],
@@ -165,7 +165,7 @@ public function selectByVisibleTextDataProvider()
165165
}
166166

167167
/**
168-
* @dataProvider selectByVisiblePartialTextDataProvider
168+
* @dataProvider provideSelectByVisiblePartialTextData
169169
*
170170
* @param string $text
171171
* @param string $value
@@ -182,9 +182,9 @@ public function testSelectByVisiblePartialText($text, $value)
182182
}
183183

184184
/**
185-
* @return array
185+
* @return array[]
186186
*/
187-
public function selectByVisiblePartialTextDataProvider()
187+
public function provideSelectByVisiblePartialTextData()
188188
{
189189
return [
190190
['2 B', 'j2b'],

tests/functional/WebDriverNavigationTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
class WebDriverNavigationTest extends WebDriverTestCase
2222
{
2323
/**
24-
* @covers ::to
2524
* @covers ::__construct
25+
* @covers ::to
2626
*/
2727
public function testShouldNavigateToUrl()
2828
{

tests/functional/WebDriverRadiosTest.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
use Facebook\WebDriver\Exception\UnsupportedOperationException;
2020

2121
/**
22-
* @covers \Facebook\WebDriver\WebDriverRadios
2322
* @covers \Facebook\WebDriver\AbstractWebDriverCheckboxOrRadio
23+
* @covers \Facebook\WebDriver\WebDriverRadios
2424
* @group exclude-edge
2525
*/
2626
class WebDriverRadiosTest extends WebDriverTestCase
@@ -115,7 +115,7 @@ public function testSelectByIndexInvalid()
115115
}
116116

117117
/**
118-
* @dataProvider selectByVisibleTextDataProvider
118+
* @dataProvider provideSelectByVisibleTextData
119119
*
120120
* @param string $text
121121
* @param string $value
@@ -128,9 +128,9 @@ public function testSelectByVisibleText($text, $value)
128128
}
129129

130130
/**
131-
* @return array
131+
* @return array[]
132132
*/
133-
public function selectByVisibleTextDataProvider()
133+
public function provideSelectByVisibleTextData()
134134
{
135135
return [
136136
['J 3 B', 'j3b'],
@@ -139,7 +139,7 @@ public function selectByVisibleTextDataProvider()
139139
}
140140

141141
/**
142-
* @dataProvider selectByVisiblePartialTextDataProvider
142+
* @dataProvider provideSelectByVisiblePartialTextData
143143
*
144144
* @param string $text
145145
* @param string $value
@@ -152,9 +152,9 @@ public function testSelectByVisiblePartialText($text, $value)
152152
}
153153

154154
/**
155-
* @return array
155+
* @return array[]
156156
*/
157-
public function selectByVisiblePartialTextDataProvider()
157+
public function provideSelectByVisiblePartialTextData()
158158
{
159159
return [
160160
['3 B', 'j3b'],

tests/functional/WebDriverSelectTest.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
/**
2323
* @group exclude-saucelabs
24-
* @covers \Facebook\WebDriver\WebDriverSelect
2524
* @covers \Facebook\WebDriver\Exception\UnexpectedTagNameException
25+
* @covers \Facebook\WebDriver\WebDriverSelect
2626
*/
2727
class WebDriverSelectTest extends WebDriverTestCase
2828
{
@@ -58,7 +58,7 @@ public function testShouldThrowExceptionWhenNotInstantiatedOnSelectElement()
5858
}
5959

6060
/**
61-
* @dataProvider selectSelectorProvider
61+
* @dataProvider provideSelectSelector
6262
* @param string $selector
6363
*/
6464
public function testShouldGetOptionsOfSelect($selector)
@@ -72,7 +72,10 @@ public function testShouldGetOptionsOfSelect($selector)
7272
$this->assertCount(5, $options);
7373
}
7474

75-
public function selectSelectorProvider()
75+
/**
76+
* @return array[]
77+
*/
78+
public function provideSelectSelector()
7679
{
7780
return [
7881
'simple <select>' => ['#select'],

tests/functional/WebDriverTimeoutsTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public function testShouldFailGettingDelayedElementWithoutWait()
3838
}
3939

4040
/**
41-
* @covers ::implicitlyWait
4241
* @covers ::__construct
42+
* @covers ::implicitlyWait
4343
*/
4444
public function testShouldGetDelayedElementWithImplicitWait()
4545
{
@@ -52,8 +52,8 @@ public function testShouldGetDelayedElementWithImplicitWait()
5252
}
5353

5454
/**
55-
* @covers ::pageLoadTimeout
5655
* @covers ::__construct
56+
* @covers ::pageLoadTimeout
5757
*/
5858
public function testShouldFailIfPageIsLoadingLongerThanPageLoadTimeout()
5959
{

tests/unit/CookieTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function testShouldBeCreatableFromAnArrayWithAllValues()
161161
}
162162

163163
/**
164-
* @dataProvider invalidCookieProvider
164+
* @dataProvider provideInvalidCookie
165165
* @param string $name
166166
* @param string $value
167167
* @param string $domain
@@ -185,7 +185,7 @@ public function testShouldValidateCookieOnConstruction($name, $value, $domain, $
185185
/**
186186
* @return array[]
187187
*/
188-
public function invalidCookieProvider()
188+
public function provideInvalidCookie()
189189
{
190190
return [
191191
// $name, $value, $domain, $expectedMessage

tests/unit/Exception/WebDriverExceptionTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public function testShouldStoreResultsOnInstantiation()
2929
}
3030

3131
/**
32-
* @dataProvider jsonWireStatusCodeProvider
33-
* @dataProvider w3CWebDriverErrorCodeProvider
32+
* @dataProvider provideJsonWireStatusCode
33+
* @dataProvider provideW3CWebDriverErrorCode
3434
* @param int $errorCode
3535
* @param string $expectedExceptionType
3636
*/
@@ -49,7 +49,7 @@ public function testShouldThrowProperExceptionBasedOnWebDriverErrorCode($errorCo
4949
/**
5050
* @return array[]
5151
*/
52-
public function jsonWireStatusCodeProvider()
52+
public function provideJsonWireStatusCode()
5353
{
5454
return [
5555
[1337, UnrecognizedExceptionException::class],
@@ -93,7 +93,7 @@ public function jsonWireStatusCodeProvider()
9393
/**
9494
* @return array[]
9595
*/
96-
public function w3CWebDriverErrorCodeProvider()
96+
public function provideW3CWebDriverErrorCode()
9797
{
9898
return [
9999
['element click intercepted', ElementClickInterceptedException::class],

tests/unit/Interactions/Internal/WebDriverButtonReleaseActionTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class WebDriverButtonReleaseActionTest extends TestCase
2828
/** @var WebDriverLocatable|\PHPUnit_Framework_MockObject_MockObject */
2929
private $locationProvider;
3030

31-
public function setUp()
31+
protected function setUp()
3232
{
3333
$this->webDriverMouse = $this->getMockBuilder(WebDriverMouse::class)->getMock();
3434
$this->locationProvider = $this->getMockBuilder(WebDriverLocatable::class)->getMock();
@@ -43,7 +43,7 @@ public function testPerformSendsMouseUpCommand()
4343
$coords = $this->getMockBuilder(WebDriverCoordinates::class)
4444
->disableOriginalConstructor()->getMock();
4545
$this->webDriverMouse->expects($this->once())->method('mouseUp')->with($coords);
46-
$this->locationProvider->expects($this->once())->method('getCoordinates')->will($this->returnValue($coords));
46+
$this->locationProvider->expects($this->once())->method('getCoordinates')->willReturn($coords);
4747
$this->webDriverButtonReleaseAction->perform();
4848
}
4949
}

tests/unit/Interactions/Internal/WebDriverClickActionTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class WebDriverClickActionTest extends TestCase
2828
/** @var WebDriverLocatable|\PHPUnit_Framework_MockObject_MockObject */
2929
private $locationProvider;
3030

31-
public function setUp()
31+
protected function setUp()
3232
{
3333
$this->webDriverMouse = $this->getMockBuilder(WebDriverMouse::class)->getMock();
3434
$this->locationProvider = $this->getMockBuilder(WebDriverLocatable::class)->getMock();
@@ -43,7 +43,7 @@ public function testPerformSendsClickCommand()
4343
$coords = $this->getMockBuilder(WebDriverCoordinates::class)
4444
->disableOriginalConstructor()->getMock();
4545
$this->webDriverMouse->expects($this->once())->method('click')->with($coords);
46-
$this->locationProvider->expects($this->once())->method('getCoordinates')->will($this->returnValue($coords));
46+
$this->locationProvider->expects($this->once())->method('getCoordinates')->willReturn($coords);
4747
$this->webDriverClickAction->perform();
4848
}
4949
}

tests/unit/Interactions/Internal/WebDriverClickAndHoldActionTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class WebDriverClickAndHoldActionTest extends TestCase
2828
/** @var WebDriverLocatable|\PHPUnit_Framework_MockObject_MockObject */
2929
private $locationProvider;
3030

31-
public function setUp()
31+
protected function setUp()
3232
{
3333
$this->webDriverMouse = $this->getMockBuilder(WebDriverMouse::class)->getMock();
3434
$this->locationProvider = $this->getMockBuilder(WebDriverLocatable::class)->getMock();
@@ -43,7 +43,7 @@ public function testPerformSendsMouseDownCommand()
4343
$coords = $this->getMockBuilder(WebDriverCoordinates::class)
4444
->disableOriginalConstructor()->getMock();
4545
$this->webDriverMouse->expects($this->once())->method('mouseDown')->with($coords);
46-
$this->locationProvider->expects($this->once())->method('getCoordinates')->will($this->returnValue($coords));
46+
$this->locationProvider->expects($this->once())->method('getCoordinates')->willReturn($coords);
4747
$this->webDriverClickAndHoldAction->perform();
4848
}
4949
}

tests/unit/Interactions/Internal/WebDriverContextClickActionTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class WebDriverContextClickActionTest extends TestCase
2828
/** @var WebDriverLocatable|\PHPUnit_Framework_MockObject_MockObject */
2929
private $locationProvider;
3030

31-
public function setUp()
31+
protected function setUp()
3232
{
3333
$this->webDriverMouse = $this->getMockBuilder(WebDriverMouse::class)->getMock();
3434
$this->locationProvider = $this->getMockBuilder(WebDriverLocatable::class)->getMock();
@@ -43,7 +43,7 @@ public function testPerformSendsContextClickCommand()
4343
$coords = $this->getMockBuilder(WebDriverCoordinates::class)
4444
->disableOriginalConstructor()->getMock();
4545
$this->webDriverMouse->expects($this->once())->method('contextClick')->with($coords);
46-
$this->locationProvider->expects($this->once())->method('getCoordinates')->will($this->returnValue($coords));
46+
$this->locationProvider->expects($this->once())->method('getCoordinates')->willReturn($coords);
4747
$this->webDriverContextClickAction->perform();
4848
}
4949
}

0 commit comments

Comments
 (0)