From 56c822f5e976cc0f85d03c4afbb6e10fd26d6c13 Mon Sep 17 00:00:00 2001 From: Robin Date: Thu, 22 Oct 2015 20:55:27 +0200 Subject: [PATCH] Added empty array Test --- Tests/IntegrationTest/IntegrationTest.php | 42 ++++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/Tests/IntegrationTest/IntegrationTest.php b/Tests/IntegrationTest/IntegrationTest.php index 3140daa..80ddada 100644 --- a/Tests/IntegrationTest/IntegrationTest.php +++ b/Tests/IntegrationTest/IntegrationTest.php @@ -18,11 +18,19 @@ class IntegrationTest extends BaseTest public function testSimpleInsertSelect() { - $test = new Test(); - $test->setAttrs(array('foo' => 'bar')); + $test = $this->createTest(array('foo' => 'bar')); - $this->entityManager->persist($test); - $this->entityManager->flush(); + /** @var Test $retrievedTest */ + $retrievedTest = $this->entityManager->getRepository($this->testEntityName)->find($test->getId()); + + static::assertEquals($test->getAttrs(), $retrievedTest->getAttrs()); + + } + + public function testEmptyArray() + { + + $test = $this->createTest(array()); /** @var Test $retrievedTest */ $retrievedTest = $this->entityManager->getRepository($this->testEntityName)->find($test->getId()); @@ -31,4 +39,30 @@ public function testSimpleInsertSelect() } + /** + * @param $attrs array the attributes of the jsonb array + * @return Test + */ + private function createTest($attrs) + { + $test = new Test(); + $test->setAttrs($attrs); + + $this->entityManager->persist($test); + $this->entityManager->flush(); + + return $test; + } + + private function clearTable() + { + + foreach ($this->entityManager->getRepository($this->testEntityName)->findAll() as $test) { + $this->entityManager->remove($test); + } + + $this->entityManager->flush(); + + } + }