@@ 29-142 (lines=114) @@ | ||
26 | * WEB_SERVER_PORT port to listen on (required) |
|
27 | * WEB_SERVER_DOCROOT path to the document root for the server (required) |
|
28 | */ |
|
29 | class WebServerListener implements \PHPUnit_Framework_TestListener |
|
30 | { |
|
31 | /** @var WebServerListenerTrait */ |
|
32 | private $trait; |
|
33 | ||
34 | public function __construct() |
|
35 | { |
|
36 | $this->trait = new WebServerListenerTrait(); |
|
37 | } |
|
38 | ||
39 | /** |
|
40 | * Make sure the PHP built-in web server is running for tests with group |
|
41 | * 'webserver'. |
|
42 | */ |
|
43 | public function startTestSuite(\PHPUnit_Framework_TestSuite $suite) |
|
44 | { |
|
45 | $this->trait->startTestSuite($suite); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * We don't need these. |
|
50 | */ |
|
51 | public function endTestSuite(\PHPUnit_Framework_TestSuite $suite) |
|
52 | { |
|
53 | } |
|
54 | ||
55 | public function addError(\PHPUnit_Framework_Test $test, \Exception $e, $time) |
|
56 | { |
|
57 | } |
|
58 | ||
59 | public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time) |
|
60 | { |
|
61 | } |
|
62 | ||
63 | public function addIncompleteTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) |
|
64 | { |
|
65 | } |
|
66 | ||
67 | public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) |
|
68 | { |
|
69 | } |
|
70 | ||
71 | public function startTest(\PHPUnit_Framework_Test $test) |
|
72 | { |
|
73 | } |
|
74 | ||
75 | public function endTest(\PHPUnit_Framework_Test $test, $time) |
|
76 | { |
|
77 | } |
|
78 | ||
79 | public function addRiskyTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) |
|
80 | { |
|
81 | } |
|
82 | ||
83 | /** |
|
84 | * Get web server hostname. |
|
85 | * |
|
86 | * @throws \Exception |
|
87 | * |
|
88 | * @return string |
|
89 | */ |
|
90 | protected function getHostName() |
|
91 | { |
|
92 | return $this->trait->getHostName(); |
|
93 | } |
|
94 | ||
95 | /** |
|
96 | * Get web server port. |
|
97 | * |
|
98 | * @throws \Exception |
|
99 | * |
|
100 | * @return int |
|
101 | */ |
|
102 | protected function getPort() |
|
103 | { |
|
104 | return $this->trait->getPort(); |
|
105 | } |
|
106 | ||
107 | /** |
|
108 | * Get web server port. |
|
109 | * |
|
110 | * @throws \Exception |
|
111 | * |
|
112 | * @return int |
|
113 | */ |
|
114 | protected function getDocRoot() |
|
115 | { |
|
116 | return $this->trait->getDocRoot(); |
|
117 | } |
|
118 | ||
119 | /** |
|
120 | * Start PHP built-in web server. |
|
121 | * |
|
122 | * @return int PID |
|
123 | */ |
|
124 | protected function startPhpWebServer() |
|
125 | { |
|
126 | return $this->trait->startPhpWebServer(); |
|
127 | } |
|
128 | ||
129 | /** |
|
130 | * Wait for caching proxy to be started up and reachable. |
|
131 | * |
|
132 | * @param string $ip |
|
133 | * @param int $port |
|
134 | * @param int $timeout Timeout in milliseconds |
|
135 | * |
|
136 | * @throws \RuntimeException If proxy is not reachable within timeout |
|
137 | */ |
|
138 | protected function waitFor($ip, $port, $timeout) |
|
139 | { |
|
140 | $this->trait->waitFor($ip, $port, $timeout); |
|
141 | } |
|
142 | } |
|
143 |
@@ 37-150 (lines=114) @@ | ||
34 | * WEB_SERVER_PORT port to listen on (required) |
|
35 | * WEB_SERVER_DOCROOT path to the document root for the server (required) |
|
36 | */ |
|
37 | class WebServerListener implements TestListener |
|
38 | { |
|
39 | /** @var WebServerListenerTrait */ |
|
40 | private $trait; |
|
41 | ||
42 | public function __construct() |
|
43 | { |
|
44 | $this->trait = new WebServerListenerTrait(); |
|
45 | } |
|
46 | ||
47 | /** |
|
48 | * Make sure the PHP built-in web server is running for tests with group |
|
49 | * 'webserver'. |
|
50 | */ |
|
51 | public function startTestSuite(TestSuite $suite) |
|
52 | { |
|
53 | $this->trait->startTestSuite($suite); |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * We don't need these. |
|
58 | */ |
|
59 | public function endTestSuite(TestSuite $suite) |
|
60 | { |
|
61 | } |
|
62 | ||
63 | public function addError(Test $test, \Exception $e, $time) |
|
64 | { |
|
65 | } |
|
66 | ||
67 | public function addFailure(Test $test, AssertionFailedError $e, $time) |
|
68 | { |
|
69 | } |
|
70 | ||
71 | public function addIncompleteTest(Test $test, \Exception $e, $time) |
|
72 | { |
|
73 | } |
|
74 | ||
75 | public function addSkippedTest(Test $test, \Exception $e, $time) |
|
76 | { |
|
77 | } |
|
78 | ||
79 | public function startTest(Test $test) |
|
80 | { |
|
81 | } |
|
82 | ||
83 | public function endTest(Test $test, $time) |
|
84 | { |
|
85 | } |
|
86 | ||
87 | public function addRiskyTest(Test $test, \Exception $e, $time) |
|
88 | { |
|
89 | } |
|
90 | ||
91 | /** |
|
92 | * Get web server hostname. |
|
93 | * |
|
94 | * @throws \Exception |
|
95 | * |
|
96 | * @return string |
|
97 | */ |
|
98 | protected function getHostName() |
|
99 | { |
|
100 | return $this->trait->getHostName(); |
|
101 | } |
|
102 | ||
103 | /** |
|
104 | * Get web server port. |
|
105 | * |
|
106 | * @throws \Exception |
|
107 | * |
|
108 | * @return int |
|
109 | */ |
|
110 | protected function getPort() |
|
111 | { |
|
112 | return $this->trait->getPort(); |
|
113 | } |
|
114 | ||
115 | /** |
|
116 | * Get web server port. |
|
117 | * |
|
118 | * @throws \Exception |
|
119 | * |
|
120 | * @return int |
|
121 | */ |
|
122 | protected function getDocRoot() |
|
123 | { |
|
124 | return $this->trait->getDocRoot(); |
|
125 | } |
|
126 | ||
127 | /** |
|
128 | * Start PHP built-in web server. |
|
129 | * |
|
130 | * @return int PID |
|
131 | */ |
|
132 | protected function startPhpWebServer() |
|
133 | { |
|
134 | return $this->trait->startPhpWebServer(); |
|
135 | } |
|
136 | ||
137 | /** |
|
138 | * Wait for caching proxy to be started up and reachable. |
|
139 | * |
|
140 | * @param string $ip |
|
141 | * @param int $port |
|
142 | * @param int $timeout Timeout in milliseconds |
|
143 | * |
|
144 | * @throws \RuntimeException If proxy is not reachable within timeout |
|
145 | */ |
|
146 | protected function waitFor($ip, $port, $timeout) |
|
147 | { |
|
148 | $this->trait->waitFor($ip, $port, $timeout); |
|
149 | } |
|
150 | } |
|
151 | } |
|
152 |