From ea222db0be1ec4df710c2f6c446a6e0ecbca206e Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Fri, 6 Sep 2024 14:10:21 +0300 Subject: [PATCH] has one test --- tests/integration/Espo/ORM/RelationsTest.php | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/integration/Espo/ORM/RelationsTest.php b/tests/integration/Espo/ORM/RelationsTest.php index d729915051..6a560e92f8 100644 --- a/tests/integration/Espo/ORM/RelationsTest.php +++ b/tests/integration/Espo/ORM/RelationsTest.php @@ -190,6 +190,30 @@ class RelationsTest extends BaseTestCase // hasOne + $em->refreshEntity($account); + $this->assertInstanceOf(AccountExtended::class, $account); + + $account->setRelatedOriginalLead($lead1); + $em->saveEntity($account, [SaveOption::SKIP_ALL => true]); + $em->refreshEntity($lead1); + + $this->assertEquals($account->getId(), $lead1->get('createdAccountId')); + + $account->setRelatedOriginalLead($lead2); + $em->saveEntity($account, [SaveOption::SKIP_ALL => true]); + $em->refreshEntity($lead2); + + $this->assertEquals($account->getId(), $lead2->get('createdAccountId')); + + $em->refreshEntity($lead1); + + $this->assertEquals(null, $lead1->get('createdAccountId')); + + $account->setRelatedOriginalLead(null); + $em->saveEntity($account, [SaveOption::SKIP_ALL => true]); + $em->refreshEntity($lead2); + + $this->assertEquals(null, $lead2->get('createdAccountId')); } }