SalesforceOAuthTest.php in Salesforce Suite 8.4
File
modules/salesforce_oauth/tests/src/FunctionalJavascript/SalesforceOAuthTest.php
View source
<?php
namespace Drupal\Tests\salesforce_oauth\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
class SalesforceOAuthTest extends WebDriverTestBase {
protected $defaultTheme = 'stark';
public static $modules = [
'key',
'typed_data',
'dynamic_entity_reference',
'salesforce',
'salesforce_test_rest_client',
'salesforce_oauth',
];
protected $adminUser;
protected function setUp() {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser([
'authorize salesforce',
]);
$this
->drupalLogin($this->adminUser);
}
public function testOAuth() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalGet('admin/config/salesforce/authorize/add');
$labelField = $page
->findField('label');
$label = $this
->randomString();
$labelField
->setValue($label);
$page
->findField('provider')
->setValue('oauth');
$assert_session
->assertWaitOnAjaxRequest();
$edit = [
'provider_settings[consumer_key]' => 'foo',
'provider_settings[consumer_secret]' => 'bar',
'provider_settings[login_url]' => 'https://login.salesforce.com',
];
foreach ($edit as $key => $value) {
$assert_session
->fieldExists($key);
$page
->fillField($key, $value);
}
$this
->createScreenshot(\Drupal::root() . '/sites/default/files/simpletest/sfoauth-1.png');
$page
->pressButton('Save');
if ($page
->findField('id')) {
$page
->fillField('id', strtolower($this
->randomMachineName()));
$this
->createScreenshot(\Drupal::root() . '/sites/default/files/simpletest/sfoauth-2.png');
$page
->pressButton('Save');
}
$assert_session
->assertWaitOnAjaxRequest();
$this
->createScreenshot(\Drupal::root() . '/sites/default/files/simpletest/sfoauth-3.png');
$assert_session
->pageTextContainsOnce('error=invalid_client_id');
}
public function testOAuthCallback() {
}
}