PdfUsingMpdfMenuAccessTest.php in PDF using mPDF 8.2
File
tests/src/Functional/PdfUsingMpdfMenuAccessTest.php
View source
<?php
namespace Drupal\Tests\pdf_using_mpdf\Functional;
class PdfUsingMpdfMenuAccessTest extends PdfUsingMpdfTestBase {
protected function setUp() {
parent::setUp();
}
public function testMenuAccess() {
$edit = [];
$this
->drupalLogin($this->adminUser);
foreach ($this->nodeTypes as $nodeType) {
$edit = [
'authenticated[generate ' . $nodeType
->id() . ' pdf]' => TRUE,
'anonymous[generate ' . $nodeType
->id() . ' pdf]' => TRUE,
];
break;
}
$this
->drupalPostForm('admin/people/permissions', $edit, 'Save permissions');
$node_type_a = $this
->createNode([
'type' => 'type_a',
]);
$node_type_b = $this
->createNode([
'type' => 'type_b',
]);
$this
->drupalLogout();
$this
->drupalLogin($this->accessUser);
$this
->drupalGet('node/' . $node_type_a
->id() . '/pdf');
$this
->assertSession()
->statusCodeEquals(200);
$this
->drupalGet('node/' . $node_type_b
->id() . '/pdf');
$this
->assertSession()
->statusCodeEquals(403);
$this
->drupalLogout();
$this
->drupalGet('node/' . $node_type_a
->id() . '/pdf');
$this
->assertSession()
->statusCodeEquals(200);
$this
->drupalGet('node/' . $node_type_b
->id() . '/pdf');
$this
->assertSession()
->statusCodeEquals(403);
}
}