source: src/webservice/tests/bootstrap.php@ d55ec21

Last change on this file since d55ec21 was d55ec21, checked in by Joachim Langenbach <joachim.langenbach@…>, 11 years ago
  • Improved testing execution of webservice related tests (they use the built in php webserver to create a test webservice instance)
  • Property mode set to 100644
File size: 1.6 KB
Line 
1<?php
2/*
3 Copyright (C) 2015 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 MA 02110-1301 USA.
19
20 Followed the guide at http://tech.vg.no/2013/07/19/using-phps-built-in-web-server-in-your-test-suites/
21*/
22
23// Command that starts the built-in web server
24$command = sprintf(
25 'php -S %s:%d -t %s >/dev/null 2>&1 & echo $!',
26 WEB_SERVER_HOST,
27 WEB_SERVER_PORT,
28 WEB_SERVER_DOCROOT
29);
30
31// Execute the command and store the process ID
32$output = array();
33exec($command, $output);
34$pid = (int) $output[0];
35
36echo sprintf(
37 '%s - Web server started on %s:%d with PID %d',
38 date('r'),
39 WEB_SERVER_HOST,
40 WEB_SERVER_PORT,
41 $pid
42) . PHP_EOL;
43
44// Kill the web server when the process ends
45register_shutdown_function(function() use ($pid) {
46 echo sprintf('%s - Killing process with ID %d', date('r'), $pid) . PHP_EOL;
47 exec('kill ' . $pid);
48});
49?>
Note: See TracBrowser for help on using the repository browser.