Moving from govendor to dep, updated dependencies (#48)

* Moving from govendor to dep.

* Making the pull request template more friendly.

* Fixing akward space in PR template.

* goimports run on whole project using ` goimports -w $(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./gen-go/*")`

source of command: https://gist.github.com/bgentry/fd1ffef7dbde01857f66
This commit is contained in:
Renan DelValle 2018-01-07 13:13:47 -08:00 committed by GitHub
parent 9631aa3aab
commit 8d445c1c77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2186 changed files with 400410 additions and 352 deletions

61
vendor/git.apache.org/thrift.git/lib/php/test/Makefile.am generated vendored Executable file
View file

@ -0,0 +1,61 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
THRIFT = $(top_builddir)/compiler/cpp/thrift
stubs: ../../../test/ThriftTest.thrift TestValidators.thrift
mkdir -p ./packages
$(THRIFT) --gen php -r --out ./packages ../../../test/ThriftTest.thrift
mkdir -p ./packages/phpv
mkdir -p ./packages/phpvo
mkdir -p ./packages/phpjs
$(THRIFT) --gen php:validate -r --out ./packages/phpv TestValidators.thrift
$(THRIFT) --gen php:validate,oop -r --out ./packages/phpvo TestValidators.thrift
$(THRIFT) --gen php:json -r --out ./packages/phpjs TestValidators.thrift
check-json-serializer: stubs
if HAVE_PHPUNIT
$(PHPUNIT) --log-junit=TEST-json-serializer.xml Test/Thrift/JsonSerialize/
endif
check-validator: stubs
php Test/Thrift/TestValidators.php
php Test/Thrift/TestValidators.php -oop
check-protocol: stubs
if HAVE_PHPUNIT
$(PHPUNIT) --log-junit=TEST-log-json-protocol.xml Test/Thrift/Protocol/TestTJSONProtocol.php
$(PHPUNIT) --log-junit=TEST-binary-serializer.xml Test/Thrift/Protocol/TestBinarySerializer.php
$(PHPUNIT) --log-junit=TEST-log-simple-json-protocol.xml Test/Thrift/Protocol/TestTSimpleJSONProtocol.php
endif
check: stubs \
check-protocol \
check-validator \
check-json-serializer
clean-local:
$(RM) -r ./packages
$(RM) TEST-*.xml
EXTRA_DIST = \
Test \
TestValidators.thrift

View file

@ -0,0 +1,194 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package thrift.test
*/
namespace Test\Thrift;
use ThriftTest\Xtruct;
use ThriftTest\Xtruct2;
use ThriftTest\Numberz;
use ThriftTest\Insanity;
class Fixtures
{
public static $testArgs = array();
public static function populateTestArgs()
{
self::$testArgs['testString1'] = "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, Norsk (nynorsk), Norsk (bokmål), Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk / Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語";
self::$testArgs['testString2'] =
"quote: \\\" backslash:" .
" forwardslash-escaped: \\/ " .
" backspace: \b formfeed: \f newline: \n return: \r tab: " .
" now-all-of-them-together: \"\\\/\b\n\r\t" .
" now-a-bunch-of-junk: !@#\$%&()(&%$#{}{}<><><";
self::$testArgs['testString3'] =
"string that ends in double-backslash \\\\";
self::$testArgs['testUnicodeStringWithNonBMP'] =
"สวัสดี/𝒯";
self::$testArgs['testDouble'] = 3.1415926535898;
// TODO: add testBinary() call
self::$testArgs['testByte'] = 0x01;
self::$testArgs['testI32'] = pow( 2, 30 );
if (PHP_INT_SIZE == 8) {
self::$testArgs['testI64'] = pow( 2, 60 );
} else {
self::$testArgs['testI64'] = "1152921504606847000";
}
self::$testArgs['testStruct'] =
new Xtruct(
array(
'string_thing' => 'worked',
'byte_thing' => 0x01,
'i32_thing' => pow( 2, 30 ),
'i64_thing' => self::$testArgs['testI64']
)
);
self::$testArgs['testNestNested'] =
new Xtruct(
array(
'string_thing' => 'worked',
'byte_thing' => 0x01,
'i32_thing' => pow( 2, 30 ),
'i64_thing' => self::$testArgs['testI64']
)
);
self::$testArgs['testNest'] =
new Xtruct2(
array(
'byte_thing' => 0x01,
'struct_thing' => self::$testArgs['testNestNested'],
'i32_thing' => pow( 2, 15 )
)
);
self::$testArgs['testMap'] =
array(
7 => 77,
8 => 88,
9 => 99
);
self::$testArgs['testStringMap'] =
array(
"a" => "123",
"a b" => "with spaces ",
"same" => "same",
"0" => "numeric key",
"longValue" => self::$testArgs['testString1'],
self::$testArgs['testString1'] => "long key"
);
self::$testArgs['testSet'] = array( 1 => true, 5 => true, 6 => true );
self::$testArgs['testList'] = array( 1, 2, 3 );
self::$testArgs['testEnum'] = Numberz::ONE;
self::$testArgs['testTypedef'] = 69;
self::$testArgs['testMapMapExpectedResult'] =
array(
4 => array(
1 => 1,
2 => 2,
3 => 3,
4 => 4,
),
-4 => array(
-4 => -4,
-3 => -3,
-2 => -2,
-1 => -1
)
);
// testInsanity ... takes a few steps to set up!
$xtruct1 =
new Xtruct(
array(
'string_thing' => 'Goodbye4',
'byte_thing' => 4,
'i32_thing' => 4,
'i64_thing' => 4
)
);
$xtruct2 =
new Xtruct(
array(
'string_thing' => 'Hello2',
'byte_thing' =>2,
'i32_thing' => 2,
'i64_thing' => 2
)
);
$userMap =
array(
Numberz::FIVE => 5,
Numberz::EIGHT => 8
);
$insanity2 =
new Insanity(
array(
'userMap' => $userMap,
'xtructs' => array($xtruct1,$xtruct2)
)
);
$insanity3 = $insanity2;
$insanity6 =
new Insanity(
array(
'userMap' => null,
'xtructs' => null
)
);
self::$testArgs['testInsanityExpectedResult'] =
array(
"1" => array(
Numberz::TWO => $insanity2,
Numberz::THREE => $insanity3
),
"2" => array(
Numberz::SIX => $insanity6
)
);
}
}

View file

@ -0,0 +1,116 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
namespace Test\Thrift\JsonSerialize;
use stdClass;
use Thrift\ClassLoader\ThriftClassLoader;
require_once __DIR__.'/../../../../lib/Thrift/ClassLoader/ThriftClassLoader.php';
$loader = new ThriftClassLoader();
$loader->registerNamespace('Thrift', __DIR__ . '/../../../../lib');
$loader->registerNamespace('Test', __DIR__ . '/../../..');
$loader->registerDefinition('ThriftTest', __DIR__ . '/../../../packages/phpjs');
$loader->register();
class JsonSerializeTest extends \PHPUnit_Framework_TestCase
{
protected function setUp() {
if (version_compare(phpversion(), '5.4', '<')) {
$this->markTestSkipped('Requires PHP 5.4 or newer!');
}
}
public function testEmptyStruct()
{
$empty = new \ThriftTest\EmptyStruct(array('non_existing_key' => 'bar'));
$this->assertEquals(new stdClass(), json_decode(json_encode($empty)));
}
public function testStringsAndInts()
{
$input = array(
'string_thing' => 'foo',
'i64_thing' => 1234567890,
);
$xtruct = new \ThriftTest\Xtruct($input);
// Xtruct's 'i32_thing' and 'byte_thing' fields should not be present here!
$expected = new stdClass();
$expected->string_thing = $input['string_thing'];
$expected->i64_thing = $input['i64_thing'];
$this->assertEquals($expected, json_decode(json_encode($xtruct)));
}
public function testNestedStructs()
{
$xtruct2 = new \ThriftTest\Xtruct2(array(
'byte_thing' => 42,
'struct_thing' => new \ThriftTest\Xtruct(array(
'i32_thing' => 123456,
)),
));
$expected = new stdClass();
$expected->byte_thing = $xtruct2->byte_thing;
$expected->struct_thing = new stdClass();
$expected->struct_thing->i32_thing = $xtruct2->struct_thing->i32_thing;
$this->assertEquals($expected, json_decode(json_encode($xtruct2)));
}
public function testInsanity()
{
$xinput = array('string_thing' => 'foo');
$xtruct = new \ThriftTest\Xtruct($xinput);
$insanity = new \ThriftTest\Insanity(array(
'xtructs' => array($xtruct, $xtruct, $xtruct)
));
$expected = new stdClass();
$expected->xtructs = array((object) $xinput, (object) $xinput, (object) $xinput);
$this->assertEquals($expected, json_decode(json_encode($insanity)));
}
public function testNestedLists()
{
$bonk = new \ThriftTest\Bonk(array('message' => 'foo'));
$nested = new \ThriftTest\NestedListsBonk(array('bonk' => array(array(array($bonk)))));
$expected = new stdClass();
$expected->bonk = array(array(array((object) array('message' => 'foo'))));
$this->assertEquals($expected, json_decode(json_encode($nested)));
}
public function testMaps()
{
$intmap = new \ThriftTest\ThriftTest_testMap_args(['thing' => [0 => 'zero']]);
$emptymap = new \ThriftTest\ThriftTest_testMap_args([]);
$this->assertEquals('{"thing":{"0":"zero"}}', json_encode($intmap));
$this->assertEquals('{}', json_encode($emptymap));
}
public function testScalarTypes()
{
$b = new \ThriftTest\Bools(['im_true' => '1', 'im_false' => '0']);
$this->assertEquals('{"im_true":true,"im_false":false}', json_encode($b));
$s = new \ThriftTest\StructA(['s' => 42]);
$this->assertEquals('{"s":"42"}', json_encode($s));
}
}

View file

@ -0,0 +1,64 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package thrift.test
*/
namespace Test\Thrift\Protocol;
use Thrift\ClassLoader\ThriftClassLoader;
use Thrift\Serializer\TBinarySerializer;
require_once __DIR__.'/../../../../lib/Thrift/ClassLoader/ThriftClassLoader.php';
$loader = new ThriftClassLoader();
$loader->registerNamespace('Thrift', __DIR__ . '/../../../../lib');
$loader->registerNamespace('Test', __DIR__ . '/../../..');
$loader->registerDefinition('ThriftTest', __DIR__ . '/../../../packages');
$loader->register();
/***
* This test suite depends on running the compiler against the
* standard ThriftTest.thrift file:
*
* lib/php/test$ ../../../compiler/cpp/thrift --gen php -r \
* --out ./packages ../../../test/ThriftTest.thrift
*/
class TestBinarySerializer extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
}
/**
* We try to serialize and deserialize a random object to make sure no exceptions are thrown.
* @see THRIFT-1579
*/
public function testBinarySerializer()
{
$struct = new \ThriftTest\Xtruct(array('string_thing' => 'abc'));
$serialized = TBinarySerializer::serialize($struct, 'ThriftTest\\Xtruct');
$deserialized = TBinarySerializer::deserialize($serialized, 'ThriftTest\\Xtruct');
$this->assertEquals($struct, $deserialized);
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,156 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
namespace test\php;
require_once __DIR__.'/../../../lib/Thrift/ClassLoader/ThriftClassLoader.php';
use Thrift\ClassLoader\ThriftClassLoader;
use Thrift\Exception\TProtocolException;
use Thrift\Protocol\TBinaryProtocol;
use Thrift\Transport\TMemoryBuffer;
$oop_mode = (isset($argv[1]) && $argv[1] === '-oop');
$GEN_DIR = $oop_mode ? 'phpvo' : 'phpv';
$loader = new ThriftClassLoader();
$loader->registerNamespace('Thrift', __DIR__ . '/../../../lib');
$loader->registerDefinition('ThriftTest', __DIR__ . '/../../packages/' . $GEN_DIR);
$loader->registerDefinition('TestValidators', __DIR__ . '/../../packages/' . $GEN_DIR);
$loader->register();
// Would be nice to have PHPUnit here, but for now just hack it.
set_exception_handler(function ($e) {
my_assert(false, "Unexpected exception caught: " . $e->getMessage());
});
set_error_handler(function ($errno, $errmsg) {
my_assert(false, "Unexpected PHP error: " . $errmsg);
});
// Empty structs should not have validators
assert_has_no_read_validator('ThriftTest\EmptyStruct');
assert_has_no_write_validator('ThriftTest\EmptyStruct');
// Bonk has only opt_in_req_out fields
{
assert_has_no_read_validator('ThriftTest\Bonk');
assert_has_a_write_validator('ThriftTest\Bonk');
{
// Check that we can read an empty object
$bonk = new \ThriftTest\Bonk();
$transport = new TMemoryBuffer("\000");
$protocol = new TBinaryProtocol($transport);
$bonk->read($protocol);
}
{
// ...but not write an empty object
$bonk = new \ThriftTest\Bonk();
$transport = new TMemoryBuffer();
$protocol = new TBinaryProtocol($transport);
assert_protocol_exception_thrown(function () use ($bonk, $protocol) { $bonk->write($protocol); },
'Bonk was able to write an empty object');
}
}
// StructA has a single required field
{
assert_has_a_read_validator('ThriftTest\StructA');
assert_has_a_write_validator('ThriftTest\StructA');
{
// Check that we are not able to write StructA with a missing required field
$structa = new \ThriftTest\StructA();
$transport = new TMemoryBuffer();
$protocol = new TBinaryProtocol($transport);
assert_protocol_exception_thrown(function () use ($structa, $protocol) { $structa->write($protocol); },
'StructA was able to write an empty object');
}
{
// Check that we are able to read and write a message with a good StructA
$transport = new TMemoryBuffer(base64_decode('CwABAAAAA2FiYwA='));
$protocol = new TBinaryProtocol($transport);
$structa = new \ThriftTest\StructA();
$structa->read($protocol);
$structa->write($protocol);
}
}
// Unions should not get write validators
assert_has_no_write_validator('TestValidators\UnionOfStrings');
// Service _result classes should not get any validators
assert_has_no_read_validator('TestValidators\TestService_test_result');
assert_has_no_write_validator('TestValidators\TestService_test_result');
function assert_has_a_read_validator($class)
{
my_assert(has_read_validator_method($class),
$class . ' class should have a read validator');
}
function assert_has_no_read_validator($class)
{
my_assert(!has_read_validator_method($class),
$class . ' class should not have a read validator');
}
function assert_has_a_write_validator($class)
{
my_assert(has_write_validator_method($class),
$class . ' class should have a write validator');
}
function assert_has_no_write_validator($class)
{
my_assert(!has_write_validator_method($class),
$class . ' class should not have a write validator');
}
function assert_protocol_exception_thrown($callable, $message)
{
try {
call_user_func($callable);
my_assert(false, $message);
} catch (TProtocolException $e) {
}
}
function has_write_validator_method($class)
{
$rc = new \ReflectionClass($class);
return $rc->hasMethod('_validateForWrite');
}
function has_read_validator_method($class)
{
$rc = new \ReflectionClass($class);
return $rc->hasMethod('_validateForRead');
}
function my_assert($something, $message)
{
if (!$something) {
fwrite(STDERR, basename(__FILE__) . " FAILED: $message\n");
exit(1);
}
}

View file

@ -0,0 +1,31 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
namespace php TestValidators
include "../../../test/ThriftTest.thrift"
union UnionOfStrings {
1: string aa;
2: string bb;
}
service TestService {
void test() throws(1: ThriftTest.Xception xception);
}