Unit tests for TCPDF and mPDF
This commit is contained in:
parent
f7bee23f65
commit
0360f8e290
|
|
@ -22,8 +22,6 @@ before_script:
|
|||
- sudo apt-get -qq install graphviz > /dev/null
|
||||
## Composer
|
||||
- composer self-update
|
||||
- composer require dompdf/dompdf:0.6.*
|
||||
- composer update --prefer-source --dev
|
||||
- composer install --prefer-source --dev
|
||||
## PHP Copy/Paste Detector
|
||||
- curl -o phpcpd.phar https://phar.phpunit.de/phpcpd.phar
|
||||
|
|
|
|||
|
|
@ -39,7 +39,10 @@
|
|||
"require-dev": {
|
||||
"phpunit/phpunit": "3.7.*",
|
||||
"phpdocumentor/phpdocumentor":"2.*",
|
||||
"squizlabs/php_codesniffer": "1.*"
|
||||
"squizlabs/php_codesniffer": "1.*",
|
||||
"dompdf/dompdf":"0.6.*",
|
||||
"tecnick.com/tcpdf": "6.*",
|
||||
"mpdf/mpdf": "5.*"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-gd2": "Required to add images",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
|
||||
],
|
||||
"hash": "d46ea4154e935e4be01ffbad0a67bab2",
|
||||
"hash": "91993ff980d11a416fcf3a7309a4044f",
|
||||
"packages": [
|
||||
|
||||
],
|
||||
|
|
@ -619,6 +619,49 @@
|
|||
],
|
||||
"time": "2014-04-24 13:29:03"
|
||||
},
|
||||
{
|
||||
"name": "mpdf/mpdf",
|
||||
"version": "v5.7.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/finwe/mpdf.git",
|
||||
"reference": "1627f9e7d2ef0f635a886f611079216ed2929717"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/finwe/mpdf/zipball/1627f9e7d2ef0f635a886f611079216ed2929717",
|
||||
"reference": "1627f9e7d2ef0f635a886f611079216ed2929717",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-mbstring": "*",
|
||||
"php": ">=4.3.10"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"mpdf.php",
|
||||
"classes"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"GPL-1.0+"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ian Back"
|
||||
}
|
||||
],
|
||||
"description": "A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support",
|
||||
"homepage": "http://www.mpdf1.com/mpdf/index.php",
|
||||
"keywords": [
|
||||
"pdf",
|
||||
"php",
|
||||
"utf-8"
|
||||
],
|
||||
"time": "2014-05-16 07:18:10"
|
||||
},
|
||||
{
|
||||
"name": "nikic/php-parser",
|
||||
"version": "v0.9.4",
|
||||
|
|
@ -833,16 +876,16 @@
|
|||
},
|
||||
{
|
||||
"name": "phpdocumentor/phpdocumentor",
|
||||
"version": "v2.4.0",
|
||||
"version": "v2.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpDocumentor/phpDocumentor2.git",
|
||||
"reference": "d7503ada7386aa6b2956224d50a8d0226a22a99f"
|
||||
"reference": "bf9fa40f6d00412410025b2e16eb16c315eb0216"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpDocumentor/phpDocumentor2/zipball/d7503ada7386aa6b2956224d50a8d0226a22a99f",
|
||||
"reference": "d7503ada7386aa6b2956224d50a8d0226a22a99f",
|
||||
"url": "https://api.github.com/repos/phpDocumentor/phpDocumentor2/zipball/bf9fa40f6d00412410025b2e16eb16c315eb0216",
|
||||
"reference": "bf9fa40f6d00412410025b2e16eb16c315eb0216",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -895,12 +938,13 @@
|
|||
"ext-xslcache": "Enabling the XSLCache extension improves the generation of xml based templates."
|
||||
},
|
||||
"bin": [
|
||||
"bin/phpdoc.php"
|
||||
"bin/phpdoc.php",
|
||||
"bin/phpdoc"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-develop": "2.4-dev"
|
||||
"dev-develop": "2.5-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
|
@ -924,7 +968,7 @@
|
|||
"documentation",
|
||||
"phpdoc"
|
||||
],
|
||||
"time": "2014-04-01 18:14:51"
|
||||
"time": "2014-05-17 12:25:35"
|
||||
},
|
||||
{
|
||||
"name": "phpdocumentor/reflection",
|
||||
|
|
@ -2528,6 +2572,63 @@
|
|||
"homepage": "http://symfony.com",
|
||||
"time": "2014-04-18 20:37:09"
|
||||
},
|
||||
{
|
||||
"name": "tecnick.com/tcpdf",
|
||||
"version": "6.0.078",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "git://git.code.sf.net/p/tcpdf/code",
|
||||
"reference": "e1cbda79b99f3cdc8fdf26b39eb4870d2cd9fbac"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"fonts",
|
||||
"config",
|
||||
"include",
|
||||
"tcpdf.php",
|
||||
"tcpdf_parser.php",
|
||||
"tcpdf_import.php",
|
||||
"tcpdf_barcodes_1d.php",
|
||||
"tcpdf_barcodes_2d.php",
|
||||
"include/tcpdf_colors.php",
|
||||
"include/tcpdf_filters.php",
|
||||
"include/tcpdf_font_data.php",
|
||||
"include/tcpdf_fonts.php",
|
||||
"include/tcpdf_images.php",
|
||||
"include/tcpdf_static.php",
|
||||
"include/barcodes/datamatrix.php",
|
||||
"include/barcodes/pdf417.php",
|
||||
"include/barcodes/qrcode.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"LGPLv3"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicola Asuni",
|
||||
"email": "info@tecnick.com",
|
||||
"homepage": "http://nicolaasuni.tecnick.com"
|
||||
}
|
||||
],
|
||||
"description": "TCPDF is a PHP class for generating PDF documents.",
|
||||
"homepage": "http://www.tcpdf.org/",
|
||||
"keywords": [
|
||||
"PDFD32000-2008",
|
||||
"TCPDF",
|
||||
"barcodes",
|
||||
"datamatrix",
|
||||
"pdf",
|
||||
"pdf417",
|
||||
"qrcode"
|
||||
],
|
||||
"time": "2014-05-12 19:50:13"
|
||||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
"version": "v1.15.1",
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use PhpOffice\PhpWord\Autoloader;
|
|||
use PhpOffice\PhpWord\Settings;
|
||||
use PhpOffice\PhpWord\IOFactory;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||
define('CLI', (PHP_SAPI == 'cli') ? true : false);
|
||||
define('EOL', CLI ? PHP_EOL : '<br />');
|
||||
define('SCRIPT_FILENAME', basename($_SERVER['SCRIPT_FILENAME'], '.php'));
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class MPDF extends AbstractRenderer implements WriterInterface
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $includeFile = 'mdf.php';
|
||||
protected $includeFile = 'mpdf.php';
|
||||
|
||||
/**
|
||||
* Save PhpWord to file
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class DomPDFTest extends \PHPUnit_Framework_TestCase
|
|||
public function testConstruct()
|
||||
{
|
||||
define('DOMPDF_ENABLE_AUTOLOAD', false);
|
||||
$file = __DIR__ . "/../../_files/temp.pdf";
|
||||
$file = __DIR__ . "/../../_files/dompdf.pdf";
|
||||
|
||||
$phpWord = new PhpWord();
|
||||
$section = $phpWord->addSection();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2014 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\PDF;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Settings;
|
||||
use PhpOffice\PhpWord\Writer\PDF;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Writer\PDF\MPDF
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class MPDFTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test construct
|
||||
*/
|
||||
public function testConstruct()
|
||||
{
|
||||
$file = __DIR__ . "/../../_files/mpdf.pdf";
|
||||
|
||||
$phpWord = new PhpWord();
|
||||
$section = $phpWord->addSection();
|
||||
$section->addText('Test 1');
|
||||
|
||||
$rendererName = Settings::PDF_RENDERER_MPDF;
|
||||
$rendererLibraryPath = realpath(PHPWORD_TESTS_BASE_DIR . '/../vendor/mpdf/mpdf');
|
||||
Settings::setPdfRenderer($rendererName, $rendererLibraryPath);
|
||||
$writer = new PDF($phpWord);
|
||||
$writer->save($file);
|
||||
|
||||
$this->assertTrue(file_exists($file));
|
||||
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2014 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\PDF;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Settings;
|
||||
use PhpOffice\PhpWord\Writer\PDF;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Writer\PDF\TCPDF
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class TCPDFTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test construct
|
||||
*/
|
||||
public function testConstruct()
|
||||
{
|
||||
$file = __DIR__ . "/../../_files/tcpdf.pdf";
|
||||
|
||||
$phpWord = new PhpWord();
|
||||
$section = $phpWord->addSection();
|
||||
$section->addText('Test 1');
|
||||
|
||||
$rendererName = Settings::PDF_RENDERER_TCPDF;
|
||||
$rendererLibraryPath = realpath(PHPWORD_TESTS_BASE_DIR . '/../vendor/tecnick.com/tcpdf');
|
||||
Settings::setPdfRenderer($rendererName, $rendererLibraryPath);
|
||||
$writer = new PDF($phpWord);
|
||||
$writer->save($file);
|
||||
|
||||
$this->assertTrue(file_exists($file));
|
||||
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue