From 7f154e9cfe916f6561b79b3b4227f1b812525112 Mon Sep 17 00:00:00 2001 From: Tim Roediger Date: Wed, 26 Feb 2014 20:36:42 +1100 Subject: [PATCH] Tidy up unserializer tests a little --- .../Test/Serializer/UnserializeModeTest.php | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/tests/Zoop/Shard/Test/Serializer/UnserializeModeTest.php b/tests/Zoop/Shard/Test/Serializer/UnserializeModeTest.php index bab2fe8..db656cf 100644 --- a/tests/Zoop/Shard/Test/Serializer/UnserializeModeTest.php +++ b/tests/Zoop/Shard/Test/Serializer/UnserializeModeTest.php @@ -57,14 +57,24 @@ public function testUnserializePatchGeneral() ], 'active' => false ], - self::USER_CLASS, - $user + self::USER_CLASS ); $this->assertEquals('there', $updated->location()); $this->assertEquals('superdweebie', $updated->getUsername()); $this->assertEquals('Tom', $updated->getProfile()->getFirstname()); $this->assertEquals(false, $updated->getActive()); + + //also check that the updated doc persists correctly + $documentManager->flush(); + $documentManager->clear(); + + $updated = $documentManager->getRepository(get_class($user))->find($id); + + $this->assertEquals('there', $updated->location()); + $this->assertEquals('superdweebie', $updated->getUsername()); + $this->assertEquals('Tom', $updated->getProfile()->getFirstname()); + $this->assertEquals(false, $updated->getActive()); } public function testUnserializePatchAddItemToCollection() @@ -91,8 +101,7 @@ public function testUnserializePatchAddItemToCollection() 'id' => $id, 'groups' => $groups ], - self::USER_CLASS, - $user + self::USER_CLASS ); // this works pre flush @@ -137,8 +146,7 @@ public function testUnserializePatchRemoveItemFromCollection() 'id' => $id, 'groups' => $groups ], - self::USER_CLASS, - $user + self::USER_CLASS ); $userGroups = $updated->getGroups(); @@ -173,8 +181,7 @@ public function testUnserializePatchEmptyCollection() 'id' => $id, 'groups' => [] ], - self::USER_CLASS, - $user + self::USER_CLASS ); $this->assertCount(0, $updated->getGroups()); @@ -212,7 +219,7 @@ public function testUnserializeUpdateGeneral() ] ], self::USER_CLASS, - $user, + null, Unserializer::UNSERIALIZE_UPDATE ); @@ -247,7 +254,7 @@ public function testUnserializeUpdateAddItemToCollection() 'groups' => $groups ], self::USER_CLASS, - $user, + null, Unserializer::UNSERIALIZE_UPDATE ); @@ -290,7 +297,7 @@ public function testUnserializeUpdateRemoveItemFromCollection() 'groups' => $groups ], self::USER_CLASS, - $user, + null, Unserializer::UNSERIALIZE_UPDATE ); @@ -326,7 +333,7 @@ public function testUnserializeUpdateEmptyCollection() 'groups' => [] ], self::USER_CLASS, - $user, + null, Unserializer::UNSERIALIZE_UPDATE );