public function AcquiaConnectorModuleTest::testAcquiaConnectorSiteStatusTests in Acquia Connector 8.2
Same name and namespace in other branches
- 8 tests/src/Functional/AcquiaConnectorModuleTest.php \Drupal\Tests\acquia_connector\Functional\AcquiaConnectorModuleTest::testAcquiaConnectorSiteStatusTests()
- 3.x tests/src/Functional/AcquiaConnectorModuleTest.php \Drupal\Tests\acquia_connector\Functional\AcquiaConnectorModuleTest::testAcquiaConnectorSiteStatusTests()
Tests the site status callback.
File
- tests/
src/ Functional/ AcquiaConnectorModuleTest.php, line 487
Class
- AcquiaConnectorModuleTest
- Tests the functionality of the Acquia Connector module.
Namespace
Drupal\Tests\acquia_connector\FunctionalCode
public function testAcquiaConnectorSiteStatusTests() {
$uuid = '0dee0d07-4032-44ea-a2f2-84182dc10d54';
$test_url = "https://insight.acquia.com/node/uuid/{$uuid}/dashboard";
$test_data = [
'active' => 1,
'href' => $test_url,
];
// Set some sample test data.
\Drupal::state()
->set('acquia_subscription_data', $test_data);
// Test StatusControllerTest::getIdFromSub.
$getIdFromSub = new StatusController();
$key = $getIdFromSub
->getIdFromSub($test_data);
$this
->assertIdentical($key, $uuid);
// Add a 'uuid' key to the data and make sure that is returned.
$test_data['uuid'] = $uuid;
$test_data['href'] = 'http://example.com';
$key = $getIdFromSub
->getIdFromSub($test_data);
$this
->assertIdentical($key, $uuid);
$query = [
'key' => hash('sha1', "{$key}:test"),
'nonce' => 'test',
];
$json = json_decode($this
->drupalGet('system/acquia-connector-status', [
'query' => $query,
]), TRUE);
// Test the version.
$this
->assertIdentical($json['version'], '1.0', 'Correct API version found.');
// Test invalid query string parameters for access.
// A random key value should fail.
$query['key'] = $this
->randomString(16);
$this
->drupalGet('system/acquia-connector-status', [
'query' => $query,
]);
$this
->assertResponse(403);
}