Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

納品書PDF出力のメディアボックスがサイズ0になる問題を修正 #476

Merged
merged 1 commit into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions data/class/SC_Fpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:ダウンロード)
Expand Down
45 changes: 45 additions & 0 deletions tests/class/SC_FpdfTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

class SC_FpdfTest extends Common_TestCase
{
/** @var FixtureGenerator */
protected $objGenerator;

protected function setUp()
{
parent::setUp();
$this->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);
}
}