Skip to content

Commit

Permalink
Merge pull request #43 from liberu-genealogy/sweep/Add-unit-test-for-…
Browse files Browse the repository at this point in the history
…GEDCOM-export-error-handling

Add unit test for GEDCOM export error handling
  • Loading branch information
curtisdelicata authored Jul 28, 2024
2 parents bc76722 + e7b3f75 commit 08a55ba
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion tests/Unit/GedcomExporterTest.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
<?php

namespace Tests\Unit;

use FamilyTree365\LaravelGedcom\Commands\GedcomExporter;
use Illuminate\Support\Facades\Storage;
use Tests\TestCase;
use Mockery;

class GedcomExporterTest extends TestCase
{
public function setUp(): void
{
parent::setUp();
Storage::fake('local');
}

public function testHandlingOfFileWriteErrors()
{
Storage::shouldReceive('put')
->once()
->andThrow(new \Exception('Failed to write file'));

$this->artisan('gedcom:export', ['filename' => 'test_export'])
->expectsOutput('An error occurred while exporting the GEDCOM file: Failed to write file')
->assertExitCode(1);
}

public static function exportDataProvider()
{
return [
Expand All @@ -18,4 +46,11 @@ public static function exportDataProvider()
"0 @M1@ OBJE\n1 TITL Photo of John Doe\n"
],
];
}
}

public function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
}

0 comments on commit 08a55ba

Please sign in to comment.