only in patch2: unchanged: --- a/tests/src/Functional/SocialAuthTwitterSettingsFormTest.php +++ b/tests/src/Functional/SocialAuthTwitterSettingsFormTest.php @@ -2,16 +2,16 @@ namespace Drupal\Tests\social_auth_twitter\Functional; -use Drupal\Tests\BrowserTestBase; +use Drupal\social_api\SocialApiSettingsFormBaseTest; /** - * Test Social Auth Twitter module functionality of settings' forms. + * Test Social Auth Twitter module functionality of settings form. * * @group social_auth * * @ingroup social_auth_twitter */ -class SocialAuthTwitterAdminFormTest extends BrowserTestBase { +class SocialAuthTwitterSettingsFormTest extends SocialApiSettingsFormBaseTest { /** * Modules to enable. @@ -21,112 +21,35 @@ class SocialAuthTwitterAdminFormTest extends BrowserTestBase { public static $modules = ['social_auth_twitter']; /** - * The installation profile to use with this test. - * - * @var string - */ - protected $profile = 'minimal'; - - /** - * A test user with no permissions. - * - * @var \Drupal\user\UserInterface - */ - protected $noPermsUser; - - /** - * A test user with corresponding permissions. - * - * @var \Drupal\user\UserInterface - */ - protected $adminUser; - - /** * {@inheritdoc} */ protected function setUp() { - parent::setUp(); - - // Create a non-administrative user. - $this->noPermsUser = $this->drupalCreateUser(); + $this->module = 'social_auth_twitter'; + $this->socialNetwork = 'twitter'; + $this->moduleType = 'social-auth'; - // Create an administrative user. - $this->adminUser = $this->drupalCreateUser( - [ - 'access administration pages', - 'administer social api authentication', - ] - ); + parent::setUp(); } /** - * Tests that module is available in social api list. + * {@inheritdoc} */ public function testIsAvailableInIntegrationList() { - $this->drupalLogin($this->adminUser); - $this->drupalGet('/admin/config/social-api/social-auth'); + $this->fields = ['consumer_key', 'consumer_secret']; - // Assert that module is enabled in social auth list. - $this->assertSession()->pageTextContains('social_auth_twitter'); + parent::testIsAvailableInIntegrationList(); } /** - * Tests configuration page. + * {@inheritdoc} */ - public function testSettingsPage() { - - $assert = $this->assertSession(); - - // Verifies that permissions are applied to the various defined paths. - $forbidden_paths = [ - '/admin/config/social-api/social-auth/twitter', + public function testSettingsFormSubmission() { + $this->edit = [ + 'consumer_key' => $this->randomString(10), + 'consumer_secret' => $this->randomString(10), ]; - // Checks each of the paths to make sure we don't have access. At this point - // we haven't logged in any users, so the client is anonymous. - foreach ($forbidden_paths as $path) { - $this->drupalGet($path); - $assert->statusCodeEquals(403); - } - - // Logs in user with no permissions. - $this->drupalLogin($this->noPermsUser); - - // Should be the same result for forbidden paths, since the user needs - // special permissions for these paths. - foreach ($forbidden_paths as $path) { - $this->drupalGet($path); - $assert->statusCodeEquals(403); - } - - // Logs in user with permissions. - $this->drupalLogin($this->adminUser); - - // Forbidden paths aren't forbidden any more. - foreach ($forbidden_paths as $unforbidden) { - $this->drupalGet($unforbidden); - $assert->statusCodeEquals(200); - } - - // Now that we have the admin user logged in, check the menu links. - $this->drupalGet('/admin/config/social-api/social-auth/twitter'); - $assert->pageTextContains('Settings'); - $assert->fieldExists('consumer_key'); - - } - - /** - * Test module settings form. - */ - public function testSubmitSettingsForm() { - $this->drupalLogin($this->adminUser); - $this->drupalGet('/admin/config/social-api/social-auth/twitter'); - $edit = [ - 'consumer_key' => 'consumer_key', - 'consumer_secret' => 'consumer_secret', - ]; - $this->drupalPostForm('/admin/config/social-api/social-auth/twitter', $edit, t('Save configuration')); - $this->assertSession()->pageTextContains('The configuration options have been saved.'); + parent::testSettingsFormSubmission(); } }