Implemented testThatEveryEntityHasAPersistedLaw

This commit is contained in:
Kevin Frantz 2019-02-16 17:12:44 +01:00
parent 02b2dfa9ae
commit 6126c96cbb
2 changed files with 15 additions and 4 deletions

View File

@ -43,7 +43,7 @@ class Right extends AbstractMeta implements RightInterface
/**
* @ORM\ManyToOne(targetEntity="Law", inversedBy="rights")
* @ORM\JoinColumn(name="law_id", referencedColumnName="id")
* @ORM\JoinColumn(name="law_id", referencedColumnName="id",nullable=false)
*
* @var LawInterface
*/

View File

@ -1,6 +1,6 @@
<?php
namespace tests\Unit\Repository\Meta;
namespace tests\Integration\Repository\Meta;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Doctrine\ORM\EntityRepository;
@ -17,8 +17,11 @@ use Doctrine\ORM\EntityManagerInterface;
*
* @author kevinfrantz
*/
class RightRepositoryTest extends KernelTestCase
class RightRepositoryIntegrationTest extends KernelTestCase
{
/**
* @var int
*/
const PRIORITY = 123;
/**
@ -59,11 +62,11 @@ class RightRepositoryTest extends KernelTestCase
$this->right->setCrud(CRUDType::READ);
$this->law = new Law();
$this->entityManager->persist($this->law);
$this->right->setLaw($this->law);
}
public function testCreation(): void
{
$this->right->setLaw($this->law);
$this->entityManager->persist($this->right);
$this->entityManager->flush();
$rightId = $this->right->getId();
@ -75,6 +78,14 @@ class RightRepositoryTest extends KernelTestCase
$this->loadedRight = null;
}
public function testThatEveryEntityHasAPersistedLaw(): void
{
foreach ($this->rightRepository->findAll() as $right) {
$this->assertInstanceOf(LawInterface::class, $right->getLaw());
$this->assertGreaterThan(0, $right->getLaw()->getId());
}
}
private function deleteRight(): void
{
$this->entityManager->remove($this->loadedRight);