Merge pull request #19497 from eileenmcnaughton/534
authorSeamus Lee <seamuslee001@gmail.com>
Tue, 2 Feb 2021 02:14:59 +0000 (13:14 +1100)
committerGitHub <noreply@github.com>
Tue, 2 Feb 2021 02:14:59 +0000 (13:14 +1100)
Fix for ReportTest when launching a pdf

CRM/Utils/PDF/Utils.php

index 7ea2bcf12f04152756c7f39833f0207d24fe85f2..526202cb7c1f907425d6e5f6d9bb8296d1222f99 100644 (file)
@@ -193,7 +193,9 @@ class CRM_Utils_PDF_Utils {
     }
     // CRM-19183 remove .pdf extension from filename
     $fileName = basename($fileName, ".pdf");
-    if (CIVICRM_UF === 'UnitTests') {
+    if (CIVICRM_UF === 'UnitTests' && headers_sent()) {
+      // Streaming content will 'die' in unit tests unless ob_start()
+      // has been called.
       throw new CRM_Core_Exception_PrematureExitException('_html2pdf_dompdf called', [
         'html' => $html,
         'fileName' => $fileName,