entityManager = static::getContainer()->get(EntityManagerInterface::class); } public function testAccountingGetsUpdatedByCascade() { $tipjarA = new Tipjar(); $tipjarA->setName('TEST_TIPJAR_A'); $accountingA = new Accounting(); $accountingA->setOwner($tipjarA); $this->entityManager->persist($tipjarA); $this->entityManager->flush(); /** @var Accounting */ $accountingA = $this->entityManager->getRepository(Tipjar::class) ->findOneBy(['name' => 'TEST_TIPJAR_A']) ->getAccounting(); $this->assertNotNull($accountingA->getId()); $this->assertEquals($tipjarA->getId(), $accountingA->getOwner()->getId()); $this->assertEquals(Tipjar::class, $accountingA->getOwner()::class); $tipjarB = new Tipjar(); $tipjarB->setName('TEST_TIPJAR_B'); $accountingB = new Accounting(); $accountingB->setOwner($tipjarB); $this->entityManager->persist($tipjarB); $this->entityManager->flush(); /** @var Accounting */ $accountingB = $this->entityManager->getRepository(Tipjar::class) ->findOneBy(['name' => 'TEST_TIPJAR_B']) ->getAccounting(); $this->assertNotNull($accountingB->getId()); $this->assertEquals($tipjarB->getId(), $accountingB->getOwner()->getId()); $this->assertEquals(Tipjar::class, $accountingB->getOwner()::class); } }