WebformAccountAccessTest.php in Webform 6.x
File
tests/src/Unit/Access/WebformAccountAccessTest.php
View source
<?php
namespace Drupal\Tests\webform\Unit\Access;
use Drupal\Core\Access\AccessResult;
use Drupal\webform\Access\WebformAccountAccess;
class WebformAccountAccessTest extends WebformAccessTestBase {
public function testWebformAccountAccess() {
$anonymous_account = $this
->mockAccount();
$admin_account = $this
->mockAccount([
'administer webform' => TRUE,
'administer webform submission' => TRUE,
]);
$submission_account = $this
->mockAccount([
'access webform overview' => TRUE,
'view any webform submission' => TRUE,
]);
$this
->assertEquals(AccessResult::neutral()
->cachePerPermissions(), WebformAccountAccess::checkAdminAccess($anonymous_account)
->setReason(''));
$this
->assertEquals(AccessResult::allowed()
->cachePerPermissions(), WebformAccountAccess::checkAdminAccess($admin_account));
$this
->assertEquals(AccessResult::neutral()
->cachePerPermissions(), WebformAccountAccess::checkSubmissionAccess($anonymous_account)
->setReason(''));
$this
->assertEquals(AccessResult::allowed()
->cachePerPermissions(), WebformAccountAccess::checkSubmissionAccess($submission_account));
$this
->assertEquals(AccessResult::neutral()
->cachePerPermissions(), WebformAccountAccess::checkOverviewAccess($anonymous_account)
->setReason(''));
$this
->assertEquals(AccessResult::allowed()
->cachePerPermissions(), WebformAccountAccess::checkOverviewAccess($submission_account));
}
}