Set('log_level_min', [LogChannels::DM_CRUD => 'Debug', LogChannels::EVENT_SERVICE => 'Trace']); } } protected function tearDown(): void { if (is_file(APPROOT.static::$sLogFile)) { $sLog = file_get_contents(APPROOT.static::$sLogFile); echo "--- error.log\n$sLog\n\n"; @unlink(APPROOT.static::$sLogFile); } parent::tearDown(); } /* * Test that when an object is deleted while having a link set with php computation * linked to a nullable external key, the db_links_changed event is not fired */ public function testDBLinksChangedNotCalledOnDeletedObjects() { $oEventReceiver = new CRUDEventReceiver($this); $oEventReceiver->RegisterCRUDEventListeners(EVENT_DB_LINKS_CHANGED, 'TestDBObject'); $sObjectParentKey = $this->GivenObjectInDB('TestDBObject', ['name' => 'parent']); $oChild = $this->createObject('TestDBObject', ['name' => 'child', 'parent_id' => $sObjectParentKey]); $this->AssertEventCountEquals(1, EVENT_DB_LINKS_CHANGED, 'Event EVENT_DB_LINKS_CHANGED should have been thrown on child creation'); $oParent = MetaModel::GetObject('TestDBObject', $sObjectParentKey); static::CleanCallCount(); $oParent->DBDelete(); $oChild->Reload(); $this->assertEquals(0, $oChild->Get('parent_id')); $this->AssertEventCountEquals(0, EVENT_DB_LINKS_CHANGED, 'Event EVENT_DB_LINKS_CHANGED should not have been thrown on deleted objects'); } }