You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
2.3 KiB
62 lines
2.3 KiB
<?php |
|
|
|
namespace Drupal\Tests\islandora\Functional; |
|
|
|
/** |
|
* Tests Islandora Settings Form. |
|
* |
|
* @package Drupal\Tests\islandora\Functional |
|
* @group islandora |
|
* @coversDefaultClass \Drupal\islandora\Form\IslandoraSettingsForm |
|
*/ |
|
class IslandoraSettingsFormTest extends IslandoraFunctionalTestBase { |
|
|
|
/** |
|
* {@inheritdoc} |
|
*/ |
|
public function setUp(): void { |
|
parent::setUp(); |
|
|
|
// Create a test user. |
|
$account = $this->drupalCreateUser([ |
|
'bypass node access', |
|
'administer site configuration', |
|
'view media', |
|
'create media', |
|
'update media', |
|
]); |
|
$this->drupalLogin($account); |
|
} |
|
|
|
/** |
|
* Test form validation for JWT expiry. |
|
*/ |
|
public function testJwtExpiry() { |
|
$this->drupalGet('/admin/config/islandora/core'); |
|
$this->assertSession()->statusCodeEquals(200); |
|
$this->assertSession()->pageTextContains("JWT Expiry"); |
|
$this->assertSession()->fieldValueEquals('edit-jwt-expiry', '+2 hour'); |
|
$this->drupalGet('/admin/config/islandora/core'); |
|
// Blank is not allowed. |
|
$this->submitForm(['edit-jwt-expiry' => ""], $this->t('Save configuration')); |
|
$this->assertSession()->pageTextContainsOnce('"" is not a valid time or interval expression.'); |
|
$this->drupalGet('/admin/config/islandora/core'); |
|
// Negative is not allowed. |
|
$this->submitForm(['edit-jwt-expiry' => "-2 hours"], $this->t('Save configuration')); |
|
$this->assertSession()->pageTextContainsOnce('Time or interval expression cannot be negative'); |
|
$this->drupalGet('/admin/config/islandora/core'); |
|
// Must include an integer value. |
|
$this->submitForm(['edit-jwt-expiry' => "last hour"], $this->t('Save configuration')); |
|
$this->assertSession()->pageTextContainsOnce('No numeric interval specified, for example "1 day"'); |
|
$this->drupalGet('/admin/config/islandora/core'); |
|
// Must have an accepted interval. |
|
$this->submitForm(['edit-jwt-expiry' => "1 fortnight"], $this->t('Save configuration')); |
|
$this->assertSession()->pageTextContainsOnce('No time interval found, please include one of'); |
|
$this->drupalGet('/admin/config/islandora/core'); |
|
// Test a valid setting. |
|
$this->submitForm(['edit-jwt-expiry' => "2 weeks"], $this->t('Save configuration')); |
|
$this->assertSession()->pageTextContainsOnce('The configuration options have been saved.'); |
|
|
|
} |
|
|
|
}
|
|
|