From ddd1028d958226231ab9df0d4f505a1c9b435871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baptiste=20Clavi=C3=A9?= Date: Sat, 26 Dec 2015 00:13:13 +0100 Subject: [PATCH] Add some assertions for deep constructor on object snapshots --- test/Snapshot/ObjectSnapshotTest.php | 33 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/test/Snapshot/ObjectSnapshotTest.php b/test/Snapshot/ObjectSnapshotTest.php index 52a35c1..fbaf2f1 100644 --- a/test/Snapshot/ObjectSnapshotTest.php +++ b/test/Snapshot/ObjectSnapshotTest.php @@ -48,23 +48,6 @@ public function testConstructWithoutObject() new ObjectSnapshot([]); } - /** - * @dataProvider deepProvider - */ - public function testDeepConstructor($value) - { - new ObjectSnapshot((object) ['foo' => $value]); - } - - public function deepProvider() - { - return [ - 'with a sub-object' => [(object) ['bar' => 'baz']], - 'with a sub-array' => [['bar' => 'baz']], - 'with a scalar' => ['fubar'] - ]; - } - public function testExportAllProperties() { $snapshot = new ObjectSnapshot(new Foo('foo', 'bar', 'baz')); @@ -80,6 +63,22 @@ public function testExportAllProperties() $this->assertSame('bar', $data['bar']); $this->assertSame('baz', $data['baz']); } + + public function testDeepConstructor() + { + $object = new Foo( + (object) ['foo' => 'bar'], // object + ['baz' => 'fubar'], // array + 'fubaz' // scalar + ); + + $snapshot = new ObjectSnapshot($object); + $data = $snapshot->getComparableData(); + + $this->assertInstanceOf('Totem\\Snapshot\\ObjectSnapshot', $data['foo']); + $this->assertInstanceOf('Totem\\Snapshot\\ArraySnapshot', $data['bar']); + $this->assertNotInstanceOf('Totem\\AbstractSnapshot', $data['baz']); + } } // todo in php7 : use anon class !