You are here

public function ConfigurationHandlerVariableTestCase::testExportToDataStore in Configuration Management 7.2

File

tests/handlers/vocabularies.test, line 58
Tests for Configuration Management: Vocabularies.

Class

ConfigurationHandlerVariableTestCase
Base class for functional tests for configuration management.

Code

public function testExportToDataStore() {
  $vocabulary = new stdClass();
  $vocabulary->name = $this
    ->randomName();
  $vocabulary->description = $this
    ->randomName();
  $vocabulary->machine_name = drupal_strtolower($this
    ->randomName());
  $vocabulary->help = '';
  $vocabulary->nodes = array();
  $vocabulary->weight = mt_rand(0, 10);
  taxonomy_vocabulary_save($vocabulary);
  $vocabulary_exists = db_query('SELECT 1 FROM {taxonomy_vocabulary} WHERE machine_name = :machine_name', array(
    ':machine_name' => $vocabulary->machine_name,
  ))
    ->fetchField();
  $this
    ->assertTrue($vocabulary_exists, "The vocabulary was saved in the ActiveStore.");
  $config = 'vocabulary.' . $vocabulary->machine_name;
  $results = ConfigurationManagement::exportToDataStore(array(
    $config,
  ), FALSE, FALSE);
  $exported = $results
    ->getInfo('exported');
  $this
    ->assertTrue(in_array($config, $exported), "Configuration for {$config} was exported.");
  $file_for_config = $this->datastore_path . '/' . $config . '.inc';
  $this
    ->assertTrue(file_exists($file_for_config), "The file that storages the vocabulary was created.");
}