-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathIsRunningTraitTest.php
More file actions
41 lines (32 loc) · 1010 Bytes
/
IsRunningTraitTest.php
File metadata and controls
41 lines (32 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
declare(strict_types=1);
namespace QueueTest\Swoole\Command;
use PHPUnit\Framework\MockObject\Exception;
use PHPUnit\Framework\TestCase;
use Queue\Swoole\Command\IsRunningTrait;
use Queue\Swoole\PidManager;
class IsRunningTraitTest extends TestCase
{
private object $traitUser;
/**
* @throws Exception
*/
protected function setUp(): void
{
$this->traitUser = new class {
use IsRunningTrait;
public PidManager $pidManager;
};
$this->traitUser->pidManager = $this->createMock(PidManager::class);
}
public function testIsRunningReturnsFalseWhenNoPids(): void
{
$this->traitUser->pidManager->method('read')->willReturn([]);
$this->assertFalse($this->traitUser->isRunning());
}
public function testIsRunningReturnsFalseWhenPidsAreZero(): void
{
$this->traitUser->pidManager->method('read')->willReturn([0, 0]);
$this->assertFalse($this->traitUser->isRunning());
}
}