ContentHubDeleteClientConfirmFormTest.php in Acquia Content Hub 8.2
File
tests/src/Functional/ContentHubDeleteClientConfirmFormTest.php
View source
<?php
namespace Drupal\Tests\acquia_contenthub\Functional;
use Drupal\acquia_contenthub_test\MockDataProvider;
use Drupal\Tests\BrowserTestBase;
class ContentHubDeleteClientConfirmFormTest extends BrowserTestBase {
protected $authorizedUser;
protected $unauthorizedUser;
const CH_DELETE_CLIENT_CONFIRM_FORM_PATH = '/admin/config/services/acquia-contenthub/delete-client-confirm';
protected $defaultTheme = 'stable';
public static $modules = [
'acquia_contenthub',
'acquia_contenthub_test',
'acquia_contenthub_server_test',
'user',
];
protected function setUp() {
parent::setUp();
$this->authorizedUser = $this
->drupalCreateUser([
'administer acquia content hub',
]);
$this->unauthorizedUser = $this
->drupalCreateUser();
$this
->drupalLogin($this->authorizedUser);
$settings = [
'hostname' => MockDataProvider::VALID_HOSTNAME,
'api_key' => MockDataProvider::VALID_API_KEY,
'secret_key' => MockDataProvider::VALID_SECRET,
'client_name' => MockDataProvider::VALID_CLIENT_NAME,
'webhook' => 'http://invalid-url.com',
];
$this
->drupalPostForm('/admin/config/services/acquia-contenthub', $settings, 'Register Site');
}
public function testContentHubDeleteClientConfirmFormPagePermissions() {
$session = $this
->assertSession();
$this
->drupalGet(self::CH_DELETE_CLIENT_CONFIRM_FORM_PATH);
$session
->pageTextContains('Acquia Content Hub Delete Client Confirmation');
$session
->statusCodeEquals(200);
$this
->drupalLogout();
$this
->drupalLogin($this->unauthorizedUser);
$this
->drupalGet(self::CH_DELETE_CLIENT_CONFIRM_FORM_PATH);
$session
->pageTextContains('Access denied');
$session
->statusCodeEquals(403);
}
public function testContentHubDeleteClientConfirmFormRenderedProperly() {
$session = $this
->assertSession();
$this
->drupalGet(self::CH_DELETE_CLIENT_CONFIRM_FORM_PATH);
$session
->pageTextContains("Everything is in order, safe to proceed");
$session
->buttonExists('Unregister');
$session
->buttonExists('Cancel');
}
}