mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Tests for PDF generation?
This commit is contained in:
parent
d9324697c0
commit
a0abd052b2
@ -33,6 +33,7 @@
|
||||
"predis/predis": "^1.1",
|
||||
"sentry/sentry-laravel": "^1.0",
|
||||
"simshaun/recurr": "^4.0",
|
||||
"spatie/browsershot": "^3.29",
|
||||
"superbalist/laravel-google-cloud-storage": "^2.2",
|
||||
"webpatser/laravel-countries": "dev-master#75992ad",
|
||||
"wildbit/postmark-php": "^2.6"
|
||||
|
115
package.json
115
package.json
@ -1,59 +1,60 @@
|
||||
{
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "npm run development",
|
||||
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||
"watch": "npm run development -- --watch",
|
||||
"watch-poll": "npm run watch -- --watch-poll",
|
||||
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||
"prod": "npm run production",
|
||||
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||
"test": "jest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@coreui/coreui": "^2.0.12",
|
||||
"@coreui/coreui-plugin-chartjs-custom-tooltips": "1.2.0",
|
||||
"@coreui/icons": "^0.3.0",
|
||||
"@types/bluebird": "^3.5.25",
|
||||
"@types/core-js": "^0.9.36",
|
||||
"@types/jest": "^23.3.9",
|
||||
"axios": "^0.18",
|
||||
"babel-preset-stage-2": "^6.24.1",
|
||||
"bootstrap": "^4.0.0",
|
||||
"chart.js": "^2.7.3",
|
||||
"cross-env": "^5.1",
|
||||
"flag-icon-css": "3.2.0",
|
||||
"font-awesome": "^4.7",
|
||||
"jest": "^23.6.0",
|
||||
"jquery": "^3.2",
|
||||
"laravel-mix": "^2.0",
|
||||
"pace-progress": "1.0.2",
|
||||
"perfect-scrollbar": "1.4.0",
|
||||
"popper.js": "^1.12",
|
||||
"simple-line-icons": "2.4.1",
|
||||
"ts-jest": "^23.10.5",
|
||||
"vue": "^2.5.17",
|
||||
"vuetable-2": "^1.7.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/lodash": "^4.14.118",
|
||||
"@types/node": "^10.12.10",
|
||||
"axios-progress-bar": "^1.2.0",
|
||||
"chalk": "^2.4.2",
|
||||
"hashids": "^1.2.2",
|
||||
"laravel-echo": "^1.4.0",
|
||||
"lodash.get": "^4.4.2",
|
||||
"quill": "^1.3.6",
|
||||
"socket.io-client": "^2.1.1",
|
||||
"ts-loader": "3.5.0",
|
||||
"typescript": "^3.1.6",
|
||||
"vue-affix": "^0.4.0",
|
||||
"vue-chartjs": "^3.4.0",
|
||||
"vue-events": "^3.1.0",
|
||||
"vue-multiselect": "^2.1.3",
|
||||
"vue-scrollactive": "^0.8.0",
|
||||
"vue-select": "^2.5.1",
|
||||
"vue-toastr": "^2.0.16",
|
||||
"vuex": "^3.1.0"
|
||||
}
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "npm run development",
|
||||
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||
"watch": "npm run development -- --watch",
|
||||
"watch-poll": "npm run watch -- --watch-poll",
|
||||
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||
"prod": "npm run production",
|
||||
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||
"test": "jest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@coreui/coreui": "^2.0.12",
|
||||
"@coreui/coreui-plugin-chartjs-custom-tooltips": "1.2.0",
|
||||
"@coreui/icons": "^0.3.0",
|
||||
"@types/bluebird": "^3.5.25",
|
||||
"@types/core-js": "^0.9.36",
|
||||
"@types/jest": "^23.3.9",
|
||||
"axios": "^0.18",
|
||||
"babel-preset-stage-2": "^6.24.1",
|
||||
"bootstrap": "^4.0.0",
|
||||
"chart.js": "^2.7.3",
|
||||
"cross-env": "^5.1",
|
||||
"flag-icon-css": "3.2.0",
|
||||
"font-awesome": "^4.7",
|
||||
"jest": "^23.6.0",
|
||||
"jquery": "^3.2",
|
||||
"laravel-mix": "^2.0",
|
||||
"pace-progress": "1.0.2",
|
||||
"perfect-scrollbar": "1.4.0",
|
||||
"popper.js": "^1.12",
|
||||
"simple-line-icons": "2.4.1",
|
||||
"ts-jest": "^23.10.5",
|
||||
"vue": "^2.5.17",
|
||||
"vuetable-2": "^1.7.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/lodash": "^4.14.118",
|
||||
"@types/node": "^10.12.10",
|
||||
"axios-progress-bar": "^1.2.0",
|
||||
"chalk": "^2.4.2",
|
||||
"hashids": "^1.2.2",
|
||||
"laravel-echo": "^1.4.0",
|
||||
"lodash.get": "^4.4.2",
|
||||
"puppeteer": "^1.15.0",
|
||||
"quill": "^1.3.6",
|
||||
"socket.io-client": "^2.1.1",
|
||||
"ts-loader": "3.5.0",
|
||||
"typescript": "^3.1.6",
|
||||
"vue-affix": "^0.4.0",
|
||||
"vue-chartjs": "^3.4.0",
|
||||
"vue-events": "^3.1.0",
|
||||
"vue-multiselect": "^2.1.3",
|
||||
"vue-scrollactive": "^0.8.0",
|
||||
"vue-select": "^2.5.1",
|
||||
"vue-toastr": "^2.0.16",
|
||||
"vuex": "^3.1.0"
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,10 @@
|
||||
<testsuite name="Feature">
|
||||
<directory suffix="Test.php">./tests/Feature</directory>
|
||||
</testsuite>
|
||||
|
||||
<testsuite name="Pdf">
|
||||
<directory suffix="Test.php">./tests/Pdf</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
|
33
tests/Pdf/PdfGenerationTest.php
Normal file
33
tests/Pdf/PdfGenerationTest.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Pdf;
|
||||
|
||||
use Spatie\Browsershot\Browsershot;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @test
|
||||
//@covers App\DataMapper\BaseSettings
|
||||
*/
|
||||
class PdfGenerationTest extends TestCase
|
||||
{
|
||||
|
||||
public function setUp() :void
|
||||
{
|
||||
|
||||
parent::setUp();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function testPdfGeneration()
|
||||
{
|
||||
$html = file_get_contents(base_path().'/tests/Pdf/invoice.html');
|
||||
$pdf = base_path().'/tests/Pdf/invoice.pdf';
|
||||
|
||||
Browsershot::html($html)->save($pdf);
|
||||
|
||||
$this->assertTrue(file_exists($pdf));
|
||||
|
||||
}
|
||||
}
|
213
tests/Pdf/invoice.html
Normal file
213
tests/Pdf/invoice.html
Normal file
@ -0,0 +1,213 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>A simple, clean, and responsive HTML invoice template</title>
|
||||
|
||||
<style>
|
||||
.invoice-box {
|
||||
max-width: 800px;
|
||||
margin: auto;
|
||||
padding: 30px;
|
||||
border: 1px solid #eee;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, .15);
|
||||
font-size: 16px;
|
||||
line-height: 24px;
|
||||
font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.invoice-box table {
|
||||
width: 100%;
|
||||
line-height: inherit;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.invoice-box table td {
|
||||
padding: 5px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.invoice-box table tr td:nth-child(2) {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.invoice-box table tr.top table td {
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
.invoice-box table tr.top table td.title {
|
||||
font-size: 45px;
|
||||
line-height: 45px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.invoice-box table tr.information table td {
|
||||
padding-bottom: 40px;
|
||||
}
|
||||
|
||||
.invoice-box table tr.heading td {
|
||||
background: #eee;
|
||||
border-bottom: 1px solid #ddd;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.invoice-box table tr.details td {
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
.invoice-box table tr.item td{
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.invoice-box table tr.item.last td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.invoice-box table tr.total td:nth-child(2) {
|
||||
border-top: 2px solid #eee;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 600px) {
|
||||
.invoice-box table tr.top table td {
|
||||
width: 100%;
|
||||
display: block;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.invoice-box table tr.information table td {
|
||||
width: 100%;
|
||||
display: block;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
/** RTL **/
|
||||
.rtl {
|
||||
direction: rtl;
|
||||
font-family: Tahoma, 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
.rtl table {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.rtl table tr td:nth-child(2) {
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="invoice-box">
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<tr class="top">
|
||||
<td colspan="2">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="title">
|
||||
<img src="https://www.sparksuite.com/images/logo.png" style="width:100%; max-width:300px;">
|
||||
</td>
|
||||
|
||||
<td>
|
||||
Invoice #: 123<br>
|
||||
Created: January 1, 2015<br>
|
||||
Due: February 1, 2015
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="information">
|
||||
<td colspan="2">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
Sparksuite, Inc.<br>
|
||||
12345 Sunny Road<br>
|
||||
Sunnyville, CA 12345
|
||||
</td>
|
||||
|
||||
<td>
|
||||
Acme Corp.<br>
|
||||
John Doe<br>
|
||||
john@example.com
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="heading">
|
||||
<td>
|
||||
Payment Method
|
||||
</td>
|
||||
|
||||
<td>
|
||||
Check #
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="details">
|
||||
<td>
|
||||
Check
|
||||
</td>
|
||||
|
||||
<td>
|
||||
1000
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="heading">
|
||||
<td>
|
||||
Item
|
||||
</td>
|
||||
|
||||
<td>
|
||||
Price
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="item">
|
||||
<td>
|
||||
Website design
|
||||
</td>
|
||||
|
||||
<td>
|
||||
$300.00
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="item">
|
||||
<td>
|
||||
Hosting (3 months)
|
||||
</td>
|
||||
|
||||
<td>
|
||||
$75.00
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="item last">
|
||||
<td>
|
||||
Domain name (1 year)
|
||||
</td>
|
||||
|
||||
<td>
|
||||
$10.00
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="total">
|
||||
<td></td>
|
||||
|
||||
<td>
|
||||
Total: $385.00
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user