LiftLinkTest.php in Acquia Lift Connector 8.3
File
src/Tests/LiftLinkTest.php
View source
<?php
namespace Drupal\acquia_lift\Tests;
use Drupal\simpletest\WebTestBase;
class LiftLinkTest extends WebTestBase {
use SettingsDataTrait;
public static $modules = array(
'node',
'acquia_lift',
'menu_ui',
'user',
'toolbar',
);
protected function setUp() {
parent::setUp();
if ($this->profile != 'standard') {
$this
->drupalCreateContentType(array(
'type' => 'page',
'name' => 'Basic page',
'display_submitted' => FALSE,
));
$this
->drupalCreateContentType(array(
'type' => 'article',
'name' => 'Article',
));
}
}
public function testLinkInToolbar() {
$permissions = [
'access toolbar',
'access acquia lift links',
];
$linkUser = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($linkUser);
$this
->setValidSettings();
$node = $this
->drupalCreateNode();
$this
->drupalGet($node
->toUrl());
$this
->assertRaw('id="openLiftLink"');
}
public function testLinkInToolbarAfterConfigChange() {
$permissions = [
'access toolbar',
'access acquia lift links',
];
$linkUser = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($linkUser);
$node = $this
->drupalCreateNode();
$this
->drupalGet($node
->toUrl());
$this
->assertNoRaw('id="openLiftLink"');
$this
->assertCacheContext('url.path');
$this
->assertCacheContext('user');
$this
->assertCacheTag('config:acquia_lift.settings');
$this
->setValidSettings();
$this
->drupalGet($node
->toUrl());
$this
->assertRaw('id="openLiftLink"');
$this
->assertCacheTag('config:acquia_lift.settings');
$this
->assertCacheContext('url.path');
$this
->assertCacheContext('user');
$this
->assertCacheContext('url.query_args:_wrapper_format');
$this
->assertCacheContext('url.query_args:my_identity_parameter');
$this
->assertCacheContext('url.query_args:my_identity_type_parameter');
}
public function testLinkNotInToolbar() {
$permissions = [
'access toolbar',
];
$linkUser = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($linkUser);
$node = $this
->drupalCreateNode();
$this
->drupalGet($node
->toUrl());
$this
->assertNoRaw('id="openLiftLink"');
$this
->setValidSettings();
$this
->drupalGet($node
->toUrl());
$this
->assertNoRaw('id="openLiftLink"');
}
public function testLinkNotInToolbarInAdminPages() {
$permissions = [
'access toolbar',
'access acquia lift links',
'access administration pages',
];
$linkUser = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($linkUser);
$this
->drupalGet('/admin');
$this
->assertNoRaw('id="openLiftLink"');
$this
->setValidSettings();
$this
->drupalGet('/admin');
$this
->assertNoRaw('id="openLiftLink"');
}
}