File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ v2.2.0 (2019-11)
2+
3+ * Test serialization/unserialization
4+
15v2.1.0 (2019-11-13)
26
37 * New ` optional() ` constructor for nullable values
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments