SocialAuthTestBase.php in Social Auth 8.2
File
tests/src/Functional/SocialAuthTestBase.php
View source
<?php
namespace Drupal\Tests\social_auth\Functional;
use Drupal\Core\Url;
use Drupal\Tests\social_api\Functional\SocialApiTestBase;
abstract class SocialAuthTestBase extends SocialApiTestBase {
protected $defaultTheme = 'stark';
public static $modules = [
'block',
'social_auth',
];
protected $socialAuthLoginBlock;
protected $authRootPath = '/user/login/';
protected function setUp() {
$this->adminUserPermissions = [
'administer social api authentication',
];
$this->moduleType = 'social-auth';
parent::setUp();
$this->socialAuthLoginBlock = $this
->drupalPlaceBlock('social_auth_login', [
'label' => 'Social Auth Login',
'id' => 'social_auth_login',
]);
$this->socialAuthLoginBlock
->getPlugin()
->setConfigurationValue('label_display', 1);
$this->socialAuthLoginBlock
->save();
}
protected function checkLinkToProviderExists() {
$this
->drupalGet(Url::fromRoute('<front>'));
$this
->assertSession()
->pageTextContains($this->socialAuthLoginBlock
->label());
if ($this->provider) {
$this
->checkPathInBlock($this->authRootPath . $this->provider);
}
$this
->drupalLogin($this->noPermsUser);
$this
->drupalGet(Url::fromRoute('<front>'));
$this
->assertSession()
->pageTextContains($this->socialAuthLoginBlock
->label());
if ($this->provider) {
$this
->checkPathInBlock($this->authRootPath . $this->provider);
}
}
protected function checkPathInBlock($path) {
$links = $this
->xpath('//a[contains(@href, :href)]', [
':href' => $path,
]);
$this
->assertGreaterThanOrEqual(1, count($links));
}
}