-
Notifications
You must be signed in to change notification settings - Fork 1
/
OptimusDriverTest.php
51 lines (44 loc) · 1.26 KB
/
OptimusDriverTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace Tests\Unit;
use InvalidArgumentException;
use Laravel\FakeId\Drivers\OptimusDriver;
use PHPUnit\Framework\TestCase;
/**
* Class OptimusDriverTest
*
* @package Tests\Unit
* @author Oanh Nguyen <oanhnn.bk@gmail.com>
* @license The MIT license
*/
class OptimusDriverTest extends TestCase
{
/**
* Test it should return same value with input after encode and decode
*
* @return void
*/
public function testItShouldReturnSameValueAfterEncodeAndDecode()
{
$driver = new OptimusDriver([
'prime' => 2019110711,
'inverse' => 1464972935,
'random' => 1388954641,
]);
$input = 123456;
$encoded = $driver->encode($input);
$decoded = $driver->decode($encoded);
$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([]);
}
}