public function AdminSettingsTest::testAdminAccess in Sparkpost email 8.2
Same name in this branch
- 8.2 tests/src/Functional/AdminSettingsTest.php \Drupal\Tests\sparkpost\Functional\AdminSettingsTest::testAdminAccess()
- 8.2 modules/sparkpost_requeue/tests/src/Functional/AdminSettingsTest.php \Drupal\Tests\sparkpost_requeue\Functional\AdminSettingsTest::testAdminAccess()
Access admin pages.
File
- tests/
src/ Functional/ AdminSettingsTest.php, line 52
Class
- AdminSettingsTest
- Test basic functionality.
Namespace
Drupal\Tests\sparkpost\FunctionalCode
public function testAdminAccess() {
$this
->drupalLogin($this->user);
// Try access sparkpost admin form.
$this
->drupalGet('admin/config/services/sparkpost');
$this
->assertSession()
->statusCodeEquals(403);
// Try access test form.
$this
->drupalGet('admin/config/services/sparkpost/test');
$this
->assertSession()
->statusCodeEquals(403);
// Login as admin.
$this
->drupalLogout();
$this
->drupalLogin($this->admin);
// Try access sparkpost admin form.
$this
->drupalGet('admin/config/services/sparkpost');
$this
->assertSession()
->statusCodeEquals(200);
// Try access test form.
$this
->drupalGet('admin/config/services/sparkpost/test');
$this
->assertSession()
->statusCodeEquals(403);
// Set dummy access key.
\Drupal::configFactory()
->getEditable('sparkpost.settings')
->set('api_key', 'API_KEY')
->save();
// Try access test form.
$this
->drupalGet('admin/config/services/sparkpost/test');
$this
->assertSession()
->statusCodeEquals(200);
}