public function LinkedinAuthTest::testConfigPage in Social Auth LinkedIn 8
Tests configuration page.
Throws
\Behat\Mink\Exception\ElementNotFoundException
File
- tests/
src/ Functional/ LinkedinAuthTest.php, line 38
Class
- LinkedinAuthTest
- Test the user-facing auth button generated by social_auth_linkedin.
Namespace
Drupal\Tests\social_auth_linkedin\FunctionalCode
public function testConfigPage() {
$assert = $this
->assertSession();
// Verify that permissions are applied to the various defined paths.
// Define some paths. Since the Marvin entity is defined, we can use it
// in our management paths.
$forbidden_paths = [
'/admin/config/social-api/social-auth/linkedin',
];
// Check 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);
}
// Create a user with no permissions.
$noperms_user = $this
->drupalCreateUser();
$this
->drupalLogin($noperms_user);
// 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);
}
// Create a user who can administer social api auth.
$admin_user = $this
->drupalCreateUser([
'administer social api authentication',
]);
$this
->drupalLogin($admin_user);
// 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/linkedin');
$assert
->pageTextContains('LINKEDIN CLIENT SETTINGS');
$assert
->fieldExists('client_id');
}