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')); }
/** * Run module tests * @internal param $aCheckList * @return array */ public static function items() { if (!Module::getInstance()->getOptions()->useAutotests) { return array(); } $points = array(); $i = 1; $fGetCaseId = function ($className) { $arClass = implode('\\', $className); return array_pop($arClass); }; foreach (self::cases() as $caseClass) { /** @var $case AbstractCase */ $case = new $caseClass(static::_getLocalizationByCase($caseClass)); $points[self::SECTION . '-' . $i++] = array('AUTO' => 'Y', 'NAME' => $case->name(), 'DESC' => $case->description(), 'CLASS_NAME' => get_called_class(), 'METHOD_NAME' => 'run', 'PARENT' => self::SECTION, 'PARAMS' => array('class' => $caseClass)); } return array('CATEGORIES' => array(self::SECTION => array('NAME' => static::getLocalization()->message('run.name'))), 'POINTS' => $points); }
public function testReinitIblockReference() { $beforeApplyFix = array('iblocks' => IblockTable::getList()->getSelectedRowsCount(), 'properties' => PropertyTable::getList()->getSelectedRowsCount(), 'sections' => SectionTable::getList()->getSelectedRowsCount()); $collector = Collector::createByFile(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'add_collection.json'); $this->assertNotEmpty($collector->getFixes()); Module::getInstance()->applyFixesList($collector->getFixes()); $afterApplyFix = array('iblocks' => IblockTable::getList()->getSelectedRowsCount(), 'properties' => PropertyTable::getList()->getSelectedRowsCount(), 'sections' => SectionTable::getList()->getSelectedRowsCount()); Module::getInstance()->rollbackLastChanges(); $afterRollback = array('iblocks' => IblockTable::getList()->getSelectedRowsCount(), 'properties' => PropertyTable::getList()->getSelectedRowsCount(), 'sections' => SectionTable::getList()->getSelectedRowsCount()); Module::getInstance()->applyFixesList($collector->getFixes()); $afterRollbackApply = array('iblocks' => IblockTable::getList()->getSelectedRowsCount(), 'properties' => PropertyTable::getList()->getSelectedRowsCount(), 'sections' => SectionTable::getList()->getSelectedRowsCount()); $this->assertEquals($beforeApplyFix['iblocks'], $afterApplyFix['iblocks'] - 1, $this->errorMessage('iblock not created after apply fix')); $this->assertEquals($beforeApplyFix['properties'], $afterApplyFix['properties'] - 2, $this->errorMessage('properties not created after apply fix')); $this->assertEquals($beforeApplyFix['sections'], $afterApplyFix['sections'] - 1, $this->errorMessage('sections not created after apply fix')); $this->assertEquals($beforeApplyFix['iblocks'], $afterRollback['iblocks'], $this->errorMessage('iblock not removed after rollback fix')); $this->assertEquals($beforeApplyFix['properties'], $afterRollback['properties'], $this->errorMessage('properties not removed after rollback fix')); $this->assertEquals($beforeApplyFix['sections'], $afterRollback['sections'], $this->errorMessage('sections not removed after rollback fix')); $this->assertEquals($afterRollback['iblocks'] + 1, $afterRollbackApply['iblocks'], $this->errorMessage('iblock not created after apply rollback fix')); $this->assertEquals($afterRollback['properties'] + 2, $afterRollbackApply['properties'], $this->errorMessage('properties not created after apply rollback fix')); $this->assertEquals($afterRollback['sections'] + 1, $afterRollbackApply['sections'], $this->errorMessage('sections not created after apply rollback fix')); }
function DoInstall() { global $APPLICATION, $data; $loc = \WS\Migrations\Module::getInstance()->getLocalization('setup'); $options = \WS\Migrations\Module::getInstance()->getOptions(); global $errors; $errors = array(); if ($data['catalog']) { $dir = $_SERVER['DOCUMENT_ROOT'].$data['catalog']; if (!is_dir($dir)) { mkdir($dir); } if (!is_dir($dir)) { $errors[] = $loc->getDataByPath('error.notCreateDir'); } if (!$errors) { $options->catalogPath = $data['catalog']; } $this->InstallFiles(); $this->InstallDB(); RegisterModule(self::MODULE_ID); \Bitrix\Main\Loader::includeModule(self::MODULE_ID); \Bitrix\Main\Loader::includeModule('iblock'); \WS\Migrations\Module::getInstance()->install(); } if (!$data || $errors) { $APPLICATION->IncludeAdminFile($loc->getDataByPath('title'), __DIR__.'/form.php'); return; } }
<?php global $USER; if (!$USER->isAdmin()) { return array(); } $loc = \WS\Migrations\Module::getInstance()->getLocalization('menu'); $inputUri = '/bitrix/admin/ws_migrations.php?q='; return array(array('parent_menu' => 'global_menu_settings', 'sort' => 500, 'text' => $loc->getDataByPath('title'), 'title' => $loc->getDataByPath('title'), 'module_id' => 'ws.migrations', 'icon' => '', 'items_id' => 'ws_migrations_menu', 'items' => array(array('text' => $loc->getDataByPath('apply'), 'url' => $inputUri . 'main'), array('text' => $loc->getDataByPath('import'), 'url' => $inputUri . 'import'), array('text' => $loc->getDataByPath('export'), 'url' => $inputUri . 'export'))));
public function testCreateNewReferenceFixes() { $collector = Module::getInstance()->getDutyCollector(); $fixes = $collector->getFixes(); $this->assertNotEmpty($fixes, $this->errorMessage('requires fixations adding links')); foreach ($fixes as $fix) { if ($fix->getProcess() != 'reference') { $this->throwError($this->errorMessage('when upgrading recorded only links')); } } }
" ENCTYPE="multipart/form-data" name="apply"><? $form = new CAdminForm('ws_maigrations_export', array( array( "DIV" => "edit1", "TAB" => $localization->getDataByPath('title'), "ICON" => "iblock", "TITLE" => $localization->getDataByPath('title'), ) , )); $form->Begin(array( 'FORM_ACTION' => $APPLICATION->GetCurUri() )); $form->BeginNextFormTab(); $form->BeginCustomField('version', 'vv'); ?><tr> <td width="30%"><?php echo $localization->getDataByPath('version'); ?> :</td> <td width="60%"><b><?php echo \WS\Migrations\Module::getInstance()->getDbVersion(); ?> </b></td> </tr><? $form->EndCustomField('version'); $form->EndTab(); $form->Buttons(array('btnSave' => false, 'btnÀpply' => true)); $form->Show(); ?></form><?
/** * @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))); }
<? CModule::IncludeModule('ws.migrations'); define("ADMIN_MODULE_NAME", \WS\Migrations\Module::getName()); CJSCore::Init(array('jquery')); ?>
public function getLocalization() { return Module::getInstance()->getLocalization('processes'); }
/** * @return Localization */ protected function getLocalization() { return Module::getInstance()->getLocalization('handlers'); }
<?php global $APPLICATION, $errors; $localization = \WS\Migrations\Module::getInstance()->getLocalization('setup'); $options = \WS\Migrations\Module::getInstance()->getOptions(); $form = new CAdminForm('ew', array(array('DIV' => 't1', 'TAB' => $localization->getDataByPath('tab')))); echo BeginNote(); echo $localization->getDataByPath('description'); echo EndNote(); $errors && ShowError(implode(', ', $errors)); $form->Begin(array('FORM_ACTION' => $APPLICATION->GetCurUri())); $form->BeginNextFormTab(); $form->AddEditField('data[catalog]', $localization->getDataByPath('fields.catalog'), true, array(), $options->catalogPath ?: '/migrations'); $form->Buttons(array('btnSave' => false, 'btnÀpply' => true)); $form->Show();
<?php require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php"; require_once __DIR__ . "/../include.php"; require_once __DIR__ . "/../prolog.php"; if (!$USER->isAdmin()) { return; } CModule::IncludeModule('ws.migrations'); CModule::IncludeModule('iblock'); $request = $_REQUEST; $action = $request['q']; $fAction = function ($file) use($action) { global $USER, $DB, $APPLICATION, $adminPage, $adminMenu, $adminChain; $localization = \WS\Migrations\Module::getInstance()->getLocalization('admin')->fork($action); include $file; }; $actionFile = __DIR__ . DIRECTORY_SEPARATOR . $request['q'] . '.php'; if (file_exists($actionFile)) { $fAction($actionFile); } else { /* @var $APPLICATION CMain */ $APPLICATION->ThrowException("Action `{$actionFile}` not exists"); } require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin_after.php";