openlayers-8.x-4.x-dev/tests/src/Functional/AdminTest.php
tests/src/Functional/AdminTest.php
<?php
namespace Drupal\Tests\openlayers\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\Component\Render\FormattableMarkup;
/**
* Tests that the Openlayers Admin page is reachable.
*
* @group OpenlayersAdmin
*/
class AdminTest extends BrowserTestBase {
/**
* Default theme.
*
* @var string
*/
protected $defaultTheme = 'stark';
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = ['node', 'openlayers'];
/**
* We use the minimal profile because we want to test local action links.
*
* @var string
*/
protected $profile = 'minimal';
/**
* Ignore the schema checks. TODO - reinstate schema checks.
*
* @var string
*/
protected $strictConfigSchema = FALSE;
/**
* Tests that the admin page works.
*/
public function testAdminPage() {
// assert(FALSE);
// Test that admin screen cannot be accessed by an anonymous user.
$this->drupalGet('admin/structure/openlayers');
$this->assertSession()->statusCodeEquals(404);
// Test that admin screen cannot be accessed by logged-in user with
// no Openlayers admin permisions.
$basic_account = $this->drupalCreateUser(['access content']);
$this->drupalLogin($basic_account);
$this->drupalGet('admin/structure/openlayers');
$this->assertSession()->statusCodeEquals(404);
// Test that admin screen can be accessed by logged-in user with
// Openlayers admin permisions.
$admin_account = $this->drupalCreateUser(['administer openlayers']);
$this->drupalLogin($admin_account);
$this->assertTrue($this->drupalUserIsLoggedIn($admin_account), new FormattableMarkup('User %name successfully logged in.', ['%name' => $admin_account->getAccountName()]));
$this->drupalGet('admin/config/system/openlayers');
$this->assertSession()->statusCodeEquals(200);
}
}
