23
23
use Codeception \Util \Uri ;
24
24
use DOMDocument ;
25
25
use DOMNode ;
26
+ use Exception ;
26
27
use InvalidArgumentException ;
27
28
use LogicException ;
28
29
use Symfony \Component \BrowserKit \AbstractBrowser ;
@@ -78,7 +79,7 @@ class InnerBrowser extends Module implements Web, PageSourceSaver, ElementLocato
78
79
*/
79
80
private $ baseUrl ;
80
81
81
- public function _failed (TestInterface $ test , $ fail )
82
+ public function _failed (TestInterface $ test , Exception $ fail )
82
83
{
83
84
try {
84
85
if (!$ this ->client || !$ this ->client ->getInternalResponse ()) {
@@ -260,7 +261,7 @@ protected function clientRequest(
260
261
return $ this ->redirectIfNecessary ($ result , $ maxRedirects , 0 );
261
262
}
262
263
263
- protected function isInternalDomain ($ domain ): bool
264
+ protected function isInternalDomain (string $ domain ): bool
264
265
{
265
266
if ($ this ->internalDomains === null ) {
266
267
$ this ->internalDomains = $ this ->getInternalDomains ();
@@ -591,8 +592,9 @@ public function seeLink($text, $url = null)
591
592
$ this ->assertTrue (true );
592
593
}
593
594
594
- public function dontSeeLink ($ text , $ url = '' )
595
+ public function dontSeeLink ($ text , $ url = null )
595
596
{
597
+ $ url = (string ) $ url ;
596
598
$ crawler = $ this ->getCrawler ()->selectLink ($ text );
597
599
if (!$ url && $ crawler ->count () > 0 ) {
598
600
$ this ->fail ("Link containing text ' $ text' was found in page " . $ this ->_getCurrentUri ());
@@ -1294,10 +1296,10 @@ public function attachFile($field, $filename)
1294
1296
* Sends an ajax GET request with the passed parameters.
1295
1297
* See `sendAjaxPostRequest()`
1296
1298
*
1297
- * @param $uri
1299
+ * @param string $uri
1298
1300
* @param array $params
1299
1301
*/
1300
- public function sendAjaxGetRequest ($ uri , array $ params = []): void
1302
+ public function sendAjaxGetRequest (string $ uri , array $ params = []): void
1301
1303
{
1302
1304
$ this ->sendAjaxRequest ('GET ' , $ uri , $ params );
1303
1305
}
@@ -1339,11 +1341,11 @@ public function sendAjaxPostRequest(string $uri, array $params = []): void
1339
1341
* $I->sendAjaxRequest('PUT', '/posts/7', ['title' => 'new title']);
1340
1342
* ```
1341
1343
*
1342
- * @param $method
1343
- * @param $uri
1344
+ * @param string $method
1345
+ * @param string $uri
1344
1346
* @param array $params
1345
1347
*/
1346
- public function sendAjaxRequest ($ method , $ uri , array $ params = []): void
1348
+ public function sendAjaxRequest (string $ method , string $ uri , array $ params = []): void
1347
1349
{
1348
1350
$ this ->clientRequest ($ method , $ uri , $ params , [], ['HTTP_X_REQUESTED_WITH ' => 'XMLHttpRequest ' ], null , false );
1349
1351
}
@@ -1802,7 +1804,7 @@ protected function assertDomNotContains($nodes, string $message, string $text =
1802
1804
$ this ->assertThat ($ nodes , $ constraint , $ message );
1803
1805
}
1804
1806
1805
- protected function assertPageContains ($ needle , string $ message = '' ): void
1807
+ protected function assertPageContains (string $ needle , string $ message = '' ): void
1806
1808
{
1807
1809
$ constraint = new PageConstraint ($ needle , $ this ->_getCurrentUri ());
1808
1810
$ this ->assertThat (
@@ -1812,10 +1814,7 @@ protected function assertPageContains($needle, string $message = ''): void
1812
1814
);
1813
1815
}
1814
1816
1815
- /**
1816
- * @param string $message
1817
- */
1818
- protected function assertPageNotContains ($ needle , string $ message = '' ): void
1817
+ protected function assertPageNotContains (string $ needle , string $ message = '' ): void
1819
1818
{
1820
1819
$ constraint = new PageConstraint ($ needle , $ this ->_getCurrentUri ());
1821
1820
$ this ->assertThatItsNot (
@@ -1825,10 +1824,7 @@ protected function assertPageNotContains($needle, string $message = ''): void
1825
1824
);
1826
1825
}
1827
1826
1828
- /**
1829
- * @param string $message
1830
- */
1831
- protected function assertPageSourceContains ($ needle , string $ message = '' ): void
1827
+ protected function assertPageSourceContains (string $ needle , string $ message = '' ): void
1832
1828
{
1833
1829
$ constraint = new PageConstraint ($ needle , $ this ->_getCurrentUri ());
1834
1830
$ this ->assertThat (
@@ -1838,10 +1834,7 @@ protected function assertPageSourceContains($needle, string $message = ''): void
1838
1834
);
1839
1835
}
1840
1836
1841
- /**
1842
- * @param string $message
1843
- */
1844
- protected function assertPageSourceNotContains ($ needle , string $ message = '' ): void
1837
+ protected function assertPageSourceNotContains (string $ needle , string $ message = '' ): void
1845
1838
{
1846
1839
$ constraint = new PageConstraint ($ needle , $ this ->_getCurrentUri ());
1847
1840
$ this ->assertThatItsNot (
@@ -1872,23 +1865,15 @@ protected function matchFormField(string $name, $form, FormField $dynamicField)
1872
1865
throw new TestRuntimeException ("None of form fields by {$ name }[] were not matched " );
1873
1866
}
1874
1867
1875
- /**
1876
- * @param $locator
1877
- * @return SymfonyCrawler
1878
- */
1879
- protected function filterByCSS ($ locator ): SymfonyCrawler
1868
+ protected function filterByCSS (string $ locator ): SymfonyCrawler
1880
1869
{
1881
1870
if (!Locator::isCSS ($ locator )) {
1882
1871
throw new MalformedLocatorException ($ locator , 'css ' );
1883
1872
}
1884
1873
return $ this ->getCrawler ()->filter ($ locator );
1885
1874
}
1886
1875
1887
- /**
1888
- * @param $locator
1889
- * @return SymfonyCrawler
1890
- */
1891
- protected function filterByXPath ($ locator ): SymfonyCrawler
1876
+ protected function filterByXPath (string $ locator ): SymfonyCrawler
1892
1877
{
1893
1878
if (!Locator::isXPath ($ locator )) {
1894
1879
throw new MalformedLocatorException ($ locator , 'xpath ' );
0 commit comments