PrintableFormTest.php in Printer and PDF versions for Drupal 8+ 2.x
File
src/Tests/PrintableFormTest.php
View source
<?php
namespace Drupal\printable\Tests;
use Drupal\Tests\BrowserTestBase;
class PrintableFormTest extends BrowserTestBase {
public static $modules = [
'printable',
];
private $user;
public function setUp() {
parent::setUp();
$this->user = $this
->drupalCreateUser([
'administer printable',
]);
$this
->drupalLogin($this->user);
}
public function testPrintFormWorks() {
$this
->drupalLogin($this->user);
$this
->drupalGet('admin/config/user-interface/printable/print');
$this
->assertResponse(200);
$config = $this
->config('printable.settings');
$this
->assertFieldByName('print_html_sendtoprinter', $config
->get('printable.send_to_printer'), 'The field was found with the correct value.');
$this
->drupalPostForm(NULL, [
'print_html_sendtoprinter' => 1,
], t('Submit'));
$this
->drupalGet('admin/config/user-interface/printable/print');
$this
->assertResponse(200);
$this
->assertFieldByName('print_html_sendtoprinter', 1, 'The field was found with the correct value.');
}
}