-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace ICanBoogie\CLDR\Provider; | ||
|
||
use ICanBoogie\CLDR\Provider; | ||
use LogicException; | ||
|
||
/** | ||
* A {@see Provider} that fails to provide any path. | ||
* | ||
* This provider is useful when you want to restrict the usage of the repository to warmed-up data. | ||
*/ | ||
final class FailingProvider implements Provider | ||
{ | ||
public function provide(string $path): array | ||
{ | ||
throw new LogicException("Only warmed-up data is available, tried to read from: $path"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Test\ICanBoogie\CLDR\Provider; | ||
|
||
use ICanBoogie\CLDR\Provider\FailingProvider; | ||
use LogicException; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @group static | ||
*/ | ||
class FailingProviderTest extends TestCase | ||
{ | ||
public function test_provide(): void | ||
{ | ||
$sut = new FailingProvider(); | ||
|
||
$this->expectException(LogicException::class); | ||
$this->expectExceptionMessageMatches("/Only warmed-up data is available/"); | ||
|
||
$sut->provide("foo"); | ||
} | ||
} |