From 0b62d6b1ae2c7ea87d6e98ba4620d67367e1e046 Mon Sep 17 00:00:00 2001 From: tuutti Date: Tue, 26 Mar 2024 10:01:22 +0200 Subject: [PATCH] UHF-8570: Improve test coverage --- tests/src/Kernel/TunnistamoClientTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/src/Kernel/TunnistamoClientTest.php b/tests/src/Kernel/TunnistamoClientTest.php index 6531a98..0891dd1 100644 --- a/tests/src/Kernel/TunnistamoClientTest.php +++ b/tests/src/Kernel/TunnistamoClientTest.php @@ -4,6 +4,9 @@ namespace Drupal\Tests\helfi_tunnistamo\Kernel; +use Drupal\Core\Form\FormState; +use Drupal\user\Entity\Role; + /** * Tests Tunnistamo configuration. * @@ -76,4 +79,20 @@ public function testEndpoints() : void { } } + /** + * Tests configuration form default values. + */ + public function testConfigurationForm() : void { + Role::create(['id' => 'test', 'label' => 'test'])->save(); + $this->setupEndpoints(); + $plugin = $this->getPlugin(); + $configuration = $plugin->getConfiguration(); + $form = $plugin->buildConfigurationForm([], new FormState()); + $this->assertEquals($configuration['auto_login'], $form['auto_login']['#default_value']); + $this->assertEquals($configuration['client_scopes'], $form['client_scopes']['#default_value']); + $this->assertEquals('https://localhost', $form['environment_url']['#default_value']); + $this->assertEquals(['test' => 'test'], $form['client_roles']['#options']); + $this->assertEquals($configuration['client_roles'], $form['client_roles']['#default_value']); + } + }