Commit dd8d5f57 authored by Paul Yang's avatar Paul Yang Committed by GitHub

Rename encode/decode to serializeToString/mergeFromString (#2795)

This better shows the semantic of the API. For already setted fields,
mergeFromString do replacement for singular fields and appending for
repeated fields.
parent 2b7430d9
......@@ -46,7 +46,7 @@ function doTest($request)
$response = new \Conformance\ConformanceResponse();
if ($request->getPayload() == "protobuf_payload") {
try {
$test_message->decode($request->getProtobufPayload());
$test_message->mergeFromString($request->getProtobufPayload());
} catch (Exception $e) {
$response->setParseError($e->getMessage());
return $response;
......@@ -65,7 +65,7 @@ function doTest($request)
if ($request->getRequestedOutputFormat() == WireFormat::UNSPECIFIED) {
trigger_error("Unspecified output format.", E_USER_ERROR);
} elseif ($request->getRequestedOutputFormat() == WireFormat::PROTOBUF) {
$response->setProtobufPayload($test_message->encode());
$response->setProtobufPayload($test_message->serializeToString());
} elseif ($request->getRequestedOutputFormat() == WireFormat::JSON) {
$response->setJsonPayload($test_message->jsonEncode());
}
......@@ -89,11 +89,11 @@ function doTestIO()
}
$request = new \Conformance\ConformanceRequest();
$request->decode($serialized_request);
$request->mergeFromString($serialized_request);
$response = doTest($request);
$serialized_response = $response->encode();
$serialized_response = $response->serializeToString();
fwrite(STDOUT, pack("V", strlen($serialized_response)));
fwrite(STDOUT, $serialized_response);
......
......@@ -78,9 +78,6 @@ RUN apt-get clean && apt-get update && apt-get install -y --force-yes \
# -- For C++ benchmarks --
cmake \
# -- For PHP --
php5.5 \
php5.5-dev \
php5.5-xml \
php5.6 \
php5.6-dev \
php5.6-xml \
......@@ -143,19 +140,28 @@ RUN cd /tmp && \
##################
# PHP dependencies.
RUN wget http://am1.php.net/get/php-5.5.38.tar.bz2/from/this/mirror
RUN mv mirror php-5.5.38.tar.bz2
RUN tar -xvf php-5.5.38.tar.bz2
RUN cd php-5.5.38 && ./configure --enable-maintainer-zts --prefix=/usr/local/php-5.5-zts && \
make && make install && cd ..
RUN cd php-5.5.38 && make clean && ./configure --prefix=/usr/local/php-5.5 && \
make && make install && cd ..
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
RUN php composer-setup.php
RUN mv composer.phar /usr/bin/composer
RUN php -r "unlink('composer-setup.php');"
RUN composer config -g -- disable-tls true
RUN composer config -g -- secure-http false
RUN cd /tmp && \
rm -rf protobuf && \
git clone https://github.com/google/protobuf.git && \
cd protobuf && \
git reset 46ae90dc5e145b12fffa7e053a908a9f3e066286 && \
cd php && \
ln -sfn /usr/bin/php5.5 /usr/bin/php && \
ln -sfn /usr/bin/php-config5.5 /usr/bin/php-config && \
ln -sfn /usr/bin/phpize5.5 /usr/bin/phpize && \
ln -sfn /usr/local/php-5.5/bin/php /usr/bin/php && \
ln -sfn /usr/local/php-5.5/bin/php-config /usr/bin/php-config && \
ln -sfn /usr/local/php-5.5/bin/phpize /usr/bin/phpize && \
composer install && \
mv vendor /usr/local/vendor-5.5 && \
ln -sfn /usr/bin/php5.6 /usr/bin/php && \
......@@ -168,11 +174,6 @@ RUN cd /tmp && \
ln -sfn /usr/bin/phpize7.0 /usr/bin/phpize && \
composer install && \
mv vendor /usr/local/vendor-7.0
RUN wget http://am1.php.net/get/php-5.5.38.tar.bz2/from/this/mirror
RUN mv mirror php-5.5.38.tar.bz2
RUN tar -xvf php-5.5.38.tar.bz2
RUN cd php-5.5.38 && ./configure --enable-maintainer-zts --prefix=/usr/local/php-5.5-zts && \
make && make install
##################
# Go dependencies.
......
......@@ -1234,7 +1234,7 @@ static const upb_handlers* msgdef_json_serialize_handlers(
// PHP encode/decode methods
// -----------------------------------------------------------------------------
PHP_METHOD(Message, encode) {
PHP_METHOD(Message, serializeToString) {
zval* php_descriptor = get_ce_obj(Z_OBJCE_P(getThis()));
Descriptor* desc =
(Descriptor*)zend_object_store_get_object(php_descriptor TSRMLS_CC);
......@@ -1260,7 +1260,7 @@ PHP_METHOD(Message, encode) {
}
}
PHP_METHOD(Message, decode) {
PHP_METHOD(Message, mergeFromString) {
zval* php_descriptor = get_ce_obj(Z_OBJCE_P(getThis()));
Descriptor* desc =
(Descriptor*)zend_object_store_get_object(php_descriptor TSRMLS_CC);
......
......@@ -39,8 +39,8 @@ zend_object_handlers* message_handlers;
static zend_function_entry message_methods[] = {
PHP_ME(Message, clear, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Message, encode, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Message, decode, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Message, serializeToString, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Message, mergeFromString, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Message, jsonEncode, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Message, jsonDecode, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Message, mergeFrom, NULL, ZEND_ACC_PUBLIC)
......
......@@ -267,8 +267,8 @@ PHP_METHOD(Message, __construct);
const upb_pbdecodermethod *new_fillmsg_decodermethod(Descriptor *desc,
const void *owner);
PHP_METHOD(Message, encode);
PHP_METHOD(Message, decode);
PHP_METHOD(Message, serializeToString);
PHP_METHOD(Message, mergeFromString);
PHP_METHOD(Message, jsonEncode);
PHP_METHOD(Message, jsonDecode);
......
......@@ -58,7 +58,7 @@ class DescriptorPool
public function internalAddGeneratedFile($data)
{
$files = new FileDescriptorSet();
$files->decode($data);
$files->mergeFromString($data);
$file = FileDescriptor::buildFromProto($files->getFile()[0]);
foreach ($file->getMessageType() as &$desc) {
......
......@@ -562,12 +562,14 @@ class Message
* Parses a protocol buffer contained in a string.
*
* This function takes a string in the (non-human-readable) binary wire
* format, matching the encoding output by encode().
* format, matching the encoding output by serializeToString().
* See mergeFrom() for merging behavior, if the field is already set in the
* specified message.
*
* @param string $data Binary protobuf data.
* @return bool Return true on success.
*/
public function decode($data)
public function mergeFromString($data)
{
$input = new InputStream($data);
$this->parseFromStream($input);
......@@ -714,7 +716,7 @@ class Message
* Serialize the message to string.
* @return string Serialized binary protobuf data.
*/
public function encode()
public function serializeToString()
{
$output = new OutputStream($this->byteSize());
$this->serializeToStream($output);
......
......@@ -21,7 +21,7 @@ class EncodeDecodeTest extends TestBase
$this->setFields($from);
$this->expectFields($from);
$data = $from->encode();
$data = $from->serializeToString();
$this->assertSame(bin2hex(TestUtil::getGoldenTestMessage()),
bin2hex($data));
}
......@@ -29,7 +29,7 @@ class EncodeDecodeTest extends TestBase
public function testDecode()
{
$to = new TestMessage();
$to->decode(TestUtil::getGoldenTestMessage());
$to->mergeFromString(TestUtil::getGoldenTestMessage());
$this->expectFields($to);
}
......@@ -40,10 +40,10 @@ class EncodeDecodeTest extends TestBase
$this->setFields($from);
$this->expectFields($from);
$data = $from->encode();
$data = $from->serializeToString();
$to = new TestMessage();
$to->decode($data);
$to->mergeFromString($data);
$this->expectFields($to);
}
......@@ -52,10 +52,10 @@ class EncodeDecodeTest extends TestBase
$from = new TestMessage();
$this->expectEmptyFields($from);
$data = $from->encode();
$data = $from->serializeToString();
$to = new TestMessage();
$to->decode($data);
$to->mergeFromString($data);
$this->expectEmptyFields($to);
}
......@@ -64,29 +64,29 @@ class EncodeDecodeTest extends TestBase
$m = new TestMessage();
$m->setOneofInt32(1);
$data = $m->encode();
$data = $m->serializeToString();
$n = new TestMessage();
$n->decode($data);
$n->mergeFromString($data);
$this->assertSame(1, $n->getOneofInt32());
$m->setOneofFloat(2.0);
$data = $m->encode();
$data = $m->serializeToString();
$n = new TestMessage();
$n->decode($data);
$n->mergeFromString($data);
$this->assertSame(2.0, $n->getOneofFloat());
$m->setOneofString('abc');
$data = $m->encode();
$data = $m->serializeToString();
$n = new TestMessage();
$n->decode($data);
$n->mergeFromString($data);
$this->assertSame('abc', $n->getOneofString());
$sub_m = new TestMessage_Sub();
$sub_m->setA(1);
$m->setOneofMessage($sub_m);
$data = $m->encode();
$data = $m->serializeToString();
$n = new TestMessage();
$n->decode($data);
$n->mergeFromString($data);
$this->assertSame(1, $n->getOneofMessage()->getA());
}
......@@ -95,20 +95,20 @@ class EncodeDecodeTest extends TestBase
$from = new TestPackedMessage();
TestUtil::setTestPackedMessage($from);
$this->assertSame(TestUtil::getGoldenTestPackedMessage(),
$from->encode());
$from->serializeToString());
}
public function testPackedDecodePacked()
{
$to = new TestPackedMessage();
$to->decode(TestUtil::getGoldenTestPackedMessage());
$to->mergeFromString(TestUtil::getGoldenTestPackedMessage());
TestUtil::assertTestPackedMessage($to);
}
public function testPackedDecodeUnpacked()
{
$to = new TestPackedMessage();
$to->decode(TestUtil::getGoldenTestUnpackedMessage());
$to->mergeFromString(TestUtil::getGoldenTestUnpackedMessage());
TestUtil::assertTestPackedMessage($to);
}
......@@ -117,20 +117,20 @@ class EncodeDecodeTest extends TestBase
$from = new TestUnpackedMessage();
TestUtil::setTestPackedMessage($from);
$this->assertSame(TestUtil::getGoldenTestUnpackedMessage(),
$from->encode());
$from->serializeToString());
}
public function testUnpackedDecodePacked()
{
$to = new TestUnpackedMessage();
$to->decode(TestUtil::getGoldenTestPackedMessage());
$to->mergeFromString(TestUtil::getGoldenTestPackedMessage());
TestUtil::assertTestPackedMessage($to);
}
public function testUnpackedDecodeUnpacked()
{
$to = new TestUnpackedMessage();
$to->decode(TestUtil::getGoldenTestUnpackedMessage());
$to->mergeFromString(TestUtil::getGoldenTestUnpackedMessage());
TestUtil::assertTestPackedMessage($to);
}
......@@ -161,19 +161,33 @@ class EncodeDecodeTest extends TestBase
$msg = new TestMessage();
foreach ($testVals as $original => $encoded) {
$msg->setOptionalInt64($original);
$data = $msg->encode();
$data = $msg->serializeToString();
$this->assertSame($encoded, bin2hex($data));
$msg->setOptionalInt64(0);
$msg->decode($data);
$msg->mergeFromString($data);
$this->assertEquals($original, $msg->getOptionalInt64());
}
}
public function testDecodeToExistingMessage()
{
$m1 = new TestMessage();
$this->setFields($m1);
$this->expectFields($m1);
$m2 = new TestMessage();
$this->setFields2($m2);
$data = $m2->serializeToString();
$m1->mergeFromString($data);
$this->expectFieldsMerged($m1);
}
public function testDecodeFieldNonExist()
{
$data = hex2bin('c80501');
$m = new TestMessage();
$m->decode($data);
$m->mergeFromString($data);
}
# TODO(teboring): Add test back when php implementation is ready for json
......
......@@ -22,10 +22,10 @@ $from = new TestMessage();
TestUtil::setTestMessage($from);
TestUtil::assertTestMessage($from);
$data = $from->encode();
$data = $from->serializeToString();
$to = new TestMessage();
$to->decode($data);
$to->mergeFromString($data);
TestUtil::assertTestMessage($to);
......@@ -43,9 +43,9 @@ assert(1 === $m->getOneofInt32());
assert(0.0 === $m->getOneofFloat());
assert('' === $m->getOneofString());
assert(NULL === $m->getOneofMessage());
$data = $m->encode();
$data = $m->serializeToString();
$n = new TestMessage();
$n->decode($data);
$n->mergeFromString($data);
assert(1 === $n->getOneofInt32());
$m->setOneofFloat(2.0);
......@@ -53,9 +53,9 @@ assert(0 === $m->getOneofInt32());
assert(2.0 === $m->getOneofFloat());
assert('' === $m->getOneofString());
assert(NULL === $m->getOneofMessage());
$data = $m->encode();
$data = $m->serializeToString();
$n = new TestMessage();
$n->decode($data);
$n->mergeFromString($data);
assert(2.0 === $n->getOneofFloat());
$m->setOneofString('abc');
......@@ -63,9 +63,9 @@ assert(0 === $m->getOneofInt32());
assert(0.0 === $m->getOneofFloat());
assert('abc' === $m->getOneofString());
assert(NULL === $m->getOneofMessage());
$data = $m->encode();
$data = $m->serializeToString();
$n = new TestMessage();
$n->decode($data);
$n->mergeFromString($data);
assert('abc' === $n->getOneofString());
$sub_m = new TestMessage_Sub();
......@@ -75,9 +75,9 @@ assert(0 === $m->getOneofInt32());
assert(0.0 === $m->getOneofFloat());
assert('' === $m->getOneofString());
assert(1 === $m->getOneofMessage()->getA());
$data = $m->encode();
$data = $m->serializeToString();
$n = new TestMessage();
$n->decode($data);
$n->mergeFromString($data);
assert(1 === $n->getOneofMessage()->getA());
$from = new TestMessage();
......
......@@ -290,14 +290,14 @@ class ImplementationTest extends TestBase
public function testDecode()
{
$m = new TestMessage();
$m->decode(TestUtil::getGoldenTestMessage());
$m->mergeFromString(TestUtil::getGoldenTestMessage());
TestUtil::assertTestMessage($m);
}
public function testDescriptorDecode()
{
$file_desc_set = new FileDescriptorSet();
$file_desc_set->decode(hex2bin(
$file_desc_set->mergeFromString(hex2bin(
"0a3b0a12746573745f696e636c7564652e70726f746f120362617222180a" .
"0b54657374496e636c75646512090a0161180120012805620670726f746f33"));
......
......@@ -100,6 +100,7 @@ message TestMessage {
enum TestEnum {
ZERO = 0;
ONE = 1;
TWO = 2;
}
message TestPackedMessage {
......
......@@ -12,6 +12,11 @@ class TestBase extends PHPUnit_Framework_TestCase
TestUtil::setTestMessage($m);
}
public function setFields2(TestMessage $m)
{
TestUtil::setTestMessage2($m);
}
public function expectFields(TestMessage $m)
{
$this->assertSame(-44, $m->getOptionalSint32());
......@@ -98,6 +103,139 @@ class TestBase extends PHPUnit_Framework_TestCase
$this->assertEquals(36, $m->getMapInt32Message()[1]->GetA());
}
// Test message merged from setFields and setFields2.
public function expectFieldsMerged(TestMessage $m)
{
$this->assertSame(-144, $m->getOptionalSint32());
$this->assertSame(146, $m->getOptionalFixed32());
$this->assertSame(-146, $m->getOptionalSfixed32());
$this->assertSame(11.5, $m->getOptionalFloat());
$this->assertSame(11.6, $m->getOptionalDouble());
$this->assertSame(true, $m->getOptionalBool());
$this->assertSame('aa', $m->getOptionalString());
$this->assertSame('bb', $m->getOptionalBytes());
$this->assertSame(133, $m->getOptionalMessage()->getA());
if (PHP_INT_SIZE == 4) {
$this->assertSame('-143', $m->getOptionalInt64());
$this->assertSame('143', $m->getOptionalUint64());
$this->assertSame('-145', $m->getOptionalSint64());
$this->assertSame('147', $m->getOptionalFixed64());
$this->assertSame('-147', $m->getOptionalSfixed64());
} else {
$this->assertSame(-143, $m->getOptionalInt64());
$this->assertSame(143, $m->getOptionalUint64());
$this->assertSame(-145, $m->getOptionalSint64());
$this->assertSame(147, $m->getOptionalFixed64());
$this->assertSame(-147, $m->getOptionalSfixed64());
}
$this->assertEquals(-42, $m->getRepeatedInt32()[0]);
$this->assertEquals(42, $m->getRepeatedUint32()[0]);
$this->assertEquals(-43, $m->getRepeatedInt64()[0]);
$this->assertEquals(43, $m->getRepeatedUint64()[0]);
$this->assertEquals(-44, $m->getRepeatedSint32()[0]);
$this->assertEquals(-45, $m->getRepeatedSint64()[0]);
$this->assertEquals(46, $m->getRepeatedFixed32()[0]);
$this->assertEquals(47, $m->getRepeatedFixed64()[0]);
$this->assertEquals(-46, $m->getRepeatedSfixed32()[0]);
$this->assertEquals(-47, $m->getRepeatedSfixed64()[0]);
$this->assertEquals(1.5, $m->getRepeatedFloat()[0]);
$this->assertEquals(1.6, $m->getRepeatedDouble()[0]);
$this->assertEquals(true, $m->getRepeatedBool()[0]);
$this->assertEquals('a', $m->getRepeatedString()[0]);
$this->assertEquals('b', $m->getRepeatedBytes()[0]);
$this->assertEquals(TestEnum::ZERO, $m->getRepeatedEnum()[0]);
$this->assertEquals(34, $m->getRepeatedMessage()[0]->GetA());
$this->assertEquals(-52, $m->getRepeatedInt32()[1]);
$this->assertEquals(52, $m->getRepeatedUint32()[1]);
$this->assertEquals(-53, $m->getRepeatedInt64()[1]);
$this->assertEquals(53, $m->getRepeatedUint64()[1]);
$this->assertEquals(-54, $m->getRepeatedSint32()[1]);
$this->assertEquals(-55, $m->getRepeatedSint64()[1]);
$this->assertEquals(56, $m->getRepeatedFixed32()[1]);
$this->assertEquals(57, $m->getRepeatedFixed64()[1]);
$this->assertEquals(-56, $m->getRepeatedSfixed32()[1]);
$this->assertEquals(-57, $m->getRepeatedSfixed64()[1]);
$this->assertEquals(2.5, $m->getRepeatedFloat()[1]);
$this->assertEquals(2.6, $m->getRepeatedDouble()[1]);
$this->assertEquals(false, $m->getRepeatedBool()[1]);
$this->assertEquals('c', $m->getRepeatedString()[1]);
$this->assertEquals('d', $m->getRepeatedBytes()[1]);
$this->assertEquals(TestEnum::ONE, $m->getRepeatedEnum()[1]);
$this->assertEquals(35, $m->getRepeatedMessage()[1]->GetA());
$this->assertEquals(-142, $m->getRepeatedInt32()[2]);
$this->assertEquals(142, $m->getRepeatedUint32()[2]);
$this->assertEquals(-143, $m->getRepeatedInt64()[2]);
$this->assertEquals(143, $m->getRepeatedUint64()[2]);
$this->assertEquals(-144, $m->getRepeatedSint32()[2]);
$this->assertEquals(-145, $m->getRepeatedSint64()[2]);
$this->assertEquals(146, $m->getRepeatedFixed32()[2]);
$this->assertEquals(147, $m->getRepeatedFixed64()[2]);
$this->assertEquals(-146, $m->getRepeatedSfixed32()[2]);
$this->assertEquals(-147, $m->getRepeatedSfixed64()[2]);
$this->assertEquals(11.5, $m->getRepeatedFloat()[2]);
$this->assertEquals(11.6, $m->getRepeatedDouble()[2]);
$this->assertEquals(false, $m->getRepeatedBool()[2]);
$this->assertEquals('aa', $m->getRepeatedString()[2]);
$this->assertEquals('bb', $m->getRepeatedBytes()[2]);
$this->assertEquals(TestEnum::TWO, $m->getRepeatedEnum()[2]);
$this->assertEquals(134, $m->getRepeatedMessage()[2]->GetA());
if (PHP_INT_SIZE == 4) {
$this->assertEquals('-163', $m->getMapInt64Int64()['-63']);
$this->assertEquals('163', $m->getMapUint64Uint64()['63']);
$this->assertEquals('-165', $m->getMapSint64Sint64()['-65']);
$this->assertEquals('167', $m->getMapFixed64Fixed64()['67']);
$this->assertEquals('-169', $m->getMapSfixed64Sfixed64()['-69']);
} else {
$this->assertEquals(-163, $m->getMapInt64Int64()[-63]);
$this->assertEquals(163, $m->getMapUint64Uint64()[63]);
$this->assertEquals(-165, $m->getMapSint64Sint64()[-65]);
$this->assertEquals(167, $m->getMapFixed64Fixed64()[67]);
$this->assertEquals(-169, $m->getMapSfixed64Sfixed64()[-69]);
}
$this->assertEquals(-162, $m->getMapInt32Int32()[-62]);
$this->assertEquals(162, $m->getMapUint32Uint32()[62]);
$this->assertEquals(-164, $m->getMapSint32Sint32()[-64]);
$this->assertEquals(166, $m->getMapFixed32Fixed32()[66]);
$this->assertEquals(-168, $m->getMapSfixed32Sfixed32()[-68]);
$this->assertEquals(13.5, $m->getMapInt32Float()[1]);
$this->assertEquals(13.6, $m->getMapInt32Double()[1]);
$this->assertEquals(false , $m->getMapBoolBool()[true]);
$this->assertEquals('ee', $m->getMapStringString()['e']);
$this->assertEquals('ff', $m->getMapInt32Bytes()[1]);
$this->assertEquals(TestEnum::TWO, $m->getMapInt32Enum()[1]);
$this->assertEquals(136, $m->getMapInt32Message()[1]->GetA());
if (PHP_INT_SIZE == 4) {
$this->assertEquals('-163', $m->getMapInt64Int64()['-163']);
$this->assertEquals('163', $m->getMapUint64Uint64()['163']);
$this->assertEquals('-165', $m->getMapSint64Sint64()['-165']);
$this->assertEquals('167', $m->getMapFixed64Fixed64()['167']);
$this->assertEquals('-169', $m->getMapSfixed64Sfixed64()['-169']);
} else {
$this->assertEquals(-163, $m->getMapInt64Int64()[-163]);
$this->assertEquals(163, $m->getMapUint64Uint64()[163]);
$this->assertEquals(-165, $m->getMapSint64Sint64()[-165]);
$this->assertEquals(167, $m->getMapFixed64Fixed64()[167]);
$this->assertEquals(-169, $m->getMapSfixed64Sfixed64()[-169]);
}
$this->assertEquals(-162, $m->getMapInt32Int32()[-162]);
$this->assertEquals(162, $m->getMapUint32Uint32()[162]);
$this->assertEquals(-164, $m->getMapSint32Sint32()[-164]);
$this->assertEquals(166, $m->getMapFixed32Fixed32()[166]);
$this->assertEquals(-168, $m->getMapSfixed32Sfixed32()[-168]);
$this->assertEquals(13.5, $m->getMapInt32Float()[2]);
$this->assertEquals(13.6, $m->getMapInt32Double()[2]);
$this->assertEquals(false , $m->getMapBoolBool()[false]);
$this->assertEquals('ee', $m->getMapStringString()['ee']);
$this->assertEquals('ff', $m->getMapInt32Bytes()[2]);
$this->assertEquals(TestEnum::TWO, $m->getMapInt32Enum()[2]);
$this->assertEquals(136, $m->getMapInt32Message()[2]->GetA());
}
public function expectEmptyFields(TestMessage $m)
{
$this->assertSame(0, $m->getOptionalInt32());
......
......@@ -130,6 +130,87 @@ class TestUtil
$m->getMapInt32Message()[1]->SetA(36);
}
public static function setTestMessage2(TestMessage $m)
{
$sub = new TestMessage_Sub();
$m->setOptionalInt32(-142);
$m->setOptionalInt64(-143);
$m->setOptionalUint32(142);
$m->setOptionalUint64(143);
$m->setOptionalSint32(-144);
$m->setOptionalSint64(-145);
$m->setOptionalFixed32(146);
$m->setOptionalFixed64(147);
$m->setOptionalSfixed32(-146);
$m->setOptionalSfixed64(-147);
$m->setOptionalFloat(11.5);
$m->setOptionalDouble(11.6);
$m->setOptionalBool(true);
$m->setOptionalString('aa');
$m->setOptionalBytes('bb');
$m->setOptionalEnum(TestEnum::TWO);
$m->setOptionalMessage($sub);
$m->getOptionalMessage()->SetA(133);
$m->getRepeatedInt32() []= -142;
$m->getRepeatedInt64() []= -143;
$m->getRepeatedUint32() []= 142;
$m->getRepeatedUint64() []= 143;
$m->getRepeatedSint32() []= -144;
$m->getRepeatedSint64() []= -145;
$m->getRepeatedFixed32() []= 146;
$m->getRepeatedFixed64() []= 147;
$m->getRepeatedSfixed32() []= -146;
$m->getRepeatedSfixed64() []= -147;
$m->getRepeatedFloat() []= 11.5;
$m->getRepeatedDouble() []= 11.6;
$m->getRepeatedBool() []= false;
$m->getRepeatedString() []= 'aa';
$m->getRepeatedBytes() []= 'bb';
$m->getRepeatedEnum() []= TestEnum::TWO;
$m->getRepeatedMessage() []= new TestMessage_Sub();
$m->getRepeatedMessage()[0]->setA(134);
$m->getMapInt32Int32()[-62] = -162;
$m->getMapInt64Int64()[-63] = -163;
$m->getMapUint32Uint32()[62] = 162;
$m->getMapUint64Uint64()[63] = 163;
$m->getMapSint32Sint32()[-64] = -164;
$m->getMapSint64Sint64()[-65] = -165;
$m->getMapFixed32Fixed32()[66] = 166;
$m->getMapFixed64Fixed64()[67] = 167;
$m->getMapSfixed32Sfixed32()[-68] = -168;
$m->getMapSfixed64Sfixed64()[-69] = -169;
$m->getMapInt32Float()[1] = 13.5;
$m->getMapInt32Double()[1] = 13.6;
$m->getMapBoolBool()[true] = false;
$m->getMapStringString()['e'] = 'ee';
$m->getMapInt32Bytes()[1] = 'ff';
$m->getMapInt32Enum()[1] = TestEnum::TWO;
$m->getMapInt32Message()[1] = new TestMessage_Sub();
$m->getMapInt32Message()[1]->SetA(136);
$m->getMapInt32Int32()[-162] = -162;
$m->getMapInt64Int64()[-163] = -163;
$m->getMapUint32Uint32()[162] = 162;
$m->getMapUint64Uint64()[163] = 163;
$m->getMapSint32Sint32()[-164] = -164;
$m->getMapSint64Sint64()[-165] = -165;
$m->getMapFixed32Fixed32()[166] = 166;
$m->getMapFixed64Fixed64()[167] = 167;
$m->getMapSfixed32Sfixed32()[-168] = -168;
$m->getMapSfixed64Sfixed64()[-169] = -169;
$m->getMapInt32Float()[2] = 13.5;
$m->getMapInt32Double()[2] = 13.6;
$m->getMapBoolBool()[false] = false;
$m->getMapStringString()['ee'] = 'ee';
$m->getMapInt32Bytes()[2] = 'ff';
$m->getMapInt32Enum()[2] = TestEnum::TWO;
$m->getMapInt32Message()[2] = new TestMessage_Sub();
$m->getMapInt32Message()[2]->SetA(136);
}
public static function assertTestMessage(TestMessage $m)
{
if (PHP_INT_SIZE == 4) {
......
......@@ -402,7 +402,14 @@ use_php_bc() {
}
build_php5.5() {
use_php 5.5
PHP=`which php`
PHP_CONFIG=`which php-config`
PHPIZE=`which phpize`
ln -sfn "/usr/local/php-5.5/bin/php" $PHP
ln -sfn "/usr/local/php-5.5/bin/php-config" $PHP_CONFIG
ln -sfn "/usr/local/php-5.5/bin/phpize" $PHPIZE
generate_php_test_proto
pushd php
rm -rf vendor
cp -r /usr/local/vendor-5.5 vendor
......@@ -415,7 +422,15 @@ build_php5.5() {
}
build_php5.5_c() {
use_php 5.5
PHP=`which php`
PHP_CONFIG=`which php-config`
PHPIZE=`which phpize`
ln -sfn "/usr/local/php-5.5/bin/php" $PHP
ln -sfn "/usr/local/php-5.5/bin/php-config" $PHP_CONFIG
ln -sfn "/usr/local/php-5.5/bin/phpize" $PHPIZE
generate_php_test_proto
wget https://phar.phpunit.de/phpunit-old.phar -O /usr/bin/phpunit
cd php/tests && /bin/bash ./test.sh && cd ../..
pushd conformance
make test_php_c
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment