Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lvps committed Apr 26, 2024
1 parent 984d0a0 commit 563e60d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ resources/photos/
resources/pdftemplates/
tests/.phpunit.result.cache
resources/*/output/
tests/pdftemplates-test/output/*
49 changes: 11 additions & 38 deletions tests/SirTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
use PHPUnit\Framework\TestCase;
use WEEEOpen\Crauto\Sir;

const TEST_DIR = __DIR__ . '/../resources/pdftemplates-test';
const TEST_DIR = __DIR__ . '/pdftemplates-test';

class SirTest extends TestCase {
private static function delete_file(string $file) {
// Comment out if you want to check the output files
//unlink($file);
private static function delete_file(?string $file): void {
if(isset($file) && is_file($file)) {
// Comment out if you want to check the output files
unlink($file);
}
}

protected function setUp(): void {
Expand All @@ -23,11 +25,7 @@ protected function setUp(): void {

public function testGenerateSir() {
$pdfFilePath = null;
register_shutdown_function(function() use (&$pdfFilePath) {
if(is_file($pdfFilePath)) {
self::delete_file($pdfFilePath);
}
});
register_shutdown_function(function() use (&$pdfFilePath) { self::delete_file($pdfFilePath); });

$replacements = [
'[NAME]' => 'John',
Expand All @@ -45,11 +43,7 @@ public function testGenerateSir() {

public function testGenerateSirPhD() {
$pdfFilePath = null;
register_shutdown_function(function() use (&$pdfFilePath) {
if(is_file($pdfFilePath)) {
self::delete_file($pdfFilePath);
}
});
register_shutdown_function(function() use (&$pdfFilePath) { self::delete_file($pdfFilePath); });

$replacements = [
'[NAME]' => 'Andrea',
Expand All @@ -68,14 +62,7 @@ public function testGenerateSirPhD() {
public function testGenerateSir2() {
$pdfFilePath = null;
$pdfFilePath2 = null;
register_shutdown_function(function() use (&$pdfFilePath, &$pdfFilePath2) {
if(is_file($pdfFilePath)) {
self::delete_file($pdfFilePath);
}
if(is_file($pdfFilePath2)) {
self::delete_file($pdfFilePath2);
}
});
register_shutdown_function(function() use (&$pdfFilePath, &$pdfFilePath2) { self::delete_file($pdfFilePath); self::delete_file($pdfFilePath2); });

$replacements = [
'[NAME]' => 'John',
Expand Down Expand Up @@ -105,14 +92,7 @@ public function testGenerateSir2() {
public function testGenerateSirOnce() {
$pdfFilePath = null;
$pdfFilePath2 = null;
register_shutdown_function(function() use (&$pdfFilePath, &$pdfFilePath2) {
if(is_file($pdfFilePath)) {
self::delete_file($pdfFilePath);
}
if(is_file($pdfFilePath2)) {
self::delete_file($pdfFilePath2);
}
});
register_shutdown_function(function() use (&$pdfFilePath, &$pdfFilePath2) { self::delete_file($pdfFilePath); self::delete_file($pdfFilePath2); });

$replacements = [
'[NAME]' => 'John',
Expand All @@ -135,14 +115,7 @@ public function testGenerateSirOnce() {
public function testGenerateSirWithUpdate() {
$pdfFilePath = null;
$pdfFilePath2 = null;
register_shutdown_function(function() use (&$pdfFilePath, &$pdfFilePath2) {
if(is_file($pdfFilePath)) {
self::delete_file($pdfFilePath);
}
if(is_file($pdfFilePath2)) {
self::delete_file($pdfFilePath2);
}
});
register_shutdown_function(function() use (&$pdfFilePath, &$pdfFilePath2) { self::delete_file($pdfFilePath); self::delete_file($pdfFilePath2); });

$replacements = [
'[NAME]' => 'John',
Expand Down

0 comments on commit 563e60d

Please sign in to comment.