Skip to content

Commit 0186923

Browse files
committed
use composer for integratino test
1 parent da83e67 commit 0186923

File tree

10 files changed

+578
-651
lines changed

10 files changed

+578
-651
lines changed

Rakefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ task :integration do
3838
sh "sudo make install"
3939
sh "sudo cp tests/integration/php-fpm.conf ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf"
4040
sh "sudo ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm"
41-
sleep 1
4241

43-
cmd_run("$(phpenv which php) tests/integration/fcgiget.php localhost:9000/home/travis/build/chobie/php-protocolbuffers/tests/integration/test.php")
44-
cmd_run("$(phpenv which php) tests/integration/fcgiget.php localhost:9000/home/travis/build/chobie/php-protocolbuffers/tests/integration/test.php")
42+
Dir.chdir("tests/integration") do
43+
cmd_run("composer install --no-interaction")
44+
cmd_run("./vendor/bin/phpunit")
45+
end
4546
end
4647
end

tests/integration/bootstrap.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
require 'vendor/autoload.php';
3+
4+
use Adoy\FastCGI\Client;
5+
6+
7+
function fastcgi_get_contents($url)
8+
{
9+
$url = parse_url($url);
10+
if (!$url || !isset($url['path'])) {
11+
die("Malformed URI");
12+
}
13+
14+
$req = '/'.basename($url['path']);
15+
if (isset($url['query'])) {
16+
$uri = $req .'?'.$url['query'];
17+
} else {
18+
$url['query'] = '';
19+
$uri = $req;
20+
}
21+
$client = new Client(
22+
(isset($url['host']) ? $url['host'] : 'localhost'),
23+
(isset($url['port']) ? $url['port'] : 9000));
24+
25+
$params = array(
26+
'GATEWAY_INTERFACE' => 'FastCGI/1.0',
27+
'REQUEST_METHOD' => 'GET',
28+
'SCRIPT_FILENAME' => $url['path'],
29+
'SCRIPT_NAME' => $req,
30+
'QUERY_STRING' => $url['query'],
31+
'REQUEST_URI' => $uri,
32+
'DOCUMENT_URI' => $req,
33+
'SERVER_SOFTWARE' => 'php/fcgiclient',
34+
'REMOTE_ADDR' => '127.0.0.1',
35+
'REMOTE_PORT' => '9985',
36+
'SERVER_ADDR' => '127.0.0.1',
37+
'SERVER_PORT' => '80',
38+
'SERVER_NAME' => php_uname('n'),
39+
'SERVER_PROTOCOL' => 'HTTP/1.1',
40+
'CONTENT_TYPE' => '',
41+
'CONTENT_LENGTH' => 0
42+
);
43+
44+
return $client->request($params, false);
45+
}

tests/integration/composer.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"require": {
3+
"adoy/fastcgi-client": "dev-master",
4+
"phpunit/phpunit": "3.7.*"
5+
}
6+
}

0 commit comments

Comments
 (0)