EntityconnectEditTest.php in Entity connect 8.2
File
tests/src/Functional/EntityconnectEditTest.php
View source
<?php
namespace Drupal\Tests\entityconnect\Functional;
use Drupal\Core\StringTranslation\StringTranslationTrait;
class EntityconnectEditTest extends EntityconnectTestBase {
use StringTranslationTrait;
protected function setUp() {
parent::setUp();
$this->ecUser
->addRole('ec_edit');
$this->ecUser
->save();
$this
->setEcButtons(FALSE, TRUE);
$this
->drupalLogin($this->ecUser);
}
public function testEditButton() {
$this
->drupalCreateNode([
'type' => $this->testContentType
->id(),
'title' => 'Referenced Node',
'uid' => $this->ecUser
->id(),
]);
$this
->drupalGet('node/add/' . $this->testContentType
->id());
$this
->assertSession()
->buttonExists('Edit content');
$this
->assertSession()
->buttonNotExists('New content');
$base_page = $this
->getSession()
->getPage();
$base_page
->fillField('title[0][value]', 'Base ' . $this->testContentType
->label());
$ref_field = $this
->getSession()
->getPage()
->findField($this->testRefField
->getName());
$ref_field
->selectOption('Referenced Node');
$base_page
->findButton('Edit content')
->click();
$ref_page = $this
->getSession()
->getPage();
$this
->assertSession()
->fieldValueEquals('title[0][value]', 'Referenced Node');
$ref_page
->fillField('body[0][value]', 'Some text.');
$ref_page
->findButton('Save')
->click();
$base_page = $this
->getSession()
->getPage();
$base_page
->findButton('Save')
->click();
$this
->assertSession()
->pageTextContains('Referenced Node');
$base_page
->clickLink('Referenced Node');
$this
->assertSession()
->pageTextContains('Some text.');
}
}