You are here

public function EntityCloneContentTest::testContentEntityClone in Entity Clone 8

Test content entity clone.

File

tests/src/Functional/EntityCloneContentTest.php, line 62

Class

EntityCloneContentTest
Create a content and test a clone.

Namespace

Drupal\Tests\entity_clone\Functional

Code

public function testContentEntityClone() {
  $node_title = $this
    ->randomMachineName(8);
  $node = Node::create([
    'type' => 'page',
    'title' => $node_title,
  ]);
  $node
    ->save();
  $this
    ->drupalPostForm('entity_clone/node/' . $node
    ->id(), [], t('Clone'));
  $nodes = \Drupal::entityTypeManager()
    ->getStorage('node')
    ->loadByProperties([
    'title' => $node_title . ' - Cloned',
  ]);
  $node = reset($nodes);
  $this
    ->assertInstanceOf(Node::class, $node, 'Test node cloned found in database.');
}