/** * Import data model. * * @param Data $model * @param bool $force if set to true items not in the import will be deleted * * @return Result */ private function importDataModel(Data $model, $force) { // Import schema $localesImportResult = Craft::app()->schematic_locales->import($model->getAttribute('locales', $force)); $pluginImportResult = Craft::app()->schematic_plugins->import($model->getAttribute('plugins', $force)); $assetSourcesImportResult = Craft::app()->schematic_assetSources->import($model->getAttribute('assetSources'), $force); $fieldImportResult = Craft::app()->schematic_fields->import($model->getAttribute('fields'), $force); $globalSetsImportResult = Craft::app()->schematic_globalSets->import($model->getAttribute('globalSets'), $force); $sectionImportResult = Craft::app()->schematic_sections->import($model->getAttribute('sections'), $force); $userGroupImportResult = Craft::app()->schematic_userGroups->import($model->getAttribute('userGroups'), $force); $userImportResult = Craft::app()->schematic_users->import($model->getAttribute('users'), true); // Element index settings are supported from Craft 2.5 if (version_compare(CRAFT_VERSION, '2.5', '>=')) { $elementIndexSettingsImportResult = Craft::app()->schematic_elementIndexSettings->import($model->getAttribute('elementIndexSettings'), $force); } // Verify results $result = new Result(); $result->consume($localesImportResult); $result->consume($pluginImportResult); $result->consume($assetSourcesImportResult); $result->consume($fieldImportResult); $result->consume($globalSetsImportResult); $result->consume($sectionImportResult); $result->consume($userGroupImportResult); $result->consume($userImportResult); // Element index settings are supported from Craft 2.5 if (version_compare(CRAFT_VERSION, '2.5', '>=')) { $result->consume($elementIndexSettingsImportResult); } $services = Craft::app()->plugins->call('registerMigrationService'); $this->doImport($result, $model->pluginData, $services, $force); return $result; }
/** * Test export to yml excluding data types. * * @covers ::exportToYaml */ public function testExportToYamlExcludingDataTypes() { $this->prepExportMockServices(); $exportableDataTypes = Schematic::getExportableDataTypes(); $dataTypesToExport = array_diff($exportableDataTypes, ['pluginData']); $results = $this->schematicService->exportToYaml($this->getYamlExportFile(), $dataTypesToExport); $this->assertFalse($results->hasErrors()); // Read and process the recently created export YAML file. $yaml = IOHelper::getFileContents($this->getYamlExportFile()); $dataModel = Data::fromYaml($yaml, []); // Make sure the excluded data type was not exported. $this->assertEmpty($dataModel->pluginData); }
/** * @covers ::toYaml */ public function testToYamlContainsCorrectText() { $dataModel = $this->generateDataModel(); $yaml = Data::toYaml($dataModel->attributes); $this->assertContains('override_bucket_name', $yaml); }