public function DrupalRolesIntegrationTest::testForm in Authorization 8
Test form building.
File
- authorization_drupal_roles/
tests/ src/ Kernel/ DrupalRolesIntegrationTest.php, line 91
Class
- DrupalRolesIntegrationTest
- Integration tests for authorization_drupal_roles.
Namespace
Drupal\Tests\authorization_drupal_roles\KernelCode
public function testForm() : void {
$profile = AuthorizationProfile::create([
'status' => 'true',
'description' => 'test',
'id' => 'test',
'provider' => 'dummy',
'consumer' => 'authorization_drupal_roles',
]);
$profile
->setConsumerMappings([
[
'role' => 'test0',
],
[
'role' => 'test1',
],
[
'role' => 'test2',
],
]);
$consumer = $profile
->getConsumer();
$form = [];
$formState = new FormState();
$form = $consumer
->buildConfigurationForm($form, $formState);
self::assertStringContainsString('no settings', (string) $form['description']['#markup']);
$roleId = $this
->drupalCreateRole([]);
$form = [];
$formState = new FormState();
$row = $consumer
->buildRowForm($form, $formState, 2);
self::assertStringContainsString('test2', $row['role']['#default_value']);
self::assertArrayHasKey($roleId, $row['role']['#options']);
}