Skip to content

Commit c7497a3

Browse files
committed
test: check php serialization
1 parent d4b6286 commit c7497a3

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v2.2.0 (2019-11)
2+
3+
* Test serialization/unserialization
4+
15
v2.1.0 (2019-11-13)
26

37
* New `optional()` constructor for nullable values

test/15-SerializableValueTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,32 @@ public function testBuiltinEqualsZero(AbstractSerializableValue $tw)
9090
"serializable wrapper considered zero as ==equal !");
9191
}
9292

93+
/**
94+
* @depends testInstance
95+
*/
96+
public function testPhpSerialize(AbstractSerializableValue $tw): string
97+
{
98+
$ser = serialize($tw);
99+
$this->assertNotEmpty($ser);
100+
return $ser;
101+
}
102+
103+
/**
104+
* @depends testPhpSerialize
105+
* @depends testInstance
106+
*/
107+
public function testPhpUnserialize(string $serialization, AbstractSerializableValue $orig)
108+
{
109+
/** @var AbstractSerializableValue $uns */
110+
$uns = unserialize($serialization);
111+
112+
$this->assertSame(get_class($orig), get_class($uns),
113+
"unserialize(serialize(ASV)) returned instance of a different class!");
114+
115+
$this->assertTrue($orig->equals($uns),
116+
"Unserialized object doesn't equal the original object anymore!");
117+
$this->assertTrue($uns->equals($orig),
118+
"Original object doesn't equal an unserialized object anymore!");
119+
}
120+
93121
}

0 commit comments

Comments
 (0)