Merge pull request #3925 from beganovich/v2-2207-pdfmaker-changes

Moving PdfMaker out of tests folder
This commit is contained in:
David Bomba 2020-07-23 07:41:11 +10:00 committed by GitHub
commit 3f1d877273
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 263 additions and 145 deletions

View File

@ -0,0 +1,23 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Services\PdfMaker\Designs;
class Bold
{
public function html()
{
return file_get_contents(
base_path('resources/views/pdf-designs//bold.html')
);
}
}

View File

@ -0,0 +1,23 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Services\PdfMaker\Designs;
class Business
{
public function html()
{
return file_get_contents(
base_path('resources/views/pdf-designs//business.html')
);
}
}

View File

@ -0,0 +1,23 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Services\PdfMaker\Designs;
class Clean
{
public function html()
{
return file_get_contents(
base_path('resources/views/pdf-designs//clean.html')
);
}
}

View File

@ -0,0 +1,23 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Services\PdfMaker\Designs;
class Creative
{
public function html()
{
return file_get_contents(
base_path('resources/views/pdf-designs//creative.html')
);
}
}

View File

@ -0,0 +1,23 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Services\PdfMaker\Designs;
class Elegant
{
public function html()
{
return file_get_contents(
base_path('resources/views/pdf-designs//elegant.html')
);
}
}

View File

@ -0,0 +1,23 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Services\PdfMaker\Designs;
class Hipster
{
public function html()
{
return file_get_contents(
base_path('resources/views/pdf-designs//hipster.html')
);
}
}

View File

@ -0,0 +1,23 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Services\PdfMaker\Designs;
class Modern
{
public function html()
{
return file_get_contents(
base_path('resources/views/pdf-designs//modern.html')
);
}
}

View File

@ -0,0 +1,23 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Services\PdfMaker\Designs;
class Plain
{
public function html()
{
return file_get_contents(
base_path('resources/views/pdf-designs//plain.html')
);
}
}

View File

@ -0,0 +1,23 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Services\PdfMaker\Designs;
class Playful
{
public function html()
{
return file_get_contents(
base_path('resources/views/pdf-designs//playful.html')
);
}
}

View File

@ -1,6 +1,16 @@
<?php
namespace Tests\Feature\PdfMaker;
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Services\PdfMaker;
class PdfMaker
{

View File

@ -1,6 +1,16 @@
<?php
namespace Tests\Feature\PdfMaker;
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Services\PdfMaker;
use DOMDocument;
use DOMXPath;

View File

@ -1,13 +0,0 @@
<?php
namespace Tests\Feature\PdfMaker;
class Bold
{
public function html()
{
return file_get_contents(
base_path('tests/Feature/PdfMaker/designs/bold.html')
);
}
}

View File

@ -1,13 +0,0 @@
<?php
namespace Tests\Feature\PdfMaker;
class Business
{
public function html()
{
return file_get_contents(
base_path('tests/Feature/PdfMaker/designs/business.html')
);
}
}

View File

@ -1,13 +0,0 @@
<?php
namespace Tests\Feature\PdfMaker;
class Clean
{
public function html()
{
return file_get_contents(
base_path('tests/Feature/PdfMaker/designs/clean.html')
);
}
}

View File

@ -1,13 +0,0 @@
<?php
namespace Tests\Feature\PdfMaker;
class Creative
{
public function html()
{
return file_get_contents(
base_path('tests/Feature/PdfMaker/designs/creative.html')
);
}
}

View File

@ -1,13 +0,0 @@
<?php
namespace Tests\Feature\PdfMaker;
class Elegant
{
public function html()
{
return file_get_contents(
base_path('tests/Feature/PdfMaker/designs/elegant.html')
);
}
}

View File

@ -2,12 +2,12 @@
namespace Tests\Feature\PdfMaker;
class Modern
class ExampleDesign
{
public function html()
{
return file_get_contents(
base_path('tests/Feature/PdfMaker/designs/modern.html')
base_path('tests/Feature/PdfMaker/example-design.html')
);
}
}

View File

@ -1,13 +0,0 @@
<?php
namespace Tests\Feature\PdfMaker;
class Hipster
{
public function html()
{
return file_get_contents(
base_path('tests/Feature/PdfMaker/designs/hipster.html')
);
}
}

View File

@ -2,6 +2,16 @@
namespace Tests\Feature\PdfMaker;
use App\Services\PdfMaker\Designs\Bold;
use App\Services\PdfMaker\Designs\Business;
use App\Services\PdfMaker\Designs\Clean;
use App\Services\PdfMaker\Designs\Creative;
use App\Services\PdfMaker\Designs\Elegant;
use App\Services\PdfMaker\Designs\Hipster;
use App\Services\PdfMaker\Designs\Modern;
use App\Services\PdfMaker\Designs\Plain;
use App\Services\PdfMaker\Designs\Playful;
use App\Services\PdfMaker\PdfMaker;
use Tests\TestCase;
class PdfMakerDesignsTest extends TestCase
@ -246,7 +256,6 @@ class PdfMakerDesignsTest extends TestCase
info($maker->getCompiledHTML(true));
$this->assertTrue(true);
}
public function testModern()
@ -362,7 +371,6 @@ class PdfMakerDesignsTest extends TestCase
info($maker->getCompiledHTML(true));
$this->assertTrue(true);
}
@ -479,7 +487,6 @@ class PdfMakerDesignsTest extends TestCase
info($maker->getCompiledHTML(true));
$this->assertTrue(true);
}
public function testPlain()
@ -587,7 +594,6 @@ class PdfMakerDesignsTest extends TestCase
info($maker->getCompiledHTML(true));
$this->assertTrue(true);
}
public function testHipster()
@ -699,7 +705,6 @@ class PdfMakerDesignsTest extends TestCase
info($maker->getCompiledHTML(true));
$this->assertTrue(true);
}
public function testElegant()
@ -815,7 +820,6 @@ class PdfMakerDesignsTest extends TestCase
info($maker->getCompiledHTML(true));
$this->assertTrue(true);
}
public function testCreative()
@ -931,7 +935,6 @@ class PdfMakerDesignsTest extends TestCase
info($maker->getCompiledHTML(true));
$this->assertTrue(true);
}
public function testPlayful()
@ -1039,8 +1042,6 @@ class PdfMakerDesignsTest extends TestCase
info($maker->getCompiledHTML(true));
$this->assertTrue(true);
}
}

View File

@ -2,6 +2,7 @@
namespace Tests\Feature\PdfMaker;
use App\Services\PdfMaker\PdfMaker;
use Spatie\Browsershot\Browsershot;
use Tests\TestCase;
@ -12,18 +13,13 @@ class PdfMakerTest extends TestCase
'variables' => [],
];
public function setUp() :void
{
$this->markTestSkipped();
}
public function testDesignLoadsCorrectly()
{
$maker = new PdfMaker($this->state);
$maker->design(Business::class);
$maker->design(ExampleDesign::class);
$this->assertInstanceOf(Business::class, $maker->design);
$this->assertInstanceOf(ExampleDesign::class, $maker->design);
}
public function testHtmlDesignLoadsCorrectly()
@ -31,7 +27,7 @@ class PdfMakerTest extends TestCase
$maker = new PdfMaker($this->state);
$maker
->design(Business::class)
->design(ExampleDesign::class)
->build();
$this->assertStringContainsString('<!-- Business -->', $maker->getCompiledHTML());
@ -42,7 +38,7 @@ class PdfMakerTest extends TestCase
$maker = new PdfMaker($this->state);
$maker
->design(Business::class)
->design(ExampleDesign::class)
->build();
$this->assertEquals('table', $maker->getSectionNode('product-table')->nodeName);
@ -73,7 +69,7 @@ class PdfMakerTest extends TestCase
$maker = new PdfMaker($state);
$maker
->design(Business::class)
->design(ExampleDesign::class)
->build();
$this->assertStringContainsString('my-awesome-class', $maker->getSection('product-table', 'class'));
@ -108,7 +104,7 @@ class PdfMakerTest extends TestCase
$maker = new PdfMaker($state);
$maker
->design(Business::class)
->design(ExampleDesign::class)
->build();
$this->assertStringContainsString('Invoice Ninja', $maker->getCompiledHTML());
@ -152,7 +148,7 @@ class PdfMakerTest extends TestCase
$maker = new PdfMaker($state);
$maker
->design(Business::class)
->design(ExampleDesign::class)
->build();
$compiled = 'contact@invoiceninja.com';
@ -172,7 +168,7 @@ class PdfMakerTest extends TestCase
]);
$maker1
->design(Business::class)
->design(ExampleDesign::class)
->build();
$output1 = $maker1->getCompiledHTML();
@ -189,7 +185,7 @@ class PdfMakerTest extends TestCase
]);
$maker2
->design(Business::class)
->design(ExampleDesign::class)
->build();
$output2 = $maker2->getCompiledHTML();
@ -215,7 +211,7 @@ class PdfMakerTest extends TestCase
]);
$maker
->design(Business::class)
->design(ExampleDesign::class)
->build();
$node = $maker->getSectionNode('header');
@ -242,7 +238,7 @@ class PdfMakerTest extends TestCase
]);
$maker
->design(Business::class)
->design(ExampleDesign::class)
->build();
$node = $maker->getSectionNode('header');
@ -306,11 +302,9 @@ class PdfMakerTest extends TestCase
$maker = new PdfMaker($state);
$maker
->design(Business::class)
->design(ExampleDesign::class)
->build();
info($maker->getCompiledHTML());
$this->assertTrue(true);
}
}

View File

@ -1,13 +0,0 @@
<?php
namespace Tests\Feature\PdfMaker;
class Plain
{
public function html()
{
return file_get_contents(
base_path('tests/Feature/PdfMaker/designs/plain.html')
);
}
}

View File

@ -1,13 +0,0 @@
<?php
namespace Tests\Feature\PdfMaker;
class Playful
{
public function html()
{
return file_get_contents(
base_path('tests/Feature/PdfMaker/designs/playful.html')
);
}
}