From 68e1810615a7026016f9c110f95134c10e808a37 Mon Sep 17 00:00:00 2001 From: Oanh Nguyen Date: Mon, 11 Nov 2019 10:18:32 +0700 Subject: [PATCH] Update --- README.md | 14 ++++++++++++++ src/Drivers/OptimusDriver.php | 2 +- tests/Integration/RoutesWithFakeIdTest.php | 3 ++- tests/Unit/OptimusDriverTest.php | 14 ++++++++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 07765f1..d4d159c 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,20 @@ Begin by pulling in the package through Composer. $ composer require oanhnn/laravel-fakeid ``` +Publish config file with + +```bash +$ php artisan vendor:publish --provider="Laravel\\FakeId\\ServiceProvider" +``` + +or + +```bash +php artisan vendor:publish --tag=laravel-fakeid-config +``` + +Edit `config/fakeid.php` for config specific drivers. + ## Usage ### Getting start diff --git a/src/Drivers/OptimusDriver.php b/src/Drivers/OptimusDriver.php index 5d8b3ee..e08d3e6 100644 --- a/src/Drivers/OptimusDriver.php +++ b/src/Drivers/OptimusDriver.php @@ -33,7 +33,7 @@ class OptimusDriver implements Driver public function __construct(array $config) { if (!isset($config['prime'], $config['inverse'])) { - throw new InvalidArgumentException('prime and inverse must be specified.'); + throw new InvalidArgumentException('The prime and inverse must be specified.'); } $this->optimus = new Optimus( diff --git a/tests/Integration/RoutesWithFakeIdTest.php b/tests/Integration/RoutesWithFakeIdTest.php index 8012209..1e6d739 100644 --- a/tests/Integration/RoutesWithFakeIdTest.php +++ b/tests/Integration/RoutesWithFakeIdTest.php @@ -40,8 +40,9 @@ public function testItShouldMatchCorrect() $this->assertNotSame('/posts/' . $post->getKey(), $uri); $response = $this->getJson($uri); - $response->assertOk(); + $response->assertStatus(200); $response->assertJson([ + 'id' => $post->id, 'title' => 'Post test', ]); } diff --git a/tests/Unit/OptimusDriverTest.php b/tests/Unit/OptimusDriverTest.php index bf259c9..19e51ab 100644 --- a/tests/Unit/OptimusDriverTest.php +++ b/tests/Unit/OptimusDriverTest.php @@ -2,6 +2,7 @@ namespace Tests\Unit; +use InvalidArgumentException; use Laravel\FakeId\Drivers\OptimusDriver; use PHPUnit\Framework\TestCase; @@ -34,4 +35,17 @@ public function testItShouldReturnSameValueAfterEncodeAndDecode() $this->assertNotSame($input, $encoded); $this->assertSame($input, $decoded); } + + /** + * Test it should throw exception when it was created with invalid config options + * + * @return void + */ + public function testItShouldThrowExceptionWhenInvalidConfigOptions() + { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('The prime and inverse must be specified.'); + + new OptimusDriver([]); + } }