public function ConfigurationApiTest::testStartAndStopTracking in Configuration Management 7.2
File
- tests/
configuration.test, line 112 - Tests for Configuration Management
Class
Code
public function testStartAndStopTracking() {
$results = ConfigurationManagement::startTracking(array(
'content_type.article',
));
$exported = $results
->getInfo('exported');
$dirpath = drupal_realpath(ConfigurationManagement::getStream()) . '/';
$tracked = ConfigurationManagement::trackedConfigurations();
$non_tracked = ConfigurationManagement::nonTrackedConfigurations();
foreach ($this->configurations as $id) {
list($component, $identifier) = explode('.', $id, 2);
if (!empty($tracked[$component][$identifier])) {
$filename = $dirpath . $id . '.inc';
$this
->assertTrue(file_exists($filename), t('@filename file was created.', array(
'@filename' => $filename,
)));
}
$this
->assertTrue(!empty($tracked[$component][$identifier]), t('@id is being tracked', array(
'@id' => $id,
)));
$this
->assertTrue(empty($non_tracked[$component][$identifier]), t('@id is not being tracked', array(
'@id' => $id,
)));
$handler = ConfigurationManagement::createConfigurationInstance($id);
$this
->assertTrue($handler
->loadFromActiveStore()
->getStatus() == t('In Sync'), $id . ' is In Sync');
}
$count_tracked = db_query("SELECT COUNT(component) FROM {configuration_tracked}")
->fetchField();
$this
->assertTrue($count_tracked == count($exported), t("@num of @total configurations have been tracked.", array(
'@num' => $count_tracked,
'@total' => count($exported),
)));
$results = ConfigurationManagement::stopTracking(array(
'content_type.article',
));
$count_tracked = db_query("SELECT COUNT(component) FROM {configuration_tracked}")
->fetchField();
$this
->assertTrue(empty($count_tracked), "No configurations have been tracked.");
$tracked = ConfigurationManagement::trackedConfigurations();
$non_tracked = ConfigurationManagement::nonTrackedConfigurations();
foreach ($this->configurations as $id) {
list($component, $identifier) = explode('.', $id, 2);
if (empty($tracked[$component][$identifier])) {
$filename = $dirpath . $id . '.inc';
$this
->assertTrue(!file_exists($filename), t('@filename file was deleted.', array(
'@filename' => $filename,
)));
}
$this
->assertTrue(empty($tracked[$component][$identifier]), t('@id is not being tracked', array(
'@id' => $id,
)));
}
}