Updated and simplified PHP testing structure (#8558)
* Simplified PHP testing setup. - Consolidated on a single autoloader, created by composer. - Consolidated on a single phpunit invocation strategy: we run phpunit on a directory, which will run all tests matching *Test.php in that directory. - We now rely on autoloading to import all test protos. require_once() calls for test protos are removed. - For now the valgrind tests are removed. A follow-up PR will re-enable them in a more robust way. * More improvements to PHP testing. 1. Replace custom PHPUnit-selection logic in test.sh with generic composer version selection. 2. Optimized both test proto generation and the custom extension build to avoid unnecessary work when the files are already up to date. * Added assertions to verify that the C test doesn't use PHP sources. * Updated tests.sh for the new PHP testing commands. * Removed obsolete rules from tests.sh. * Fixed generate_test_protos.sh for when tmp does not exist. Also removed undefined_test.php and fixed Makefile.am. * Added php8.0_all again which is still used. * Added missing file to Makefile.am. * Re-added php_all_32 rule which is also still used. * Updated testing commands for macOS and download composer. * Use /usr/local/bin on mac instead of /usr/bin, since the latter is not writable.pull/8566/head
parent
114efc42d4
commit
8b87075924
17 changed files with 105 additions and 1313 deletions
@ -0,0 +1,27 @@ |
||||
#!/bin/bash |
||||
|
||||
set -e |
||||
|
||||
cd `dirname $0` |
||||
|
||||
if [[ -d tmp && -z $(find tests/proto ../src/protoc -newer tmp) ]]; then |
||||
# Generated protos are already present and up to date, so we can skip protoc. |
||||
# |
||||
# Protoc is very fast, but sometimes it is not available (like if we haven't |
||||
# built it in Docker). Skipping it helps us proceed in this case. |
||||
echo "Test protos are up-to-date, skipping protoc." |
||||
exit 0 |
||||
fi |
||||
|
||||
rm -rf tmp |
||||
mkdir -p tmp |
||||
|
||||
find tests/proto -type f -name "*.proto"| xargs ../src/protoc --php_out=tmp -I../src -Itests |
||||
|
||||
if [ "$1" = "--aggregate_metadata" ]; then |
||||
# Overwrite some of the files to use aggregation. |
||||
AGGREGATED_FILES="tests/proto/test.proto tests/proto/test_include.proto tests/proto/test_import_descriptor_proto.proto" |
||||
../src/protoc --php_out=aggregate_metadata=foo#bar:tmp -I../src -Itests $AGGREGATED_FILES |
||||
fi |
||||
|
||||
echo "Generated test protos from tests/proto -> tmp" |
@ -1,18 +0,0 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<phpunit bootstrap="./tests/bootstrap_phpunit.php" |
||||
colors="true"> |
||||
<testsuites> |
||||
<testsuite name="protobuf-tests"> |
||||
<file>tests/PhpImplementationTest.php</file> |
||||
<file>tests/ArrayTest.php</file> |
||||
<file>tests/EncodeDecodeTest.php</file> |
||||
<file>tests/GeneratedClassTest.php</file> |
||||
<file>tests/GeneratedPhpdocTest.php</file> |
||||
<file>tests/MapFieldTest.php</file> |
||||
<file>tests/WellKnownTest.php</file> |
||||
<file>tests/DescriptorsTest.php</file> |
||||
<file>tests/GeneratedServiceTest.php</file> |
||||
<file>tests/WrapperTypeSettersTest.php</file> |
||||
</testsuite> |
||||
</testsuites> |
||||
</phpunit> |
@ -1,27 +0,0 @@ |
||||
<?php |
||||
|
||||
error_reporting(E_ALL); |
||||
|
||||
function getGeneratedFiles($dir, &$results = array()) |
||||
{ |
||||
$files = scandir($dir); |
||||
|
||||
foreach ($files as $key => $value) { |
||||
$path = realpath($dir.DIRECTORY_SEPARATOR.$value); |
||||
if (!is_dir($path)) { |
||||
$results[] = $path; |
||||
} else if ($value != "." && $value != "..") { |
||||
getGeneratedFiles($path, $results); |
||||
} |
||||
} |
||||
return $results; |
||||
} |
||||
|
||||
foreach (getGeneratedFiles("generated") as $filename) |
||||
{ |
||||
if (!is_dir($filename)) { |
||||
include_once $filename; |
||||
} |
||||
|
||||
} |
||||
|
@ -1,5 +0,0 @@ |
||||
<?php |
||||
|
||||
require_once("vendor/autoload.php"); |
||||
|
||||
error_reporting(E_ALL); |
@ -1,20 +1,26 @@ |
||||
#!/bin/bash |
||||
|
||||
set -ex |
||||
set -e |
||||
|
||||
cd $(dirname $0) |
||||
|
||||
../prepare_c_extension.sh |
||||
pushd ../ext/google/protobuf |
||||
pushd ../ext/google/protobuf > /dev/null |
||||
|
||||
CONFIGURE_OPTIONS=("./configure" "--with-php-config=$(which php-config)") |
||||
|
||||
if [ "$1" != "--release" ]; then |
||||
CONFIGURE_OPTIONS+=("CFLAGS=-g -O0 -Wall") |
||||
fi |
||||
|
||||
# If the PHP interpreter we are building against or the arguments |
||||
# have changed, we must regenerated the Makefile. |
||||
if [[ ! -f Makefile ]] || [[ "$(grep ' \$ ./configure' config.log)" != " $ ${CONFIGURE_OPTIONS[@]}" ]]; then |
||||
phpize --clean |
||||
rm -f configure.in configure.ac |
||||
phpize |
||||
if [ "$1" = "--release" ]; then |
||||
./configure --with-php-config=$(which php-config) |
||||
else |
||||
# To get debugging symbols in PHP itself, build PHP with: |
||||
# $ ./configure --enable-debug CFLAGS='-g -O0' |
||||
./configure --with-php-config=$(which php-config) CFLAGS="-g -O0 -Wall" |
||||
"${CONFIGURE_OPTIONS[@]}" |
||||
fi |
||||
|
||||
make |
||||
popd |
||||
popd > /dev/null |
||||
|
@ -0,0 +1,14 @@ |
||||
<?php |
||||
|
||||
// We have to test this because the command-line argument will fail silently |
||||
// if the extension could not be loaded: |
||||
// php -dextension=ext/google/protobuf/modules/protouf.so |
||||
if (!extension_loaded("protobuf")) { |
||||
throw new Exception("Protobuf extension not loaded"); |
||||
} |
||||
|
||||
spl_autoload_register(function($class) { |
||||
if (strpos($class, "Google\\Protobuf") === 0) { |
||||
throw new Exception("When using the C extension, we should not load runtime class: " . $class); |
||||
} |
||||
}, true, true); |
@ -1,16 +0,0 @@ |
||||
#!/bin/bash |
||||
|
||||
set -ex |
||||
|
||||
cd `dirname $0` |
||||
|
||||
rm -rf generated |
||||
mkdir -p generated |
||||
|
||||
find proto -type f -name "*.proto"| xargs ../../src/protoc --experimental_allow_proto3_optional --php_out=generated -I../../src -I. |
||||
|
||||
if [ "$1" = "--aggregate_metadata" ]; then |
||||
# Overwrite some of the files to use aggregation. |
||||
AGGREGATED_FILES="proto/test.proto proto/test_include.proto proto/test_import_descriptor_proto.proto" |
||||
../../src/protoc --experimental_allow_proto3_optional --php_out=aggregate_metadata=foo#bar:generated -I../../src -I. $AGGREGATED_FILES |
||||
fi |
@ -1,72 +0,0 @@ |
||||
#!/bin/bash |
||||
|
||||
set -ex |
||||
|
||||
cd $(dirname $0) |
||||
|
||||
./generate_protos.sh |
||||
./compile_extension.sh |
||||
|
||||
PHP_VERSION=$(php -r "echo PHP_VERSION;") |
||||
|
||||
# Each version of PHPUnit supports a fairly narrow range of PHP versions. |
||||
case "$PHP_VERSION" in |
||||
7.0.*) |
||||
PHPUNIT=phpunit-6.phar |
||||
;; |
||||
7.1.*|7.2.*) |
||||
PHPUNIT=phpunit-7.5.0.phar |
||||
;; |
||||
7.3.*|7.4.*) |
||||
PHPUNIT=phpunit-8.phar |
||||
;; |
||||
8.0.*) |
||||
PHPUNIT=phpunit-9.phar |
||||
;; |
||||
*) |
||||
echo "ERROR: Unsupported PHP version $PHP_VERSION" |
||||
exit 1 |
||||
;; |
||||
esac |
||||
|
||||
[ -f $PHPUNIT ] || wget https://phar.phpunit.de/$PHPUNIT |
||||
|
||||
tests=( ArrayTest.php EncodeDecodeTest.php GeneratedClassTest.php MapFieldTest.php WellKnownTest.php DescriptorsTest.php WrapperTypeSettersTest.php) |
||||
|
||||
for t in "${tests[@]}" |
||||
do |
||||
echo "****************************" |
||||
echo "* $t" |
||||
echo "****************************" |
||||
php -dextension=../ext/google/protobuf/modules/protobuf.so $PHPUNIT --bootstrap autoload.php $t |
||||
echo "" |
||||
done |
||||
|
||||
for t in "${tests[@]}" |
||||
do |
||||
echo "****************************" |
||||
echo "* $t persistent" |
||||
echo "****************************" |
||||
php -d protobuf.keep_descriptor_pool_after_request=1 -dextension=../ext/google/protobuf/modules/protobuf.so $PHPUNIT --bootstrap autoload.php $t |
||||
echo "" |
||||
done |
||||
|
||||
# # Make sure to run the memory test in debug mode. |
||||
# php -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php |
||||
|
||||
export ZEND_DONT_UNLOAD_MODULES=1 |
||||
export USE_ZEND_ALLOC=0 |
||||
valgrind --suppressions=valgrind.supp --leak-check=yes php -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php |
||||
valgrind --suppressions=valgrind.supp --leak-check=yes php -d protobuf.keep_descriptor_pool_after_request=1 -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php |
||||
|
||||
# TODO(teboring): Only for debug (phpunit has memory leak which blocks this beging used by |
||||
# regression test.) |
||||
|
||||
# for t in "${tests[@]}" |
||||
# do |
||||
# echo "****************************" |
||||
# echo "* $t (memory leak)" |
||||
# echo "****************************" |
||||
# valgrind --leak-check=yes php -dextension=../ext/google/protobuf/modules/protobuf.so $PHPUNIT --bootstrap autoload.php $t |
||||
# echo "" |
||||
# done |
@ -1,920 +0,0 @@ |
||||
<?php |
||||
|
||||
require_once('test_util.php'); |
||||
|
||||
use Google\Protobuf\Internal\RepeatedField; |
||||
use Google\Protobuf\Internal\GPBType; |
||||
use Foo\TestMessage; |
||||
use Foo\TestMessage\Sub; |
||||
|
||||
class UndefinedTest extends PHPUnit_Framework_TestCase |
||||
{ |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testInt32AppendStringFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::INT32); |
||||
$arr[] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testInt32SetStringFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::INT32); |
||||
$arr[] = 0; |
||||
$arr[0] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testInt32AppendMessageFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::INT32); |
||||
$arr[] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testInt32SetMessageFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::INT32); |
||||
$arr[] = 0; |
||||
$arr[0] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testUint32AppendStringFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::UINT32); |
||||
$arr[] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testUint32SetStringFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::UINT32); |
||||
$arr[] = 0; |
||||
$arr[0] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testUint32AppendMessageFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::UINT32); |
||||
$arr[] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testUint32SetMessageFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::UINT32); |
||||
$arr[] = 0; |
||||
$arr[0] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testInt64AppendStringFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::INT64); |
||||
$arr[] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testInt64SetStringFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::INT64); |
||||
$arr[] = 0; |
||||
$arr[0] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testInt64AppendMessageFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::INT64); |
||||
$arr[] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testInt64SetMessageFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::INT64); |
||||
$arr[] = 0; |
||||
$arr[0] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testUint64AppendStringFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::UINT64); |
||||
$arr[] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testUint64SetStringFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::UINT64); |
||||
$arr[] = 0; |
||||
$arr[0] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testUint64AppendMessageFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::UINT64); |
||||
$arr[] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testUint64SetMessageFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::UINT64); |
||||
$arr[] = 0; |
||||
$arr[0] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testFloatAppendStringFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::FLOAT); |
||||
$arr[] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testFloatSetStringFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::FLOAT); |
||||
$arr[] = 0.0; |
||||
$arr[0] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testFloatAppendMessageFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::FLOAT); |
||||
$arr[] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testFloatSetMessageFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::FLOAT); |
||||
$arr[] = 0.0; |
||||
$arr[0] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testDoubleAppendStringFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::DOUBLE); |
||||
$arr[] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testDoubleSetStringFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::DOUBLE); |
||||
$arr[] = 0.0; |
||||
$arr[0] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testDoubleAppendMessageFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::DOUBLE); |
||||
$arr[] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testDoubleSetMessageFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::DOUBLE); |
||||
$arr[] = 0.0; |
||||
$arr[0] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testBoolAppendMessageFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::BOOL); |
||||
$arr[] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testBoolSetMessageFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::BOOL); |
||||
$arr[] = true; |
||||
$arr[0] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testStringAppendMessageFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::STRING); |
||||
$arr[] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testStringSetMessageFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::STRING); |
||||
$arr[] = 'abc'; |
||||
$arr[0] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testStringAppendInvalidUTF8Fail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::STRING); |
||||
$hex = hex2bin("ff"); |
||||
$arr[] = $hex; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testStringSetInvalidUTF8Fail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::STRING); |
||||
$arr[] = 'abc'; |
||||
$hex = hex2bin("ff"); |
||||
$arr[0] = $hex; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testMessageAppendIntFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::MESSAGE, Sub::class); |
||||
$arr[] = 1; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testMessageSetIntFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::MESSAGE, Sub::class); |
||||
$arr[] = new Sub; |
||||
$arr[0] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testMessageAppendStringFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::MESSAGE, Sub::class); |
||||
$arr[] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testMessageSetStringFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::MESSAGE, Sub::class); |
||||
$arr[] = new Sub; |
||||
$arr[0] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testMessageAppendOtherMessageFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::MESSAGE, Sub::class); |
||||
$arr[] = new TestMessage; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testMessageAppendNullFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::MESSAGE, Sub::class); |
||||
$null = null; |
||||
$arr[] = $null; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testMessageSetNullFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::MESSAGE, Sub::class); |
||||
$arr[] = new Sub(); |
||||
$null = null; |
||||
$arr[0] = $null; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testRemoveMiddleFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::INT32); |
||||
|
||||
$arr[] = 0; |
||||
$arr[] = 1; |
||||
$arr[] = 2; |
||||
$this->assertSame(3, count($arr)); |
||||
|
||||
unset($arr[1]); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testRemoveEmptyFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::INT32); |
||||
|
||||
unset($arr[0]); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testMessageOffsetFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::INT32); |
||||
$arr[] = 0; |
||||
$arr[new Sub()] = 0; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testStringOffsetFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::INT32); |
||||
$arr[] = 0; |
||||
$arr['abc'] = 0; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testSetNonExistedOffsetFail() |
||||
{ |
||||
$arr = new RepeatedField(GPBType::INT32); |
||||
$arr[0] = 0; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testInt32FieldInvalidTypeFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
$m->setOptionalInt32(new TestMessage()); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testInt32FieldInvalidStringFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
$m->setOptionalInt32('abc'); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testUint32FieldInvalidTypeFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
$m->setOptionalUint32(new TestMessage()); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testUint32FieldInvalidStringFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
$m->setOptionalUint32('abc'); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testInt64FieldInvalidTypeFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
$m->setOptionalInt64(new TestMessage()); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testInt64FieldInvalidStringFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
$m->setOptionalInt64('abc'); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testUint64FieldInvalidTypeFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
$m->setOptionalUint64(new TestMessage()); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testUint64FieldInvalidStringFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
$m->setOptionalUint64('abc'); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testFloatFieldInvalidTypeFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
$m->setOptionalFloat(new TestMessage()); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testFloatFieldInvalidStringFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
$m->setOptionalFloat('abc'); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testDoubleFieldInvalidTypeFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
$m->setOptionalDouble(new TestMessage()); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testDoubleFieldInvalidStringFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
$m->setOptionalDouble('abc'); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testBoolFieldInvalidStringFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
$m->setOptionalBool(new TestMessage()); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testStringFieldInvalidUTF8Fail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
$hex = hex2bin("ff"); |
||||
$m->setOptionalString($hex); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testMessageFieldWrongTypeFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
$a = 1; |
||||
$m->setOptionalMessage($a); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testMessageFieldWrongClassFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
$m->setOptionalMessage(new TestMessage()); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testRepeatedFieldWrongTypeFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
$a = 1; |
||||
$m->setRepeatedInt32($a); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testRepeatedFieldWrongObjectFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
$m->setRepeatedInt32($m); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testRepeatedFieldWrongRepeatedTypeFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
|
||||
$repeated_int32 = new RepeatedField(GPBType::UINT32); |
||||
$m->setRepeatedInt32($repeated_int32); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testRepeatedFieldWrongRepeatedMessageClassFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
|
||||
$repeated_message = new RepeatedField(GPBType::MESSAGE, |
||||
TestMessage::class); |
||||
$m->setRepeatedMessage($repeated_message); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testMapFieldWrongTypeFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
$a = 1; |
||||
$m->setMapInt32Int32($a); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testMapFieldWrongObjectFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
$m->setMapInt32Int32($m); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testMapFieldWrongRepeatedTypeFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
|
||||
$map_uint32_uint32 = new MapField(GPBType::UINT32, GPBType::UINT32); |
||||
$m->setMapInt32Int32($map_uint32_uint32); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testMapFieldWrongRepeatedMessageClassFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
|
||||
$map_int32_message = new MapField(GPBType::INT32, |
||||
GPBType::MESSAGE, |
||||
TestMessage::class); |
||||
$m->setMapInt32Message($map_int32_message); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testMessageMergeFromInvalidTypeFail() |
||||
{ |
||||
$m = new TestMessage(); |
||||
$n = new Sub(); |
||||
$m->mergeFrom($n); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testInt32SetStringKeyFail() |
||||
{ |
||||
$arr = new MapField(GPBType::INT32, GPBType::INT32); |
||||
$arr['abc'] = 0; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testInt32SetStringValueFail() |
||||
{ |
||||
$arr = new MapField(GPBType::INT32, GPBType::INT32); |
||||
$arr[0] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testInt32SetMessageKeyFail() |
||||
{ |
||||
$arr = new MapField(GPBType::INT32, GPBType::INT32); |
||||
$arr[new Sub()] = 0; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testInt32SetMessageValueFail() |
||||
{ |
||||
$arr = new MapField(GPBType::INT32, GPBType::INT32); |
||||
$arr[0] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testUint32SetStringKeyFail() |
||||
{ |
||||
$arr = new MapField(GPBType::UINT32, GPBType::UINT32); |
||||
$arr['abc'] = 0; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testUint32SetStringValueFail() |
||||
{ |
||||
$arr = new MapField(GPBType::UINT32, GPBType::UINT32); |
||||
$arr[0] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testUint32SetMessageKeyFail() |
||||
{ |
||||
$arr = new MapField(GPBType::UINT32, GPBType::UINT32); |
||||
$arr[new Sub()] = 0; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testUint32SetMessageValueFail() |
||||
{ |
||||
$arr = new MapField(GPBType::UINT32, GPBType::UINT32); |
||||
$arr[0] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testInt64SetStringKeyFail() |
||||
{ |
||||
$arr = new MapField(GPBType::INT64, GPBType::INT64); |
||||
$arr['abc'] = 0; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testInt64SetStringValueFail() |
||||
{ |
||||
$arr = new MapField(GPBType::INT64, GPBType::INT64); |
||||
$arr[0] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testInt64SetMessageKeyFail() |
||||
{ |
||||
$arr = new MapField(GPBType::INT64, GPBType::INT64); |
||||
$arr[new Sub()] = 0; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testInt64SetMessageValueFail() |
||||
{ |
||||
$arr = new MapField(GPBType::INT64, GPBType::INT64); |
||||
$arr[0] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testUint64SetStringKeyFail() |
||||
{ |
||||
$arr = new MapField(GPBType::UINT64, GPBType::UINT64); |
||||
$arr['abc'] = 0; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testUint64SetStringValueFail() |
||||
{ |
||||
$arr = new MapField(GPBType::UINT64, GPBType::UINT64); |
||||
$arr[0] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testUint64SetMessageKeyFail() |
||||
{ |
||||
$arr = new MapField(GPBType::UINT64, GPBType::UINT64); |
||||
$arr[new Sub()] = 0; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testUint64SetMessageValueFail() |
||||
{ |
||||
$arr = new MapField(GPBType::UINT64, GPBType::UINT64); |
||||
$arr[0] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testDoubleSetStringValueFail() |
||||
{ |
||||
$arr = new MapField(GPBType::INT64, GPBType::DOUBLE); |
||||
$arr[0] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testDoubleSetMessageValueFail() |
||||
{ |
||||
$arr = new MapField(GPBType::INT64, GPBType::DOUBLE); |
||||
$arr[0] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testBoolSetMessageKeyFail() |
||||
{ |
||||
$arr = new MapField(GPBType::BOOL, GPBType::BOOL); |
||||
$arr[new Sub()] = true; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testBoolSetMessageValueFail() |
||||
{ |
||||
$arr = new MapField(GPBType::BOOL, GPBType::BOOL); |
||||
$arr[true] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testStringSetInvalidUTF8KeyFail() |
||||
{ |
||||
$arr = new MapField(GPBType::STRING, GPBType::STRING); |
||||
$arr[hex2bin("ff")] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testStringSetInvalidUTF8ValueFail() |
||||
{ |
||||
$arr = new MapField(GPBType::STRING, GPBType::STRING); |
||||
$arr['abc'] = hex2bin("ff"); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testStringSetMessageKeyFail() |
||||
{ |
||||
$arr = new MapField(GPBType::STRING, GPBType::STRING); |
||||
$arr[new Sub()] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testStringSetMessageValueFail() |
||||
{ |
||||
$arr = new MapField(GPBType::STRING, GPBType::STRING); |
||||
$arr['abc'] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testMessageSetIntValueFail() |
||||
{ |
||||
$arr = |
||||
new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); |
||||
$arr[0] = 0; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testMessageSetStringValueFail() |
||||
{ |
||||
$arr = |
||||
new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); |
||||
$arr[0] = 'abc'; |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testMessageSetOtherMessageValueFail() |
||||
{ |
||||
$arr = |
||||
new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); |
||||
$arr[0] = new Sub(); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException PHPUnit_Framework_Error |
||||
*/ |
||||
public function testMessageSetNullFailMap() |
||||
{ |
||||
$arr = |
||||
new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); |
||||
$null = NULL; |
||||
$arr[0] = $null; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue