/** * @after testDelete */ public function testRollbackDelete() { /** @var $list AppliedChangesLogModel[] */ $list = AppliedChangesLogModel::find(array('limit' => 3, 'order' => array('id' => 'DESC'))); $this->assertCount($list, 3, $this->errorMessage('should be in an amount of writable', array(':count' => 3))); foreach ($list as $lItem) { $this->assertTrue($lItem->processName == DeleteProcess::className(), $this->errorMessage('logging process should be - Disposal')); } $rsIblock = \CIBlock::getList(); $countIbBefore = $rsIblock->SelectedRowsCount(); $iblocksBefore = array(); while ($arIb = $rsIblock->Fetch()) { $iblocksBefore[] = $arIb['ID']; } Module::getInstance()->rollbackByLogs($list ?: array()); $rsIblock = \CIBlock::getList(); $countIbAfter = $rsIblock->SelectedRowsCount(); $iblocksAfter = array(); while ($arIb = $rsIblock->Fetch()) { $iblocksAfter[] = $arIb['ID']; } $rebuildIblockId = array_diff($iblocksAfter, $iblocksBefore); $rebuildIblockId = array_shift($rebuildIblockId); $this->assertEquals($countIbAfter, $countIbBefore + 1, $this->errorMessage('information block data to be restored')); $this->assertEquals($rebuildIblockId, $this->_iblockId, $this->errorMessage('iblock restored identifier changed')); $rsProp = PropertyTable::getList(array('filter' => array('=IBLOCK_ID' => $rebuildIblockId))); $this->assertTrue($rsProp->getSelectedRowsCount() > 0, $this->errorMessage('must present properties of reduced information iblock'), array(':iblockId' => $rebuildIblockId)); $rsSections = SectionTable::getList(array('filter' => array('=IBLOCK_ID' => $rebuildIblockId))); $this->assertTrue($rsSections->getSelectedRowsCount() > 0, $this->errorMessage('must present sections of reduced information iblock', array(':iblockId' => $rebuildIblockId))); }
/** * @param $class * @return BaseProcess */ public function getProcess($class) { switch ($class) { case AddProcess::className(): return $this->_getProcessAdd(); break; case UpdateProcess::className(): return $this->_getProcessUpdate(); break; case DeleteProcess::className(): return $this->_getProcessDelete(); break; } }