/** * Import from Yaml file. * * @param string $file * @param string $override * @param bool $force if set to true items not included in import will be deleted * * @return Result */ public function importFromYaml($file, $override = null, $force = false) { Craft::app()->config->maxPowerCaptain(); $yaml = IOHelper::getFileContents($file); $yaml_override = IOHelper::getFileContents($override); $dataModel = Data::fromYaml($yaml, $yaml_override); return $this->importDataModel($dataModel, $force); }
/** * @covers ::fromYaml * @covers ::replaceEnvVariables */ public function testErrorWhenEnvironmentVariableNotSet() { // unset environment variable putenv('SCHEMATIC_S3_BUCKET'); $this->setExpectedException('\\Craft\\Exception'); $schema = $this->getSchemaTestFile(); $override = $this->getOverrideTestFile(); Data::fromYaml($schema, $override); }
/** * 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); }