|
14 | 14 | namespace Symfony\Component\Panther\Tests; |
15 | 15 |
|
16 | 16 | use PHPUnit\Framework\TestSuite; |
| 17 | +use Symfony\Component\Panther\PantherTestCase; |
17 | 18 | use Symfony\Component\Panther\ServerListener; |
18 | 19 |
|
19 | 20 | class ServerListenerTest extends TestCase |
20 | 21 | { |
21 | | - private function createTestSuite() |
| 22 | + public static function tearDownAfterClass() |
22 | 23 | { |
23 | | - $suite = $this->createMock(TestSuite::class); |
24 | | - $suite->expects($this->once())->method('getName')->willReturn('Dummy test suite'); |
25 | | - |
26 | | - return $suite; |
| 24 | + PantherTestCase::$stopServerOnTeardown = true; |
27 | 25 | } |
28 | 26 |
|
29 | 27 | public function testStartAndStop(): void |
30 | 28 | { |
31 | | - $this->expectOutputString("Starting Panther server for test suite Dummy test suite...\n\nShutting down Panther server...\n"); |
32 | | - |
33 | | - $_SERVER['PANTHER_WEB_SERVER_DIR'] = static::$webServerDir; |
34 | | - |
35 | | - $streamContext = stream_context_create(['http' => [ |
36 | | - 'ignore_errors' => true, |
37 | | - 'protocol_version' => '1.1', |
38 | | - 'header' => ['Connection: close'], |
39 | | - 'timeout' => 1, |
40 | | - ]]); |
41 | | - |
42 | | - $healthCheck = function () use ($streamContext) { |
43 | | - return @file_get_contents('http://127.0.0.1:9000', false, $streamContext); |
44 | | - }; |
45 | | - |
46 | | - $testSuite = $this->createTestSuite(); |
47 | | - |
| 29 | + $testSuite = new TestSuite(); |
48 | 30 | $listener = new ServerListener(); |
49 | | - $listener->startTestSuite($testSuite); |
50 | 31 |
|
51 | | - // Means the server rendered a 404, so server is running. |
52 | | - static::assertContains('<title>404 Not Found</title>', $healthCheck()); |
| 32 | + $listener->startTestSuite($testSuite); |
| 33 | + static::assertFalse(PantherTestCase::$stopServerOnTeardown); |
53 | 34 |
|
54 | 35 | $listener->endTestSuite($testSuite); |
55 | | - |
56 | | - // False means that ping failed. |
57 | | - static::assertFalse($healthCheck()); |
| 36 | + static::assertNull(PantherTestCase::$webServerManager); |
58 | 37 | } |
59 | 38 | } |
0 commit comments