HasOneofTest.php 757 B

1234567891011121314151617181920212223242526
  1. <?php
  2. require_once('test_util.php');
  3. use Foo\TestMessage;
  4. class HasOneofTest extends \PHPUnit\Framework\TestCase {
  5. #########################################################
  6. # Test hasOneof<Field> methods exists and working
  7. #########################################################
  8. public function testHasOneof() {
  9. $m = new TestMessage();
  10. $this->assertFalse($m->hasOneofInt32());
  11. $m->setOneofInt32(42);
  12. $this->assertTrue($m->hasOneofInt32());
  13. $m->setOneofString("bar");
  14. $this->assertFalse($m->hasOneofInt32());
  15. $this->assertTrue($m->hasOneofString());
  16. $m->clear();
  17. $this->assertFalse($m->hasOneofInt32());
  18. $this->assertFalse($m->hasOneofString());
  19. }
  20. }