ApiKeyConfigurationTest.php in S3 File System 8.2
File
src/Tests/ApiKeyConfigurationTest.php
View source
<?php
namespace Drupal\s3fs\Tests;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Url;
use Drupal\simpletest\WebTestBase;
class ApiKeyConfigurationTest extends WebTestBase {
use StringTranslationTrait;
public static $modules = [
's3fs',
];
protected $adminUser;
protected function setUp() {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser([
'administer s3fs',
'administer site configuration',
]);
$this
->drupalLogin($this->adminUser);
}
public function testKeyConfiguration() {
$this
->drupalGet(Url::fromRoute('s3fs.admin_settings'));
$this
->assertResponse(200);
$this
->assertFieldByName('access_key', '', 'The Access API key is not set');
$this
->assertFieldByName('secret_key', '', 'The Secret API key is not set');
$this
->drupalGet(Url::fromRoute('system.status'));
$this
->assertText('S3 File System access key or secret key is not set and it is required for some functionalities to work.', 'The content exists on the report page');
$this
->assertLink('S3 File System module settings page', 0, 'Link to the api key configuration page found');
$this
->assertLinkByHref(Url::fromRoute('s3fs.admin_settings')
->toString());
}
public function testKeyStorage() {
$this
->drupalGet(Url::fromRoute('s3fs.admin_settings'));
$this
->assertResponse(200);
$access_key = $this
->randomString(40);
$secret_key = $this
->randomString(40);
$edit = [
'access_key' => $access_key,
'secret_key' => $secret_key,
'bucket' => $this
->randomString(8),
];
$this
->drupalPostForm(Url::fromRoute('s3fs.admin_settings'), $edit, $this
->t('Save configuration'));
$this
->assertText($this
->t('The configuration options have been saved.'), $this
->t('Saved configuration'));
}
}
Classes
Name |
Description |
ApiKeyConfigurationTest |
Tests whether access_key & secret_key is set at the admin configuration page,
and whether the access_key & secret_key is stored successfully or not. |