PrintableLinkTest.php in Printer and PDF versions for Drupal 8+ 8
File
src/Tests/PrintableLinkTest.php
View source
<?php
namespace Drupal\printable\Tests;
use Drupal\node\Tests\NodeTestBase;
class PrintableLinkTest extends NodeTestBase {
public static $modules = [
'printable',
'node_test_exception',
'dblog',
];
public function setUp() {
parent::setUp();
$user = $this
->drupalCreateUser([
'create page content',
'edit own page content',
'view printer friendly versions',
'administer printable',
]);
$this
->drupalLogin($user);
}
public function testPrintLinkExists() {
$this
->drupalGet('admin/config/user-interface/printable/links');
$this
->assertResponse(200);
$this
->drupalPostForm(NULL, [
'print_print_link_pos' => 'node',
], t('Submit'));
$this
->drupalGet('admin/config/user-interface/printable/pdf');
$this
->assertResponse(200);
$node_type_storage = \Drupal::entityManager()
->getStorage('node_type');
$node_type_storage
->load('article')
->delete();
$this
->drupalGet('node/add');
$edit = [];
$edit['title[0][value]'] = $this
->randomMachineName(8);
$edit['body[0][value]'] = $this
->randomMachineName(16);
$this
->drupalPostForm('node/add/page', $edit, t('Save'));
$this
->assertRaw(t('!post %title has been created.', [
'!post' => 'Basic page',
'%title' => $edit['title[0][value]'],
]), 'Basic page created.');
$node = $this
->drupalGetNodeByTitle($edit['title[0][value]']);
$this
->assertTrue($node, 'Node found in database.');
$this
->drupalGet('node/' . $node
->id());
$this
->assertResponse(200);
$this
->assertRaw('Print', 'Print link discovered successfully in the printable page');
}
}