Skip to content

Commit c37f659

Browse files
committed
标注 @expectedExceptionMessage 区分具体的异常信息
1 parent ef9c93b commit c37f659

File tree

7 files changed

+12
-2
lines changed

7 files changed

+12
-2
lines changed

tests/ApplicationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ public function testCatchExceptionEvent2()
127127

128128
/**
129129
* @expectedException \Exception
130+
* @expectedExceptionMessage Not found handler
130131
*/
131132
public function testUncatchExceptionEvent3()
132133
{
133134
$app = $this->createApplication();
134135

135-
$this->setEventManager($app, null);
136-
136+
// Router 抛出 "Not found handler" 异常
137137
$app->handle('index/notfoundxxxxxxx');
138138
}
139139

tests/ComponentTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function testInjectionAware()
4141

4242
/**
4343
* @expectedException \PHPUnit\Framework\Exception
44+
* @expectedExceptionMessageRegExp /Access to undefined property .+/
4445
*/
4546
public function testUndefinedPropertyException()
4647
{

tests/Di/ContainerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ public function testGetServiceById()
184184

185185
/**
186186
* @expectedException \Exception
187+
* @expectedExceptionMessageRegExp /Service '.+' wasn't found in the dependency injection container/
187188
*/
188189
public function testCantGetServiceById()
189190
{
@@ -274,6 +275,7 @@ public function testClosureInjectionUseThisCallOtherService()
274275

275276
/**
276277
* @expectedException \Exception
278+
* @expectedExceptionMessageRegExp /Service '.+' wasn't found in the dependency injection container/
277279
*/
278280
public function testCannotResolved()
279281
{

tests/Di/ServiceTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public function testIsShared()
8686

8787
/**
8888
* @expectedException \Exception
89+
* @expectedExceptionMessageRegExp /Service '.+' cannot be resolved/
8990
*/
9091
public function testCannotResolved()
9192
{
@@ -96,6 +97,7 @@ public function testCannotResolved()
9697

9798
/**
9899
* @expectedException \Exception
100+
* @expectedExceptionMessageRegExp /Service '.+' cannot be resolved/
99101
*/
100102
public function testResolvedCannotCase()
101103
{

tests/Events/EventManagerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public function testTriggerEmptyEvents()
6161

6262
/**
6363
* @expectedException \Exception
64+
* @expectedExceptionMessage Invalid event type
6465
*/
6566
public function testTriggerInvalidEventType()
6667
{
@@ -78,6 +79,7 @@ public function testTriggerInvalidEventType()
7879

7980
/**
8081
* @expectedException \Exception
82+
* @expectedExceptionMessage Invalid event type
8183
*/
8284
public function testTriggerInvalidEventType2()
8385
{

tests/FilterTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public function testSanitize()
6262

6363
/**
6464
* @expectedException \Exception
65+
* @expectedExceptionMessageRegExp /Sanitize filter \w+ is not supported/
6566
*/
6667
public function testInvalidArgumentException()
6768
{

tests/RouterTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public function testGetters()
8989

9090
/**
9191
* @expectedException \Exception
92+
* @expectedExceptionMessage Not found handler
9293
*/
9394
public function testNotFoundException()
9495
{
@@ -101,6 +102,7 @@ public function testNotFoundException()
101102

102103
/**
103104
* @expectedException \Exception
105+
* @expectedExceptionMessageRegExp /Method Not Allowed, allowed:.+/
104106
*/
105107
public function testMethodNotAllowedException()
106108
{

0 commit comments

Comments
 (0)