public function testAdd()
 {
     /** @var $dbList \CDBResult */
     $dbList = \CIBlock::GetList();
     $ibCountBefore = $dbList->SelectedRowsCount();
     $beforeIds = array();
     while ($arIblock = $dbList->Fetch()) {
         $beforeIds[] = $arIblock['ID'];
     }
     $this->_applyFixtures(self::FIXTURE_TYPE_ADD);
     $dbList = \CIBlock::GetList();
     $ibCountAfter = $dbList->SelectedRowsCount();
     $afterIds = array();
     while ($arIblock = $dbList->Fetch()) {
         $afterIds[] = $arIblock['ID'];
     }
     $aAddedId = array_diff($afterIds, $beforeIds);
     $this->_processIblockId = array_shift($aAddedId);
     $this->assertNotEmpty($ibCountAfter, $this->errorMessage('record IB must be present'));
     $this->assertNotEquals($ibCountAfter, $ibCountBefore, $this->errorMessage('not also recording information block'));
     $this->assertNotEmpty($this->_processIblockId, $this->errorMessage('unavailable identifier of the new information block'));
     $rsProps = \CIBlockProperty::GetList(null, array('IBLOCK_ID' => $this->_processIblockId));
     $this->assertNotEmpty($rsProps->AffectedRowsCount(), $this->errorMessage('added properties not available information block', array(':iblockId' => $this->_processIblockId)));
     $rsSections = \CIBlockSection::getList(null, array('IBLOCK_ID' => $this->_processIblockId), false, array('ID'));
     $this->assertNotEmpty($rsSections->AffectedRowsCount(), $this->errorMessage('added sections not available information block'));
     $registerRef = (bool) DbVersionReferencesTable::getList(array('filter' => array('=DB_VERSION' => Module::getInstance()->getDbVersion(), '=GROUP' => ReferenceController::GROUP_IBLOCK, '=ITEM_ID' => $this->_processIblockId)))->fetch();
     $this->assertTrue($registerRef, $this->errorMessage('In added apply not created iblock reference ' . $this->_processIblockId));
 }
 public function testExistsReferencesRegister()
 {
     Module::getInstance()->install();
     $dbRsRef = DbVersionReferencesTable::getList(array('filter' => array('GROUP' => ReferenceController::GROUP_IBLOCK)));
     $dbRsIblock = IblockTable::getList();
     $this->assertEquals($dbRsIblock->getSelectedRowsCount(), $dbRsRef->getSelectedRowsCount(), $this->errorMessage('number of links to the information block and the information block entries must match'));
     $dbRsRef = DbVersionReferencesTable::getList(array('filter' => array('GROUP' => ReferenceController::GROUP_IBLOCK_PROPERTY)));
     $dbRsProp = PropertyTable::getList();
     $this->assertEquals($dbRsProp->getSelectedRowsCount(), $dbRsRef->getSelectedRowsCount(), $this->errorMessage('number of links on the properties of information blocks and records must match'));
     $dbRsRef = DbVersionReferencesTable::getList(array('filter' => array('GROUP' => ReferenceController::GROUP_IBLOCK_SECTION)));
     $dbRsSection = SectionTable::getList();
     $this->assertEquals($dbRsSection->getSelectedRowsCount(), $dbRsRef->getSelectedRowsCount(), $this->errorMessage('number of links to information block sections and records must match'));
 }
 public function deleteAll()
 {
     $dbRes = DbVersionReferencesTable::getList();
     while ($itemData = $dbRes->fetch()) {
         DbVersionReferencesTable::delete($itemData['ID']);
     }
 }