public function PrintableUninstallTest::testCustomPageExists in Printer and PDF versions for Drupal 8+ 8
Same name and namespace in other branches
- 2.x src/Tests/PrintableUninstallTest.php \Drupal\printable\Tests\PrintableUninstallTest::testCustomPageExists()
Tests that the node/{node}/printable/print path returns the right content.
File
- src/
Tests/ PrintableUninstallTest.php, line 37
Class
- PrintableUninstallTest
- Tests the whether printable module uninstall successfully.
Namespace
Drupal\printable\TestsCode
public function testCustomPageExists() {
$node_type_storage = \Drupal::entityManager()
->getStorage('node_type');
// Test /node/add page with only one content type.
$node_type_storage
->load('article')
->delete();
$this
->drupalGet('node/add');
$this
->assertResponse(200);
$this
->assertUrl('node/add/page');
// Create a node.
$edit = [];
$edit['title[0][value]'] = $this
->randomMachineName(8);
$edit['body[0][value]'] = $this
->randomMachineName(16);
$this
->drupalPostForm('node/add/page', $edit, t('Save'));
// Check that the Basic page has been created.
$this
->assertRaw(t('!post %title has been created.', [
'!post' => 'Basic page',
'%title' => $edit['title[0][value]'],
]), 'Basic page created.');
// Check that the node exists in the database.
$node = $this
->drupalGetNodeByTitle($edit['title[0][value]']);
$this
->assertTrue($node, 'Node found in database.');
// Verify that pages do not show submitted information by default.
$this
->drupalGet('node/' . $node
->id());
$this
->assertResponse(200);
$this
->drupalGet('node/' . $node
->id() . '/printable/print');
$this
->assertResponse(200);
// Uninstall the printable module and check the printable version of node
// is also deleted.
\Drupal::service('module_installer')
->uninstall([
'printable',
]);
$this
->drupalGet('node/' . $node
->id() . '/printable/print');
$this
->assertResponse(404);
}