public function CertificateTest::testCertificateAccess in Certificate 4.x
Test the certificate access check.
A user that is allowed to receive a certificate should be able to see the certificate tab.
File
- tests/
src/ Functional/ CertificateTest.php, line 62
Class
- CertificateTest
- Tests for Certificate.
Namespace
Drupal\Tests\certificate\FunctionalCode
public function testCertificateAccess() {
// Create an activity.
/* @var $activity CertificateTestEntity */
$activity = Drupal::entityTypeManager()
->getStorage($this->content_type)
->create();
$activity
->save();
// Set certificates to appear.
$access_test_no_cert = $activity
->access('certificate', $this->uncertified_user);
$this
->assertFalse($access_test_no_cert, 'Unqualified user cannot access certificate.');
// Set certificates to appear.
$access_test_cert = $activity
->access('certificate', $this->certified_user);
$this
->assertTrue($access_test_cert, 'Qualified user can access certificate.');
}