You are here

protected function FlexiformEntityFormTest::doFormCrud in Flexiform 8

Executes the form CRUD tests.

File

tests/src/Functional/FlexiformEntityFormTest.php, line 84

Class

FlexiformEntityFormTest
Flexiform functional test.

Namespace

Drupal\Tests\flexiform\Functional

Code

protected function doFormCrud() {
  $title1 = $this
    ->randomMachineName(8);
  $title2 = $this
    ->randomMachineName(10);
  $edit = [
    'title[0][value]' => $title1,
    'body[0][value]' => $this
      ->randomString(127),
  ];
  $this
    ->drupalPostForm('node/add/article', $edit, t('Save'));
  $node = $this
    ->drupalGetNodeByTitle($title1, TRUE);
  $this
    ->assertTrue($node, 'Article node found in the database.');
  $edit['title[0][value]'] = $title2;
  $this
    ->drupalPostForm('node/' . $node
    ->id() . '/edit', $edit, t('Save'));
  $node = $this
    ->drupalGetNodeByTitle($title1, TRUE);
  $this
    ->assertFalse($node, 'The Article node has been modified.');
  $node = $this
    ->drupalGetNodeByTitle($title2, TRUE);
  $this
    ->assertTrue($node, 'Modified Article node found in the database.');
  $this
    ->assertNotEquals($node
    ->label(), $title1, 'The Article node name has been modified.');
  $this
    ->drupalGet('node/' . $node
    ->id() . '/edit');
  $this
    ->clickLink(t('Delete'));
  $this
    ->drupalPostForm(NULL, [], t('Delete'));
  $node = $this
    ->drupalGetNodeByTitle($title2, TRUE);
  $this
    ->assertFalse($node, 'Article node not found in the database.');
}