@@ -92,7 +92,7 @@ public function testSeeIsCaseInsensitiveForUnicodeText()
9292
9393 public function testDontSeeIsCaseInsensitiveForUnicodeText ()
9494 {
95- $ this ->setExpectedException ("PHPUnit\Framework\AssertionFailedError " );
95+ $ this ->expectException ("PHPUnit\Framework\AssertionFailedError " );
9696 $ this ->module ->amOnPage ('/info ' );
9797 $ this ->module ->dontSee ('ссылочка ' );
9898 }
@@ -129,50 +129,40 @@ public function testDontSeeLink()
129129
130130 public function testSeeLinkFailsIfTextDoesNotMatch ()
131131 {
132- $ this ->setExpectedException (
133- 'PHPUnit\Framework\AssertionFailedError ' ,
134- "No links containing text 'Codeception' were found in page /external_url "
135- );
132+ $ this ->expectException ('PHPUnit\Framework\AssertionFailedError ' );
133+ $ this ->expectExceptionMessage ("No links containing text 'Codeception' were found in page /external_url " );
136134 $ this ->module ->amOnPage ('/external_url ' );
137135 $ this ->module ->seeLink ('Codeception ' );
138136 }
139137
140138 public function testSeeLinkFailsIfHrefDoesNotMatch ()
141139 {
142- $ this ->setExpectedException (
143- 'PHPUnit\Framework\AssertionFailedError ' ,
144- "No links containing text 'Next' and URL '/fsdfsdf/' were found in page /external_url "
145- );
140+ $ this ->expectException ('PHPUnit\Framework\AssertionFailedError ' );
141+ $ this ->expectExceptionMessage ("No links containing text 'Next' and URL '/fsdfsdf/' were found in page /external_url " );
146142 $ this ->module ->amOnPage ('/external_url ' );
147143 $ this ->module ->seeLink ('Next ' , '/fsdfsdf/ ' );
148144 }
149145
150146 public function testSeeLinkFailsIfHrefDoesNotMatchExactly ()
151147 {
152- $ this ->setExpectedException (
153- 'PHPUnit\Framework\AssertionFailedError ' ,
154- "No links containing text 'Next' and URL 'http://codeception' were found in page /external_url "
155- );
148+ $ this ->expectException ('PHPUnit\Framework\AssertionFailedError ' );
149+ $ this ->expectExceptionMessage ("No links containing text 'Next' and URL 'http://codeception' were found in page /external_url " );
156150 $ this ->module ->amOnPage ('/external_url ' );
157151 $ this ->module ->seeLink ('Next ' , 'http://codeception ' );
158152 }
159153
160154 public function testDontSeeLinkFailsIfTextMatches ()
161155 {
162- $ this ->setExpectedException (
163- 'PHPUnit\Framework\AssertionFailedError ' ,
164- "Link containing text 'Next' was found in page /external_url "
165- );
156+ $ this ->expectException ('PHPUnit\Framework\AssertionFailedError ' );
157+ $ this ->expectExceptionMessage ("Link containing text 'Next' was found in page /external_url " );
166158 $ this ->module ->amOnPage ('/external_url ' );
167159 $ this ->module ->dontSeeLink ('Next ' );
168160 }
169161
170162 public function testDontSeeLinkFailsIfTextAndUrlMatches ()
171163 {
172- $ this ->setExpectedException (
173- 'PHPUnit\Framework\AssertionFailedError ' ,
174- "Link containing text 'Next' and URL 'http://codeception.com/' was found in page /external_url "
175- );
164+ $ this ->expectException ('PHPUnit\Framework\AssertionFailedError ' );
165+ $ this ->expectExceptionMessage ("Link containing text 'Next' and URL 'http://codeception.com/' was found in page /external_url " );
176166 $ this ->module ->amOnPage ('/external_url ' );
177167 $ this ->module ->dontSeeLink ('Next ' , 'http://codeception.com/ ' );
178168 }
@@ -186,10 +176,8 @@ public function testSeeLinkMatchesRelativeLink()
186176
187177 public function testDontSeeLinkMatchesRelativeLink ()
188178 {
189- $ this ->setExpectedException (
190- 'PHPUnit\Framework\AssertionFailedError ' ,
191- "Link containing text 'Sign in!' and URL '/login' was found in page /info "
192- );
179+ $ this ->expectException ('PHPUnit\Framework\AssertionFailedError ' );
180+ $ this ->expectExceptionMessage ("Link containing text 'Sign in!' and URL '/login' was found in page /info " );
193181 $ this ->module ->amOnPage ('/info ' );
194182 $ this ->module ->dontSeeLink ('Sign in! ' , '/login ' );
195183 }
@@ -624,7 +612,7 @@ public function testSeeInFormFields()
624612 public function testSeeInFormFieldsFails ()
625613 {
626614 $ this ->module ->amOnPage ('/form/field_values ' );
627- $ this ->setExpectedException ("PHPUnit\Framework\AssertionFailedError " );
615+ $ this ->expectException ("PHPUnit\Framework\AssertionFailedError " );
628616 $ params = [
629617 'radio1 ' => 'something I should not see ' ,
630618 'checkbox1 ' => true ,
@@ -662,7 +650,7 @@ public function testDontSeeInFormFields()
662650 public function testDontSeeInFormFieldsFails ()
663651 {
664652 $ this ->module ->amOnPage ('/form/field_values ' );
665- $ this ->setExpectedException ("PHPUnit\Framework\AssertionFailedError " );
653+ $ this ->expectException ("PHPUnit\Framework\AssertionFailedError " );
666654 $ params = [
667655 'checkbox[] ' => [
668656 'wont see this anyway ' ,
@@ -790,7 +778,7 @@ public function testSeeElementOnPage()
790778 // regression test. https://github.com/Codeception/Codeception/issues/587
791779 public function testSeeElementOnPageFails ()
792780 {
793- $ this ->setExpectedException ("PHPUnit\Framework\AssertionFailedError " );
781+ $ this ->expectException ("PHPUnit\Framework\AssertionFailedError " );
794782 $ this ->module ->amOnPage ('/form/field ' );
795783 $ this ->module ->dontSeeElement ('input[name=name] ' );
796784 }
@@ -1210,7 +1198,7 @@ public function testSelectTwoSubmitsByCSS()
12101198
12111199 protected function shouldFail ()
12121200 {
1213- $ this ->setExpectedException ('PHPUnit\Framework\AssertionFailedError ' );
1201+ $ this ->expectException ('PHPUnit\Framework\AssertionFailedError ' );
12141202 }
12151203
12161204 /**
@@ -1354,28 +1342,28 @@ public function testSubmitFormWithButtons()
13541342 */
13551343 public function testWrongXpath ()
13561344 {
1357- $ this ->setExpectedException ('Codeception\Exception\MalformedLocatorException ' );
1345+ $ this ->expectException ('Codeception\Exception\MalformedLocatorException ' );
13581346 $ this ->module ->amOnPage ('/ ' );
13591347 $ this ->module ->seeElement ('//aas[asd}[sd]a[/[ ' );
13601348 }
13611349
13621350 public function testWrongCSS ()
13631351 {
1364- $ this ->setExpectedException ('Codeception\Exception\MalformedLocatorException ' );
1352+ $ this ->expectException ('Codeception\Exception\MalformedLocatorException ' );
13651353 $ this ->module ->amOnPage ('/ ' );
13661354 $ this ->module ->seeElement ('.user#iasos<here ' );
13671355 }
13681356
13691357 public function testWrongStrictCSSLocator ()
13701358 {
1371- $ this ->setExpectedException ('Codeception\Exception\MalformedLocatorException ' );
1359+ $ this ->expectException ('Codeception\Exception\MalformedLocatorException ' );
13721360 $ this ->module ->amOnPage ('/ ' );
13731361 $ this ->module ->seeElement (['css ' => 'hel!1$<world ' ]);
13741362 }
13751363
13761364 public function testWrongStrictXPathLocator ()
13771365 {
1378- $ this ->setExpectedException ('Codeception\Exception\MalformedLocatorException ' );
1366+ $ this ->expectException ('Codeception\Exception\MalformedLocatorException ' );
13791367 $ this ->module ->amOnPage ('/ ' );
13801368 $ this ->module ->seeElement (['xpath ' => 'hello<wo>rld ' ]);
13811369 }
@@ -1585,8 +1573,8 @@ public function testClickMultiByteLink()
15851573 */
15861574 public function testClickThrowsElementNotFoundExceptionWhenTextContainsNumber ()
15871575 {
1588- $ this ->setExpectedException ('Codeception\Exception\ElementNotFound ' ,
1589- "'Link 2' is invalid CSS and XPath selector and Link or Button element with 'name=Link 2' was not found. " );
1576+ $ this ->expectException ('Codeception\Exception\ElementNotFound ' );
1577+ $ this -> expectExceptionMessage ( "'Link 2' is invalid CSS and XPath selector and Link or Button element with 'name=Link 2' was not found. " );
15901578 $ this ->module ->amOnPage ('/info ' );
15911579 $ this ->module ->click ('Link 2 ' );
15921580 }
@@ -1707,7 +1695,8 @@ public function testAttachFileThrowsCorrectMessageWhenFileDoesNotExist()
17071695 {
17081696 $ filename = 'does-not-exist.jpg ' ;
17091697 $ expectedMessage = 'File does not exist: ' . codecept_data_dir ($ filename );
1710- $ this ->setExpectedException ('InvalidArgumentException ' , $ expectedMessage );
1698+ $ this ->expectException ('InvalidArgumentException ' );
1699+ $ this ->expectExceptionMessage ($ expectedMessage );
17111700
17121701 $ this ->module ->amOnPage ('/form/file ' );
17131702 $ this ->module ->attachFile ('Avatar ' , $ filename );
0 commit comments