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
|
- sudo apt-get -qq install graphviz > /dev/null
|
||||||
## Composer
|
## Composer
|
||||||
- composer self-update
|
- composer self-update
|
||||||
- composer require dompdf/dompdf:0.6.*
|
|
||||||
- composer update --prefer-source --dev
|
|
||||||
- composer install --prefer-source --dev
|
- composer install --prefer-source --dev
|
||||||
## PHP Copy/Paste Detector
|
## PHP Copy/Paste Detector
|
||||||
- curl -o phpcpd.phar https://phar.phpunit.de/phpcpd.phar
|
- curl -o phpcpd.phar https://phar.phpunit.de/phpcpd.phar
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,10 @@
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "3.7.*",
|
"phpunit/phpunit": "3.7.*",
|
||||||
"phpdocumentor/phpdocumentor":"2.*",
|
"phpdocumentor/phpdocumentor":"2.*",
|
||||||
"squizlabs/php_codesniffer": "1.*"
|
"squizlabs/php_codesniffer": "1.*",
|
||||||
|
"dompdf/dompdf":"0.6.*",
|
||||||
|
"tecnick.com/tcpdf": "6.*",
|
||||||
|
"mpdf/mpdf": "5.*"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-gd2": "Required to add images",
|
"ext-gd2": "Required to add images",
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
"This file locks the dependencies of your project to a known state",
|
"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"
|
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
|
||||||
],
|
],
|
||||||
"hash": "d46ea4154e935e4be01ffbad0a67bab2",
|
"hash": "91993ff980d11a416fcf3a7309a4044f",
|
||||||
"packages": [
|
"packages": [
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
@ -619,6 +619,49 @@
|
||||||
],
|
],
|
||||||
"time": "2014-04-24 13:29:03"
|
"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",
|
"name": "nikic/php-parser",
|
||||||
"version": "v0.9.4",
|
"version": "v0.9.4",
|
||||||
|
|
@ -833,16 +876,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpdocumentor/phpdocumentor",
|
"name": "phpdocumentor/phpdocumentor",
|
||||||
"version": "v2.4.0",
|
"version": "v2.5.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/phpDocumentor/phpDocumentor2.git",
|
"url": "https://github.com/phpDocumentor/phpDocumentor2.git",
|
||||||
"reference": "d7503ada7386aa6b2956224d50a8d0226a22a99f"
|
"reference": "bf9fa40f6d00412410025b2e16eb16c315eb0216"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/phpDocumentor/phpDocumentor2/zipball/d7503ada7386aa6b2956224d50a8d0226a22a99f",
|
"url": "https://api.github.com/repos/phpDocumentor/phpDocumentor2/zipball/bf9fa40f6d00412410025b2e16eb16c315eb0216",
|
||||||
"reference": "d7503ada7386aa6b2956224d50a8d0226a22a99f",
|
"reference": "bf9fa40f6d00412410025b2e16eb16c315eb0216",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
|
@ -895,12 +938,13 @@
|
||||||
"ext-xslcache": "Enabling the XSLCache extension improves the generation of xml based templates."
|
"ext-xslcache": "Enabling the XSLCache extension improves the generation of xml based templates."
|
||||||
},
|
},
|
||||||
"bin": [
|
"bin": [
|
||||||
"bin/phpdoc.php"
|
"bin/phpdoc.php",
|
||||||
|
"bin/phpdoc"
|
||||||
],
|
],
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-develop": "2.4-dev"
|
"dev-develop": "2.5-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
|
@ -924,7 +968,7 @@
|
||||||
"documentation",
|
"documentation",
|
||||||
"phpdoc"
|
"phpdoc"
|
||||||
],
|
],
|
||||||
"time": "2014-04-01 18:14:51"
|
"time": "2014-05-17 12:25:35"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpdocumentor/reflection",
|
"name": "phpdocumentor/reflection",
|
||||||
|
|
@ -2528,6 +2572,63 @@
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "http://symfony.com",
|
||||||
"time": "2014-04-18 20:37:09"
|
"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",
|
"name": "twig/twig",
|
||||||
"version": "v1.15.1",
|
"version": "v1.15.1",
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use PhpOffice\PhpWord\Autoloader;
|
||||||
use PhpOffice\PhpWord\Settings;
|
use PhpOffice\PhpWord\Settings;
|
||||||
use PhpOffice\PhpWord\IOFactory;
|
use PhpOffice\PhpWord\IOFactory;
|
||||||
|
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||||
define('CLI', (PHP_SAPI == 'cli') ? true : false);
|
define('CLI', (PHP_SAPI == 'cli') ? true : false);
|
||||||
define('EOL', CLI ? PHP_EOL : '<br />');
|
define('EOL', CLI ? PHP_EOL : '<br />');
|
||||||
define('SCRIPT_FILENAME', basename($_SERVER['SCRIPT_FILENAME'], '.php'));
|
define('SCRIPT_FILENAME', basename($_SERVER['SCRIPT_FILENAME'], '.php'));
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class MPDF extends AbstractRenderer implements WriterInterface
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $includeFile = 'mdf.php';
|
protected $includeFile = 'mpdf.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save PhpWord to file
|
* Save PhpWord to file
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ class DomPDFTest extends \PHPUnit_Framework_TestCase
|
||||||
public function testConstruct()
|
public function testConstruct()
|
||||||
{
|
{
|
||||||
define('DOMPDF_ENABLE_AUTOLOAD', false);
|
define('DOMPDF_ENABLE_AUTOLOAD', false);
|
||||||
$file = __DIR__ . "/../../_files/temp.pdf";
|
$file = __DIR__ . "/../../_files/dompdf.pdf";
|
||||||
|
|
||||||
$phpWord = new PhpWord();
|
$phpWord = new PhpWord();
|
||||||
$section = $phpWord->addSection();
|
$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