EntityconnectAdminTest.php in Entity connect 8.2
File
tests/src/Functional/EntityconnectAdminTest.php
View source
<?php
namespace Drupal\Tests\entityconnect\Functional;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Url;
class EntityconnectAdminTest extends EntityconnectTestBase {
use StringTranslationTrait;
protected function setUp() {
parent::setUp();
$this->ecUser
->addRole('ec_add');
$this->ecUser
->addRole('ec_edit');
$this->ecUser
->save();
}
public function testAdminAccess() {
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/config/content/entityconnect');
$this
->assertSession()
->statusCodeEquals(200);
$this
->drupalLogout();
$anyUser = $this
->drupalCreateUser([
'access administration pages',
]);
$this
->drupalLogin($anyUser);
$this
->drupalGet('admin/config/content/entityconnect');
$this
->assertSession()
->statusCodeEquals(403);
}
public function testButtonsAdmin() {
$this
->drupalLogin($this->ecUser);
$this
->drupalGet(Url::fromRoute('node.add', [
'node_type' => $this->testContentType
->id(),
]));
$this
->assertSession()
->elementNotExists('xpath', '//div[contains(@class, \'entityconnect-\')]/input');
$this
->drupalLogout();
$this
->drupalLogin($this->adminUser);
$this
->drupalGet("admin/structure/types/manage/{$this->testContentType->id()}/fields/node.{$this->testContentType->id()}.{$this->testRefField->getName()}");
$this
->assertSession()
->pageTextContains('EntityConnect default Parameters');
$edit = [
'third_party_settings[entityconnect][buttons][button_add]' => '0',
'third_party_settings[entityconnect][buttons][button_edit]' => '0',
];
$this
->drupalPostForm(NULL, $edit, 'Save settings');
$this
->drupalLogout();
$this
->drupalLogin($this->ecUser);
$this
->drupalGet('node/add/' . $this->testContentType
->id());
$this
->assertSession()
->elementExists('xpath', '//div[contains(@class, \'entityconnect-\')]/input');
}
}