mirror of
https://github.com/opdavies/gmail-filter-builder.git
synced 2025-02-02 00:47:32 +00:00
parent
db97fb8d60
commit
fbe1edf8f0
5
src/Exception/PartialNotFoundException.php
Normal file
5
src/Exception/PartialNotFoundException.php
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Opdavies\GmailFilterBuilder\Exception;
|
||||
|
||||
class PartialNotFoundException extends \RuntimeException {}
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Opdavies\GmailFilterBuilder\Service;
|
||||
|
||||
use Opdavies\GmailFilterBuilder\Exception\PartialNotFoundException;
|
||||
use Tightenco\Collect\Support\Collection;
|
||||
|
||||
/**
|
||||
|
@ -26,11 +27,13 @@ class Addresses
|
|||
return file_exists($file);
|
||||
});
|
||||
|
||||
if ($file) {
|
||||
return include $file;
|
||||
if (!$file) {
|
||||
throw new PartialNotFoundException(vsprintf('%s does not exist.', [
|
||||
$filename,
|
||||
]));
|
||||
}
|
||||
|
||||
return [];
|
||||
return include $file;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,6 +23,13 @@ class AddressesTest extends TestCase
|
|||
'bar@example.com'
|
||||
], FakeAddresses::load());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function throw_an_exception_an_address_file_does_not_exist() {
|
||||
$this->expectException(\RuntimeException::class);
|
||||
|
||||
Addresses::load('does-not-exist');
|
||||
}
|
||||
}
|
||||
|
||||
class FakeAddresses extends Addresses
|
||||
|
|
Loading…
Reference in a new issue