public function AcquiaSPITestCase::testAcquiaSpiGet in Acquia Connector 7.3
Same name and namespace in other branches
- 7.2 acquia_spi/tests/acquia_spi.test \AcquiaSPITestCase::testAcquiaSPIGet()
Needs comment.
File
- acquia_spi/
tests/ acquia_spi.test, line 238
Class
- AcquiaSPITestCase
- Tests the functionality of the Acquia SPI module.
Code
public function testAcquiaSpiGet() {
// Test acquia_spi_get().
$spi_data = acquia_spi_get();
$valid = is_array($spi_data);
$this
->assertTrue($valid, 'acquia_spi_get() returns an array');
if ($valid) {
foreach ($this->spiDataKeys as $key) {
if (!array_key_exists($key, $spi_data)) {
$valid = FALSE;
break;
}
}
$this
->assertTrue($valid, 'Array has expected keys');
$this
->assertEqual(sha1(drupal_get_private_key()), $spi_data['site_key'], 'Site key is sha1 of Drupal private key');
$this
->assertTrue(!empty($spi_data['spi_data_version']), 'SPI data version is set');
$vars = drupal_json_decode($spi_data['system_vars']);
$this
->assertTrue(is_array($vars), 'SPI data system_vars is a JSON-encoded array');
$this
->assertTrue(isset($vars['user_admin_role']), 'user_admin_role included in SPI data');
$this
->assertTrue(!empty($spi_data['modules']), 'Modules is not empty');
$modules = array(
'status',
'name',
'version',
'package',
'core',
'project',
'filename',
'module_data',
);
$diff = array_diff(array_keys($spi_data['modules'][0]), $modules);
$this
->assertTrue(empty($diff), 'Module elements have expected keys');
$diff = array_diff(array_keys($spi_data['platform']), $this->platformKeys);
$this
->assertTrue(empty($diff), 'Platform contains expected keys');
$roles = drupal_json_decode($spi_data['roles']);
$this
->assertTrue(is_array($roles), 'Roles is an array');
$this
->assertTrue(isset($roles[1]) && $roles[1] === 'anonymous user', 'Roles array contains anonymous user');
}
}