Skip to content

Commit 0eae815

Browse files
committed
Merge pull request #43 from ddeboer/hhvm-webserver
Support HHVM built-in web server in listener
2 parents 4d3c414 + c57b2aa commit 0eae815

File tree

3 files changed

+45
-14
lines changed

3 files changed

+45
-14
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ before_script:
1111
- sudo apt-get update -qq
1212
- sudo apt-get install -qq varnish
1313
- sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.3' ]; then ./tests/install-apache.sh; fi"
14-
- sh -c "if [ '$TRAVIS_PHP_VERSION' = 'hhvm' ]; then ./tests/run-hhvm.sh; fi"
1514
# Install deps
1615
- composer update --dev --prefer-source
1716

tests/Functional/WebServerListener.php

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
namespace FOS\HttpCache\Tests\Functional;
44

55
/**
6-
* A PHPUnit test listener that starts and stops the PHP built-in web server
6+
* A PHPUnit test listener that starts and stops the PHP/HHVM built-in web
7+
* server
78
*
89
* This listener is configured with a couple of constants from the phpunit.xml
910
* file. To define constants in the phpunit file, use this syntax:
@@ -34,15 +35,13 @@ public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
3435
return;
3536
}
3637

37-
$command = sprintf(
38-
'php -S %s:%d -t %s >/dev/null 2>&1 & echo $!',
39-
$this->getHostName(),
40-
$this->getPort(),
41-
$this->getDocRoot()
42-
);
38+
if (defined('HHVM_VERSION')) {
39+
$pid = $this->startHhvmWebServer();
40+
} else {
41+
$pid = $this->startPhpWebServer();
42+
}
4343

44-
exec($command, $output);
45-
$this->pid = $pid = $output[0];
44+
$this->pid = $pid;
4645

4746
register_shutdown_function(function () use ($pid) {
4847
exec('kill ' . $pid);
@@ -107,4 +106,41 @@ protected function getDocRoot()
107106

108107
return WEB_SERVER_DOCROOT;
109108
}
109+
110+
/**
111+
* Start HHVM built-in web server
112+
*
113+
* @return int PID
114+
*/
115+
protected function startHhvmWebServer()
116+
{
117+
$cur = getcwd();
118+
chdir($this->getDocRoot());
119+
$command = sprintf(
120+
'hhvm -m server -p %d >/dev/null 2>&1 & echo $!',
121+
$this->getPort()
122+
);
123+
exec($command, $output);
124+
chdir($cur);
125+
126+
return $output[0];
127+
}
128+
129+
/**
130+
* Start PHP built-in web server
131+
*
132+
* @return int PID
133+
*/
134+
protected function startPhpWebServer()
135+
{
136+
$command = sprintf(
137+
'php -S %s:%d -t %s >/dev/null 2>&1 & echo $!',
138+
$this->getHostName(),
139+
$this->getPort(),
140+
$this->getDocRoot()
141+
);
142+
exec($command, $output);
143+
144+
return $output[0];
145+
}
110146
}

tests/run-hhvm.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)