Skip to content

Commit

Permalink
Added empty array Test
Browse files Browse the repository at this point in the history
  • Loading branch information
boldtrn committed Oct 22, 2015
1 parent a908f61 commit 56c822f
Showing 1 changed file with 38 additions and 4 deletions.
42 changes: 38 additions & 4 deletions Tests/IntegrationTest/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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();

}

}

0 comments on commit 56c822f

Please sign in to comment.