From ecf806b20e05ab69f596a9d3a2a7957500c72b6c Mon Sep 17 00:00:00 2001 From: Kaoru Kobo <475350+kaorukobo@users.noreply.github.com> Date: Fri, 10 Sep 2021 16:17:41 +0900 Subject: [PATCH] =?UTF-8?q?=E7=B4=8D=E5=93=81=E6=9B=B8PDF=E5=87=BA?= =?UTF-8?q?=E5=8A=9B=E3=81=AE=E3=83=A1=E3=83=87=E3=82=A3=E3=82=A2=E3=83=9C?= =?UTF-8?q?=E3=83=83=E3=82=AF=E3=82=B9=E3=81=8C=E3=82=B5=E3=82=A4=E3=82=BA?= =?UTF-8?q?0=E3=81=AB=E3=81=AA=E3=82=8B=E5=95=8F=E9=A1=8C=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/class/SC_Fpdf.php | 2 ++ tests/class/SC_FpdfTest.php | 45 +++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 tests/class/SC_FpdfTest.php diff --git a/data/class/SC_Fpdf.php b/data/class/SC_Fpdf.php index 9cee4ecdca..9a2b57af16 100644 --- a/data/class/SC_Fpdf.php +++ b/data/class/SC_Fpdf.php @@ -57,6 +57,8 @@ class SC_Fpdf extends SC_Helper_FPDI public $pageno; public function __construct($download, $title, $tpl_pdf = 'nouhinsyo1.pdf') { + parent::__construct(); + // デフォルトの設定 $this->tpl_pdf = PDF_TEMPLATE_REALDIR . $tpl_pdf; // テンプレートファイル $this->pdf_download = $download; // PDFのダウンロード形式(0:表示、1:ダウンロード) diff --git a/tests/class/SC_FpdfTest.php b/tests/class/SC_FpdfTest.php new file mode 100644 index 0000000000..d232490d9f --- /dev/null +++ b/tests/class/SC_FpdfTest.php @@ -0,0 +1,45 @@ +objGenerator = new FixtureGenerator(); + } + + public function test_正しいMediaBox情報が出力される() + { + $order_id = $this->objGenerator->createOrder(0, []); + $objFormParam = new SC_FormParam_Ex(); + + $fpdf = new \SC_Fpdf(true, ""); + $objFormParam->setParam( + [ + 'order_id' => $order_id, + 'year' >= date('Y'), + 'month' => date('n'), + 'day' => date('j'), + + 'msg1' => 'このたびはお買上げいただきありがとうございます。', + 'msg2' => '下記の内容にて納品させていただきます。', + 'msg3' => 'ご確認くださいますよう、お願いいたします。', + ] + ); + + ob_start(); + $fpdf->createPdf($objFormParam); + $pdfContent = ob_get_clean(); + + preg_match("|/MediaBox.+|", $pdfContent, $matches); + $mediaBoxLine = $matches[0]; + + // 不正な出力。 + $this->assertNotEquals('/MediaBox [0 0 0.00 0.00]', $mediaBoxLine); + // 前行のテストをすり抜けた場合のダブルチェック。(本来の出力) + $this->assertEquals('/MediaBox [0 0 595.28 841.89]', $mediaBoxLine); + } +}