Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
oanhnn committed Nov 11, 2019
1 parent 455e408 commit 68e1810
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
14 changes: 14 additions & 0 deletions README.md
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Drivers/OptimusDriver.php
Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion tests/Integration/RoutesWithFakeIdTest.php
Expand Up @@ -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',
]);
}
Expand Down
14 changes: 14 additions & 0 deletions tests/Unit/OptimusDriverTest.php
Expand Up @@ -2,6 +2,7 @@

namespace Tests\Unit;

use InvalidArgumentException;
use Laravel\FakeId\Drivers\OptimusDriver;
use PHPUnit\Framework\TestCase;

Expand Down Expand Up @@ -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([]);
}
}

0 comments on commit 68e1810

Please sign in to comment.