private function _injectDutyCollector() { $collector = Collector::createInstance(__DIR__); $collector->notStored(); Module::getInstance()->injectDutyCollector($collector); $this->_currentDutyCollector = $collector; return $collector; }
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')); }
private function _applyFixtures($type) { $collector = Collector::createByFile(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . $type . '.json'); $this->assertNotEmpty($collector->getFixes()); Module::getInstance()->applyFixesList($collector->getFixes()); }
/** * @return Collector[] */ public function getNotAppliedCollectors() { $result = AppliedChangesLogTable::getList(array('select' => array('GROUP_LABEL'), 'group' => array('GROUP_LABEL'))); $usesGroups = array_map(function ($row) { return $row['GROUP_LABEL']; }, $result->fetchAll()); $dir = new Directory($this->_getFixFilesDir()); $collectors = array(); $files = array(); foreach ($dir->getChildren() as $file) { if ($file->isDirectory()) { continue; } if (in_array($file->getName(), $usesGroups)) { continue; } $files[$file->getName()] = $file; } ksort($files); foreach ($files as $file) { $collectors[] = Collector::createByFile($file->getPath(), $this); } return $collectors; }