diff options
Diffstat (limited to 'php/tests/well_known_test.php')
-rw-r--r-- | php/tests/well_known_test.php | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/php/tests/well_known_test.php b/php/tests/well_known_test.php index 6a788df29..db5d5a7a0 100644 --- a/php/tests/well_known_test.php +++ b/php/tests/well_known_test.php @@ -392,4 +392,27 @@ class WellKnownTest extends TestBase { $m->setValue("a"); $this->assertSame("a", $m->getValue()); } + + /** + * @dataProvider enumNameValueConversionDataProvider + */ + public function testEnumNameValueConversion($class) + { + $reflectionClass = new ReflectionClass($class); + $constants = $reflectionClass->getConstants(); + foreach ($constants as $k => $v) { + $this->assertSame($k, $class::name($v)); + $this->assertSame($v, $class::value($k)); + } + } + + public function enumNameValueConversionDataProvider() + { + return [ + ['\Google\Protobuf\Field\Cardinality'], + ['\Google\Protobuf\Field\Kind'], + ['\Google\Protobuf\NullValue'], + ['\Google\Protobuf\Syntax'], + ]; + } } |