|
7 | 7 | * For the full copyright and license information, please view the LICENSE |
8 | 8 | * file that was distributed with this source code. |
9 | 9 | */ |
| 10 | +use PHPUnit\Framework\TestCase; |
| 11 | + |
10 | 12 | /** |
11 | 13 | * @runClassInSeparateProcess |
12 | 14 | */ |
13 | | -class SeparateClassRunMethodInNewProcessTest extends PHPUnit\Framework\TestCase |
| 15 | +final class SeparateClassRunMethodInNewProcessTest extends TestCase |
14 | 16 | { |
15 | 17 | public const PROCESS_ID_FILE_PATH = __DIR__ . '/parent_process_id.txt'; |
16 | 18 |
|
17 | | - public const INITIAL_MASTER_PID = 0; |
| 19 | + public const INITIAL_PARENT_PROCESS_ID = 0; |
18 | 20 |
|
19 | | - public const INITIAL_PID1 = 1; |
| 21 | + public const INITIAL_PROCESS_ID = 1; |
20 | 22 |
|
21 | | - public static $masterPid = self::INITIAL_MASTER_PID; |
| 23 | + public static $parentProcessId = self::INITIAL_PARENT_PROCESS_ID; |
22 | 24 |
|
23 | | - public static $pid1 = self::INITIAL_PID1; |
| 25 | + public static $processId = self::INITIAL_PROCESS_ID; |
24 | 26 |
|
25 | 27 | public static function setUpBeforeClass(): void |
26 | 28 | { |
27 | | - parent::setUpBeforeClass(); |
28 | | - |
29 | 29 | if (\file_exists(self::PROCESS_ID_FILE_PATH)) { |
30 | | - static::$masterPid = (int) \file_get_contents(self::PROCESS_ID_FILE_PATH); |
| 30 | + self::$parentProcessId = (int) \file_get_contents(self::PROCESS_ID_FILE_PATH); |
31 | 31 | } |
32 | 32 | } |
33 | 33 |
|
34 | 34 | public static function tearDownAfterClass(): void |
35 | 35 | { |
36 | | - parent::tearDownAfterClass(); |
37 | | - |
38 | 36 | if (\file_exists(self::PROCESS_ID_FILE_PATH)) { |
39 | 37 | \unlink(self::PROCESS_ID_FILE_PATH); |
40 | 38 | } |
41 | 39 | } |
42 | 40 |
|
43 | | - public function testMethodShouldGetDifferentPidThanMaster(): void |
| 41 | + public function testTestMethodIsRunInSeparateProcess(): void |
44 | 42 | { |
45 | | - static::$pid1 = \getmypid(); |
46 | | - |
47 | | - $this->assertNotEquals(self::INITIAL_PID1, static::$pid1); |
48 | | - $this->assertNotEquals(self::INITIAL_MASTER_PID, static::$masterPid); |
| 43 | + self::$processId = \getmypid(); |
49 | 44 |
|
50 | | - $this->assertNotEquals(static::$pid1, static::$masterPid); |
| 45 | + $this->assertNotSame(self::INITIAL_PROCESS_ID, self::$processId); |
| 46 | + $this->assertNotSame(self::INITIAL_PARENT_PROCESS_ID, self::$parentProcessId); |
| 47 | + $this->assertNotSame(self::$processId, self::$parentProcessId); |
51 | 48 | } |
52 | 49 | } |
0 commit comments