public function OauthTokenFileStorageTest::testCheckRequirements in Apigee Edge 8
Validates checks in the storage.
File
- tests/
src/ Kernel/ OauthTokenFileStorageTest.php, line 122
Class
- OauthTokenFileStorageTest
- OAuth cache storage tests.
Namespace
Drupal\Tests\apigee_edge\KernelCode
public function testCheckRequirements() {
/** @var \Drupal\apigee_edge\OauthTokenFileStorage $storage */
$storage = $this->container
->get('apigee_edge.authentication.oauth_token_storage');
try {
$storage
->checkRequirements();
} catch (OauthTokenStorageException $exception) {
$this
->assertEquals('Unable to save token data to private filesystem because it has not been configured yet.', $exception
->getMessage());
}
// @see \Drupal\Core\StreamWrapper\LocalStream::getLocalPath()
$this
->setSetting('file_private_path', 'vfs://private');
try {
$storage
->checkRequirements();
} catch (OauthTokenStorageException $exception) {
$this
->assertEquals(sprintf('Unable to set up %s directory for token file.', OauthTokenFileStorage::DEFAULT_DIRECTORY), $exception
->getMessage());
}
$storage = $this
->tokenStorage(TRUE);
// No exception should be thrown anymore.
$storage
->checkRequirements();
$this
->assertTrue(file_exists($this->vfsRoot
->getChild(static::CUSTOM_TOKEN_DIR)
->url()));
}