Loading tests/src/Fuctional/WhatsappFormTest.php +27 −6 Original line number Diff line number Diff line Loading @@ -2,8 +2,6 @@ namespace Drupal\Tests\whatsapp\Functional; namespace Drupal\onlyone\Utility; use Drupal\Tests\BrowserTestBase; /** Loading @@ -17,7 +15,7 @@ class WhatsappFormTest extends BrowserTestBase /** * {@inheritdoc} */ protected static $modules = ['whatsapp', 'whatsapp_test', 'key', 'user']; protected static $modules = ['whatsapp', 'key', 'user']; /** * {@inheritdoc} Loading @@ -29,7 +27,8 @@ class WhatsappFormTest extends BrowserTestBase */ protected function setUp(): void { parent::setUp(); $this->adminUser = $this->drupalCreateUser(['whatsapp configuration form', $this->adminUser = $this->drupalCreateUser([ 'whatsapp configuration form', 'administer keys', ]); $this->drupalLogin($this->adminUser); Loading @@ -39,7 +38,6 @@ class WhatsappFormTest extends BrowserTestBase * Tests the config form. */ public function testSettingsForm() { // Add a key with a 4 characters. $this->drupalGet('admin/config/system/keys/add'); $testingKey = [ Loading @@ -48,8 +46,20 @@ class WhatsappFormTest extends BrowserTestBase 'key_type' => 'authentication', 'key_input_settings[key_value]' => str_pad('', 4, 'z'), ]; $this->submitForm($testingKey, 'Save'); $this->drupalGet('admin/config/system/keys/add'); $changedKey = [ 'id' => 'changed_key', 'label' => 'Changed Key', 'key_type' => 'authentication', 'key_input_settings[key_value]' => str_pad('', 4, 'y'), ]; $this->submitForm($changedKey, 'Save'); $assert_session = $this->assertSession(); $edit = [ Loading @@ -60,8 +70,19 @@ class WhatsappFormTest extends BrowserTestBase $this->submitForm($edit, 'Save configuration'); $assert_session->statusCodeEquals(200); $widget_key_testing = $this->container->get('config.factory')->get('whatsapp.settings')->get('widget_key'); $this->assertEquals('Testing Key', $this->container->get('key.repository')->getKey($widget_key_testing)->label()); $change = [ 'id' => 'changed_key', ]; $assert_session->pageTextNotContains('No keys are available.'); $this->drupalGet('admin/config/services/whatsapp'); $this->submitForm($change, 'Save configuration'); $assert_session->statusCodeEquals(200); $widget_key_changed = $this->container->get('config.factory')->get('whatsapp.settings')->get('widget_key'); $this->assertEquals('Changed Key', $this->container->get('key.repository')->getKey($widget_key_changed)->label()); } Loading Loading
tests/src/Fuctional/WhatsappFormTest.php +27 −6 Original line number Diff line number Diff line Loading @@ -2,8 +2,6 @@ namespace Drupal\Tests\whatsapp\Functional; namespace Drupal\onlyone\Utility; use Drupal\Tests\BrowserTestBase; /** Loading @@ -17,7 +15,7 @@ class WhatsappFormTest extends BrowserTestBase /** * {@inheritdoc} */ protected static $modules = ['whatsapp', 'whatsapp_test', 'key', 'user']; protected static $modules = ['whatsapp', 'key', 'user']; /** * {@inheritdoc} Loading @@ -29,7 +27,8 @@ class WhatsappFormTest extends BrowserTestBase */ protected function setUp(): void { parent::setUp(); $this->adminUser = $this->drupalCreateUser(['whatsapp configuration form', $this->adminUser = $this->drupalCreateUser([ 'whatsapp configuration form', 'administer keys', ]); $this->drupalLogin($this->adminUser); Loading @@ -39,7 +38,6 @@ class WhatsappFormTest extends BrowserTestBase * Tests the config form. */ public function testSettingsForm() { // Add a key with a 4 characters. $this->drupalGet('admin/config/system/keys/add'); $testingKey = [ Loading @@ -48,8 +46,20 @@ class WhatsappFormTest extends BrowserTestBase 'key_type' => 'authentication', 'key_input_settings[key_value]' => str_pad('', 4, 'z'), ]; $this->submitForm($testingKey, 'Save'); $this->drupalGet('admin/config/system/keys/add'); $changedKey = [ 'id' => 'changed_key', 'label' => 'Changed Key', 'key_type' => 'authentication', 'key_input_settings[key_value]' => str_pad('', 4, 'y'), ]; $this->submitForm($changedKey, 'Save'); $assert_session = $this->assertSession(); $edit = [ Loading @@ -60,8 +70,19 @@ class WhatsappFormTest extends BrowserTestBase $this->submitForm($edit, 'Save configuration'); $assert_session->statusCodeEquals(200); $widget_key_testing = $this->container->get('config.factory')->get('whatsapp.settings')->get('widget_key'); $this->assertEquals('Testing Key', $this->container->get('key.repository')->getKey($widget_key_testing)->label()); $change = [ 'id' => 'changed_key', ]; $assert_session->pageTextNotContains('No keys are available.'); $this->drupalGet('admin/config/services/whatsapp'); $this->submitForm($change, 'Save configuration'); $assert_session->statusCodeEquals(200); $widget_key_changed = $this->container->get('config.factory')->get('whatsapp.settings')->get('widget_key'); $this->assertEquals('Changed Key', $this->container->get('key.repository')->getKey($widget_key_changed)->label()); } Loading