Skip to content

Commit

Permalink
Add some assertions for deep constructor on object snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
Taluu committed Dec 25, 2015
1 parent bc62c81 commit 1d07a97
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions test/Snapshot/ObjectSnapshotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand All @@ -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 !
Expand Down

0 comments on commit 1d07a97

Please sign in to comment.