StatusPageTest.php in Salesforce Suite 8.4
File
tests/src/Functional/StatusPageTest.php
View source
<?php
namespace Drupal\Tests\salesforce\Functional;
use Drupal\Core\Url;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Tests\BrowserTestBase;
class StatusPageTest extends BrowserTestBase {
use StringTranslationTrait;
protected $defaultTheme = 'stark';
public static $modules = [
'salesforce',
'salesforce_test_rest_client',
];
protected $authMan;
protected $authToken;
protected $authProvider;
protected $authConfig;
public function setUp() {
parent::setUp();
$this->authMan = \Drupal::service('plugin.manager.salesforce.auth_providers');
$file = __DIR__ . "/../../../salesforce.install";
require_once $file;
}
public function testRequirementsHook() {
$this
->assertEquals([], salesforce_requirements("install"));
$this
->assertEquals([], salesforce_requirements("update"));
}
public function testAuthProviderRequirementsNoProviders() {
$this->authMan
->setHasProviders(FALSE);
$requirements = salesforce_get_auth_provider_requirements();
$this
->assertEquals(REQUIREMENT_ERROR, $requirements['severity']);
$this
->assertEquals($this
->t('No auth providers have been created. Please <a href="@href">create an auth provider</a> to connect to Salesforce.', [
'@href' => Url::fromRoute('entity.salesforce_auth.add_form')
->toString(),
]), $requirements['description']);
}
public function testAuthProviderRequirementsNoConfig() {
$this->authMan
->setHasProviders(TRUE);
$this->authMan
->setHasConfig(FALSE);
$requirements = salesforce_get_auth_provider_requirements();
$this
->assertEquals(REQUIREMENT_ERROR, $requirements['severity']);
$this
->assertEquals($this
->t('Default auth provider has not been set. Please <a href="@href">choose an auth provider</a> to connect to Salesforce.', [
'@href' => Url::fromRoute('salesforce.auth_config')
->toString(),
]), $requirements['description']);
}
public function testAuthProviderRequirementsNoToken() {
$this->authMan
->setHasProviders(TRUE);
$this->authMan
->setHasConfig(TRUE);
$this->authMan
->setHasToken(FALSE);
$requirements = salesforce_get_auth_provider_requirements();
$this
->assertEquals(REQUIREMENT_ERROR, $requirements['severity']);
$this
->assertEquals($this
->t('Salesforce authentication failed. Please <a href="@href">check your auth provider settings</a> to connect to Salesforce.', [
'@href' => Url::fromRoute('entity.salesforce_auth.edit_form', [
'salesforce_auth' => $this->authMan
->getConfig()
->id(),
])
->toString(),
]), $requirements['description']);
}
public function testAuthProviderRequirementsOk() {
$this->authMan
->setHasProviders(TRUE);
$this->authMan
->setHasConfig(TRUE);
$this->authMan
->setHasToken(TRUE);
$requirements = salesforce_get_auth_provider_requirements();
$this
->assertEquals(REQUIREMENT_OK, $requirements['severity']);
$this
->assertArrayNotHasKey('description', $requirements);
}
public function testTlsRequirements() {
}
public function testUsageRequirements() {
}
}