Skip to content

Commit 59a7f4e

Browse files
committed
skip tests if swoole ext is missing
Signed-off-by: bota <[email protected]>
1 parent 711e4cd commit 59a7f4e

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

test/Swoole/Command/Factory/StopCommandFactoryTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ class StopCommandFactoryTest extends TestCase
1818
*/
1919
public function testFactoryReturnsStopCommandInstance(): void
2020
{
21+
if (! \extension_loaded('swoole')) {
22+
$this->markTestSkipped('Swoole extension not loaded.');
23+
}
24+
2125
$pidManager = $this->createMock(PidManager::class);
2226

2327
$container = $this->createMock(ContainerInterface::class);

test/Swoole/Command/StartCommandTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ class StartCommandTest extends TestCase
2222
*/
2323
public function testExecuteWhenServerIsNotRunning(): void
2424
{
25+
if (! \extension_loaded('swoole')) {
26+
$this->markTestSkipped('Swoole extension not loaded.');
27+
}
28+
2529
$input = $this->createMock(InputInterface::class);
2630
$output = $this->createMock(OutputInterface::class);
2731
$pidManager = $this->createMock(PidManager::class);

test/Swoole/Command/StopCommandTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ class StopCommandTest extends TestCase
1717
*/
1818
public function testExecuteWhenServerIsNotRunning(): void
1919
{
20+
if (! \extension_loaded('swoole')) {
21+
$this->markTestSkipped('Swoole extension not loaded.');
22+
}
23+
2024
$pidManager = $this->createMock(PidManager::class);
2125

2226
$command = $this->getMockBuilder(StopCommand::class)
@@ -38,6 +42,10 @@ public function testExecuteWhenServerIsNotRunning(): void
3842
*/
3943
public function testExecuteWhenServerStopsSuccessfully(): void
4044
{
45+
if (! \extension_loaded('swoole')) {
46+
$this->markTestSkipped('Swoole extension not loaded.');
47+
}
48+
4149
$pidManager = $this->createMock(PidManager::class);
4250
$pidManager->method('read')->willReturn(['1234']);
4351
$pidManager->expects($this->once())->method('delete');
@@ -65,6 +73,10 @@ public function testExecuteWhenServerStopsSuccessfully(): void
6573
*/
6674
public function testExecuteWhenServerFailsToStop(): void
6775
{
76+
if (! \extension_loaded('swoole')) {
77+
$this->markTestSkipped('Swoole extension not loaded.');
78+
}
79+
6880
$pidManager = $this->createMock(PidManager::class);
6981
$pidManager->method('read')->willReturn(['1234']);
7082
$pidManager->expects($this->never())->method('delete');

test/Swoole/ServerFactoryTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ public function testInvokeWithCustomValidConfig(): void
9090
*/
9191
public function testThrowsOnInvalidPort(): void
9292
{
93+
if (! \extension_loaded('swoole')) {
94+
$this->markTestSkipped('Swoole extension not loaded.');
95+
}
96+
9397
$this->expectException(InvalidArgumentException::class);
9498
$this->expectExceptionMessage('Invalid port');
9599

@@ -112,6 +116,10 @@ public function testThrowsOnInvalidPort(): void
112116
*/
113117
public function testThrowsOnInvalidMode(): void
114118
{
119+
if (! \extension_loaded('swoole')) {
120+
$this->markTestSkipped('Swoole extension not loaded.');
121+
}
122+
115123
$this->expectException(InvalidArgumentException::class);
116124
$this->expectExceptionMessage('Invalid server mode');
117125

@@ -134,6 +142,10 @@ public function testThrowsOnInvalidMode(): void
134142
*/
135143
public function testThrowsOnInvalidProtocol(): void
136144
{
145+
if (! \extension_loaded('swoole')) {
146+
$this->markTestSkipped('Swoole extension not loaded.');
147+
}
148+
137149
$this->expectException(InvalidArgumentException::class);
138150
$this->expectExceptionMessage('Invalid server protocol');
139151

0 commit comments

Comments
 (0)