NodeFormTest.php in Acquia Content Hub 8
File
tests/src/Functional/NodeFormTest.php
View source
<?php
namespace Drupal\Tests\acquia_contenthub\Functional;
use Drupal\Core\StringTranslation\StringTranslationTrait;
class NodeFormTest extends ContentHubTestBase {
use ContentHubEntityTrait;
use StringTranslationTrait;
private $article;
public function testNodeForm() {
$this
->drupalLogin($this->adminUser);
$this->article = $this
->drupalCreateNode([
'type' => 'article',
]);
$this
->drupalGet('node/' . $this->article
->id() . '/edit');
$this
->assertSession()
->pageTextNotContains($this
->t('Acquia Content Hub settings'));
$this
->convertToContentHubEntity($this->article);
$node_edit_url = 'node/' . $this->article
->id() . '/edit';
$this
->drupalGet($node_edit_url);
$this
->assertSession()
->pageTextContains($this
->t('Acquia Content Hub settings'));
$this
->assertSession()
->checkboxChecked('edit-acquia-contenthub-auto-update');
$edit = [];
$edit['acquia_contenthub[auto_update]'] = FALSE;
$this
->submitForm($edit, $this
->t('Save'));
$this
->drupalGet($node_edit_url);
$this
->assertSession()
->checkboxNotChecked('edit-acquia-contenthub-auto-update');
}
public function testNodeFormIntroduceLocalChange() {
$this
->drupalLogin($this->adminUser);
$this->article = $this
->drupalCreateNode([
'type' => 'article',
]);
$this
->convertToContentHubEntity($this->article);
$node_edit_url = 'node/' . $this->article
->id() . '/edit';
$this
->drupalGet($node_edit_url);
$this
->assertSession()
->pageTextNotContains($this
->t('This syndicated content has been modified locally, therefore it is no longer automatically synchronized to its original content.'));
$this
->assertSession()
->checkboxChecked('edit-acquia-contenthub-auto-update');
$this
->submitForm([], $this
->t('Save'));
$this
->drupalGet($node_edit_url);
$this
->assertSession()
->pageTextNotContains($this
->t('This syndicated content has been modified locally, therefore it is no longer automatically synchronized to its original content.'));
$this
->assertSession()
->checkboxChecked('edit-acquia-contenthub-auto-update');
$edit = [];
$edit['title[0][value]'] = 'my new title';
$this
->submitForm($edit, $this
->t('Save'));
$this
->drupalGet($node_edit_url);
$this
->assertSession()
->pageTextContains($this
->t('This syndicated content has been modified locally, therefore it is no longer automatically synchronized to its original content.'));
$this
->assertSession()
->checkboxNotChecked('edit-acquia-contenthub-auto-update');
}
}