public function FillPdfSettingsFormTest::testTemplateSchemePrivate in FillPDF 5.0.x
Same name and namespace in other branches
- 8.4 tests/src/Functional/FillPdfSettingsFormTest.php \Drupal\Tests\fillpdf\Functional\FillPdfSettingsFormTest::testTemplateSchemePrivate()
Tests the scheme settings with the 'private' stream wrapper.
File
- tests/
src/ Functional/ FillPdfSettingsFormTest.php, line 96
Class
- FillPdfSettingsFormTest
- @coversDefaultClass \Drupal\fillpdf\Form\FillPdfSettingsForm @group fillpdf
Namespace
Drupal\Tests\fillpdf\FunctionalCode
public function testTemplateSchemePrivate() {
// FillPDF is not yet configured.
// Configure FillPDF with the 'test' backend and the site default scheme,
// which at this point is 'public'.
$this
->configureFillPdf();
// Now on the settings form, switch to the 'private' scheme.
$this
->drupalPostForm(Url::fromRoute('fillpdf.settings'), [
'template_scheme' => 'private',
], 'Save configuration');
// Verify the new values have been submitted *and* successfully saved.
$this
->assertSession()
->pageTextContains('The configuration options have been saved.');
$this
->assertSession()
->fieldValueEquals('template_scheme', 'private');
$this
->assertEqual($this
->config('fillpdf.settings')
->get('template_scheme'), 'private');
// Now remove the private path from settings.php and rebuild the container.
$this
->writeSettings([
'settings' => [
'file_private_path' => (object) [
'value' => '',
'required' => TRUE,
],
],
]);
$this
->rebuildContainer();
// Reload the page to verify the 'private' scheme is gone.
$this
->drupalGet(Url::fromRoute('fillpdf.settings'));
$this
->assertSession()
->elementNotExists('css', '#edit-template-scheme-private');
$this
->assertSession()
->pageTextContains('Your previously used file storage private:// is no longer available');
// Verify that the site default scheme, which at this point is 'public', is
// preselected but not yet saved in config.
$this
->assertSession()
->fieldValueEquals('template_scheme', $this
->config('system.file')
->get('default_scheme'));
$this
->assertEqual($this
->config('fillpdf.settings')
->get('template_scheme'), 'private');
}