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(); + + } + }