Same name in other branches
  1. 2.x tests/src/Functional/EntityCloneContentTest.php \Drupal\Tests\entity_clone\Functional\EntityCloneContentTest::testContentEntityClone()

Test content entity clone.

Fichier

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

Classe

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->drupalGet('entity_clone/node/' . $node->id());
    $this->submitForm([], $this->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.');
}