Skip to content

Commit e87997b

Browse files
committed
Add unit testing for stdClass object serialization in PHP client (#7327)
1 parent 215e6ea commit e87997b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

samples/client/petstore/php/SwaggerClient-php/tests/ObjectSerializerTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,27 @@
55
// test object serializer
66
class ObjectSerializerTest extends \PHPUnit_Framework_TestCase
77
{
8+
/**
9+
* Test the sanitizeForSerialization method with a stdClass.
10+
*/
11+
public function testSanitizeForSerializationWithStdClass()
12+
{
13+
// Initialize the ObjectSerializer.
14+
$s = new ObjectSerializer();
15+
16+
// Build a stdClass object.
17+
$obj = new \stdClass();
18+
$obj->prop1 = 'val1';
19+
$obj->prop2 = 'val2';
20+
21+
// Call the method.
22+
$serialized = $s->sanitizeForSerialization($obj);
23+
24+
// Assert that the stdClass object is sanitized as expected.
25+
$this->assertEquals('val1', $serialized->prop1);
26+
$this->assertEquals('val2', $serialized->prop2);
27+
}
28+
829
// test sanitizeFilename
930
public function testSanitizeFilename()
1031
{

0 commit comments

Comments
 (0)