Skip to content

Commit e783f35

Browse files
committed
Update ServeControllerTest to PHPunit 9.6.
1 parent 0c8b043 commit e783f35

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

tests/framework/console/controllers/ServeControllerTest.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@
1919
*/
2020
class ServeControllerTest extends TestCase
2121
{
22-
public function setUp()
22+
public function setUp(): void
2323
{
2424
$this->mockApplication();
2525
}
2626

27-
public function testAddressTaken()
27+
public function testAddressTaken(): void
2828
{
2929
$docroot = __DIR__ . '/stub';
3030

3131
/** @var ServeController $serveController */
3232
$serveController = $this->getMockBuilder(ServeControllerMocK::className())
3333
->setConstructorArgs(['serve', Yii::$app])
34-
->setMethods(['isAddressTaken', 'runCommand'])
34+
->onlyMethods(['isAddressTaken', 'runCommand'])
3535
->getMock();
3636

3737
$serveController->expects($this->once())->method('isAddressTaken')->willReturn(true);
@@ -46,17 +46,17 @@ public function testAddressTaken()
4646

4747
$result = $serveController->flushStdOutBuffer();
4848

49-
$this->assertContains('http://localhost:8080 is taken by another process.', $result);
49+
$this->assertStringContainsString('http://localhost:8080 is taken by another process.', $result);
5050
}
5151

52-
public function testDefaultValues()
52+
public function testDefaultValues(): void
5353
{
5454
$docroot = __DIR__ . '/stub';
5555

5656
/** @var ServeController $serveController */
5757
$serveController = $this->getMockBuilder(ServeControllerMock::className())
5858
->setConstructorArgs(['serve', Yii::$app])
59-
->setMethods(['runCommand'])
59+
->onlyMethods(['runCommand'])
6060
->getMock();
6161

6262
$serveController->docroot = $docroot;
@@ -70,19 +70,19 @@ public function testDefaultValues()
7070

7171
$result = $serveController->flushStdOutBuffer();
7272

73-
$this->assertContains('Server started on http://localhost:8080', $result);
74-
$this->assertContains("Document root is \"{$docroot}\"", $result);
75-
$this->assertContains('Quit the server with CTRL-C or COMMAND-C.', $result);
73+
$this->assertStringContainsString('Server started on http://localhost:8080', $result);
74+
$this->assertStringContainsString("Document root is \"{$docroot}\"", $result);
75+
$this->assertStringContainsString('Quit the server with CTRL-C or COMMAND-C.', $result);
7676
}
7777

78-
public function testDoocRootWithNoExistValue()
78+
public function testDoocRootWithNoExistValue(): void
7979
{
8080
$docroot = '/not/exist/path';
8181

8282
/** @var ServeController $serveController */
8383
$serveController = $this->getMockBuilder(ServeControllerMock::className())
8484
->setConstructorArgs(['serve', Yii::$app])
85-
->setMethods(['runCommand'])
85+
->onlyMethods(['runCommand'])
8686
->getMock();
8787

8888
$serveController->docroot = $docroot;
@@ -95,18 +95,18 @@ public function testDoocRootWithNoExistValue()
9595

9696
$result = $serveController->flushStdOutBuffer();
9797

98-
$this->assertContains("Document root \"{$docroot}\" does not exist.", $result);
98+
$this->assertStringContainsString("Document root \"{$docroot}\" does not exist.", $result);
9999
}
100100

101-
public function testWithRouterNoExistValue()
101+
public function testWithRouterNoExistValue(): void
102102
{
103103
$docroot = __DIR__ . '/stub';
104104
$router = '/not/exist/path';
105105

106106
/** @var ServeController $serveController */
107107
$serveController = $this->getMockBuilder(ServeControllerMock::className())
108108
->setConstructorArgs(['serve', Yii::$app])
109-
->setMethods(['runCommand'])
109+
->onlyMethods(['runCommand'])
110110
->getMock();
111111

112112
$serveController->docroot = $docroot;
@@ -121,18 +121,18 @@ public function testWithRouterNoExistValue()
121121

122122
$result = $serveController->flushStdOutBuffer();
123123

124-
$this->assertContains("Routing file \"$router\" does not exist.", $result);
124+
$this->assertStringContainsString("Routing file \"$router\" does not exist.", $result);
125125
}
126126

127-
public function testWithRouterValue()
127+
public function testWithRouterValue(): void
128128
{
129129
$docroot = __DIR__ . '/stub';
130130
$router = __DIR__ . '/stub/index.php';
131131

132132
/** @var ServeController $serveController */
133133
$serveController = $this->getMockBuilder(ServeControllerMock::className())
134134
->setConstructorArgs(['serve', Yii::$app])
135-
->setMethods(['runCommand'])
135+
->onlyMethods(['runCommand'])
136136
->getMock();
137137

138138
$serveController->docroot = $docroot;
@@ -147,10 +147,10 @@ public function testWithRouterValue()
147147

148148
$result = $serveController->flushStdOutBuffer();
149149

150-
$this->assertContains('Server started on http://localhost:8081', $result);
151-
$this->assertContains("Document root is \"{$docroot}\"", $result);
152-
$this->assertContains("Routing file is \"{$router}\"", $result);
153-
$this->assertContains('Quit the server with CTRL-C or COMMAND-C.', $result);
150+
$this->assertStringContainsString('Server started on http://localhost:8081', $result);
151+
$this->assertStringContainsString("Document root is \"{$docroot}\"", $result);
152+
$this->assertStringContainsString("Routing file is \"{$router}\"", $result);
153+
$this->assertStringContainsString('Quit the server with CTRL-C or COMMAND-C.', $result);
154154
}
155155
}
156156

0 commit comments

Comments
 (0)