Skip to content

Commit aa99005

Browse files
committed
add integratino test
1 parent 0186923 commit aa99005

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ task :test do
3333
end
3434

3535
task :integration do
36-
if ENV["TRAVIS_PHP_VERSION"].to_f > 5.3 then
36+
if ENV["TRAVIS_PHP_VERSION"].to_f >= 5.3 then
3737
sh "phpenv config-add tests/integration/protocolbuffers.ini"
3838
sh "sudo make install"
3939
sh "sudo cp tests/integration/php-fpm.conf ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf"

tests/integration/composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
"require": {
33
"adoy/fastcgi-client": "dev-master",
44
"phpunit/phpunit": "3.7.*"
5+
},
6+
"autoload": {
7+
"psr-4": {"pecl\\": "messages/pecl"}
58
}
69
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
22
require dirname(__DIR__) . DIRECTORY_SEPARATOR . "bootstrap.php";
33

4-
echo "Hello World";
4+
$user = new pecl\protocolbuffers\User();
5+
$user->setUserId(12345);
6+
$user->setName("chobie");
7+
echo $user->serializeToString();

tests/integration/tests/MultipleRequestTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ class MultipleRequestTest extends PHPUnit_Framework_TestCase
55
public function testRequest()
66
{
77
$data = fastcgi_get_contents("localhost:9000/home/travis/build/chobie/php-protocolbuffers/tests/integration/src/MultipleRequest.php");
8+
// NOTE(chobie): check segmentation fault
89
$data = fastcgi_get_contents("localhost:9000/home/travis/build/chobie/php-protocolbuffers/tests/integration/src/MultipleRequest.php");
10+
list($_, $body) = preg_split("/\r?\n/", $data, 2);
911

10-
$this->assertRegExp("/Hello/", $data);
12+
$user = \pecl\protocolbuffers\User::parseFromString($body);
13+
$this->assertInstanceOf('\pecl\protocolbuffers\User', \pecl\protocolbuffers\User);
14+
$this->assertEquals("12345", $user->getUserId());
15+
$this->assertEquals("chobie", $user->getName());
1116
}
1217
}

0 commit comments

Comments
 (0)