QuickNodeCloneTest.php in Quick Node Clone 8
File
tests/src/Functional/QuickNodeCloneTest.php
View source
<?php
namespace Drupal\Tests\quick_node_clone\Functional;
use Drupal\Tests\BrowserTestBase;
class QuickNodeCloneTest extends BrowserTestBase {
protected $profile = 'standard';
public static $modules = [
'quick_node_clone',
];
protected $adminUser;
protected function setUp() : void {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser([
'access administration pages',
'Administer Quick Node Clone Settings',
'clone page content',
'create page content',
]);
}
public function testNodeClone() {
$this
->drupalLogin($this->adminUser);
$edit = [
'text_to_prepend_to_title' => 'Cloned from',
];
$this
->drupalGet('admin/config/quick-node-clone');
$this
->submitForm($edit, 'Save configuration');
$title_value = $this->randomGenerator
->word(10);
$body_value = $this->randomGenerator
->sentences(10);
$edit = [
'title[0][value]' => $title_value,
'body[0][value]' => $body_value,
];
$this
->drupalGet('node/add/page');
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->responseContains($title_value);
$this
->assertSession()
->responseContains($body_value);
$this
->clickLink('Clone');
$node = $this
->getNodeByTitle($title_value);
$this
->drupalGet('clone/' . $node
->id() . '/quick_clone');
$this
->submitForm([], 'Save');
$this
->assertSession()
->responseContains('Cloned from ' . $title_value);
$this
->assertSession()
->responseContains($body_value);
}
}