public function AcquiaConnectorUnitTest::testAuthenticators in Acquia Connector 8
Same name and namespace in other branches
- 8.2 tests/src/Unit/AcquiaConnectorUnitTest.php \Drupal\Tests\acquia_connector\Unit\AcquiaConnectorUnitTest::testAuthenticators()
- 3.x tests/src/Unit/AcquiaConnectorUnitTest.php \Drupal\Tests\acquia_connector\Unit\AcquiaConnectorUnitTest::testAuthenticators()
Test authenticators.
File
- tests/
src/ Unit/ AcquiaConnectorUnitTest.php, line 28 - Contains \Drupal\Tests\acquia_connector\Unit\AcquiaConnectorUnitTest.
Class
- AcquiaConnectorUnitTest
- @coversDefaultClass \Drupal\acquia_connector\Client
Namespace
Drupal\Tests\acquia_connector\UnitCode
public function testAuthenticators() {
$identifier = $this
->randomMachineName();
$key = $this
->randomMachineName();
$params = [
'time',
'nonce',
'hash',
];
$client = new ClientTest();
$result = $client
->buildAuthenticator($key, time(), $params);
// Test Client::buildAuthenticator.
$valid = is_array($result);
$this
->assertTrue($valid, 'Client::buildAuthenticator returns an array');
if ($valid) {
foreach ($params as $key) {
if (!array_key_exists($key, $result)) {
$valid = FALSE;
break;
}
}
$this
->assertTrue($valid, 'Array has expected keys');
}
// Test Client::buildAuthenticator.
$result = $client
->buildAuthenticator($identifier, time(), []);
$valid = is_array($result);
$this
->assertTrue($valid, 'Client::buildAuthenticator returns an array');
if ($valid) {
foreach ($params as $key) {
if (!array_key_exists($key, $result)) {
$valid = FALSE;
break;
}
}
$this
->assertTrue($valid, 'Array has expected keys');
}
}