Merge pull request #8005 from haberman/php-filefix

Moved HasOneof test into GeneratedClassTest.php, to avoid the extra file.
pull/8006/head^2
Joshua Haberman 4 years ago committed by GitHub
commit 7b56ea3ac3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      php/phpunit.xml
  2. 17
      php/tests/GeneratedClassTest.php
  3. 26
      php/tests/HasOneofTest.php
  4. 2
      php/tests/test.sh

@ -13,7 +13,6 @@
<file>tests/DescriptorsTest.php</file>
<file>tests/GeneratedServiceTest.php</file>
<file>tests/WrapperTypeSettersTest.php</file>
<file>tests/HasOneofTest.php</file>
</testsuite>
</testsuites>
</phpunit>

@ -1671,6 +1671,23 @@ class GeneratedClassTest extends TestBase
# TODO: what about unknown fields?
}
#########################################################
# Test hasOneof<Field> methods exists and working
#########################################################
public function testHasOneof() {
$m = new TestMessage();
$this->assertFalse($m->hasOneofInt32());
$m->setOneofInt32(42);
$this->assertTrue($m->hasOneofInt32());
$m->setOneofString("bar");
$this->assertFalse($m->hasOneofInt32());
$this->assertTrue($m->hasOneofString());
$m->clear();
$this->assertFalse($m->hasOneofInt32());
$this->assertFalse($m->hasOneofString());
}
#########################################################
# Test no segfault when error happens
#########################################################

@ -1,26 +0,0 @@
<?php
require_once('test_util.php');
use Foo\TestMessage;
class HasOneofTest extends \PHPUnit\Framework\TestCase {
#########################################################
# Test hasOneof<Field> methods exists and working
#########################################################
public function testHasOneof() {
$m = new TestMessage();
$this->assertFalse($m->hasOneofInt32());
$m->setOneofInt32(42);
$this->assertTrue($m->hasOneofInt32());
$m->setOneofString("bar");
$this->assertFalse($m->hasOneofInt32());
$this->assertTrue($m->hasOneofString());
$m->clear();
$this->assertFalse($m->hasOneofInt32());
$this->assertFalse($m->hasOneofString());
}
}

@ -29,7 +29,7 @@ esac
[ -f $PHPUNIT ] || wget https://phar.phpunit.de/$PHPUNIT
tests=( ArrayTest.php EncodeDecodeTest.php GeneratedClassTest.php MapFieldTest.php WellKnownTest.php DescriptorsTest.php WrapperTypeSettersTest.php HasOneofTest.php)
tests=( ArrayTest.php EncodeDecodeTest.php GeneratedClassTest.php MapFieldTest.php WellKnownTest.php DescriptorsTest.php WrapperTypeSettersTest.php)
for t in "${tests[@]}"
do

Loading…
Cancel
Save