@@ 23-53 (lines=31) @@ | ||
20 | * |
|
21 | * @author Ivannis Suárez Jerez <[email protected]> |
|
22 | */ |
|
23 | class AutoIncrementIdTests extends TestCase |
|
24 | { |
|
25 | /** |
|
26 | * Test class. |
|
27 | */ |
|
28 | public function testClass() |
|
29 | { |
|
30 | $this |
|
31 | ->testedClass |
|
32 | ->extends(Id::class) |
|
33 | ->implements(IdInterface::class) |
|
34 | ; |
|
35 | } |
|
36 | ||
37 | /** |
|
38 | * Test toNative method. |
|
39 | */ |
|
40 | public function testToNative() |
|
41 | { |
|
42 | $this |
|
43 | ->given($id = AutoIncrementId::fromNative(10)) |
|
44 | ->then |
|
45 | ->integer($id->toNative())->isEqualTo(10) |
|
46 | ->exception( |
|
47 | function () { |
|
48 | AutoIncrementId::fromNative('some-string'); |
|
49 | } |
|
50 | )->isInstanceOf(\InvalidArgumentException::class) |
|
51 | ; |
|
52 | } |
|
53 | } |
|
54 |
@@ 23-53 (lines=31) @@ | ||
20 | * |
|
21 | * @author Ivannis Suárez Jerez <[email protected]> |
|
22 | */ |
|
23 | class HashIdTests extends TestCase |
|
24 | { |
|
25 | /** |
|
26 | * Test class. |
|
27 | */ |
|
28 | public function testClass() |
|
29 | { |
|
30 | $this |
|
31 | ->testedClass |
|
32 | ->extends(Id::class) |
|
33 | ->implements(IdInterface::class) |
|
34 | ; |
|
35 | } |
|
36 | ||
37 | /** |
|
38 | * Test toNative method. |
|
39 | */ |
|
40 | public function testToNative() |
|
41 | { |
|
42 | $this |
|
43 | ->given($id = HashId::fromNative('GyuEmsRBfy61i59si0')) |
|
44 | ->then |
|
45 | ->string($id->toNative())->isEqualTo('GyuEmsRBfy61i59si0') |
|
46 | ->exception( |
|
47 | function () { |
|
48 | HashId::fromNative(109); |
|
49 | } |
|
50 | )->isInstanceOf(\InvalidArgumentException::class) |
|
51 | ; |
|
52 | } |
|
53 | } |
|
54 |
@@ 23-53 (lines=31) @@ | ||
20 | * |
|
21 | * @author Ivannis Suárez Jerez <[email protected]> |
|
22 | */ |
|
23 | class SequenceIdTests extends TestCase |
|
24 | { |
|
25 | /** |
|
26 | * Test class. |
|
27 | */ |
|
28 | public function testClass() |
|
29 | { |
|
30 | $this |
|
31 | ->testedClass |
|
32 | ->extends(Id::class) |
|
33 | ->implements(IdInterface::class) |
|
34 | ; |
|
35 | } |
|
36 | ||
37 | /** |
|
38 | * Test toNative method. |
|
39 | */ |
|
40 | public function testToNative() |
|
41 | { |
|
42 | $this |
|
43 | ->given($id = SequenceId::fromNative('000871667')) |
|
44 | ->then |
|
45 | ->string($id->toNative())->isEqualTo('000871667') |
|
46 | ->exception( |
|
47 | function () { |
|
48 | SequenceId::fromNative(654.28); |
|
49 | } |
|
50 | )->isInstanceOf(\InvalidArgumentException::class) |
|
51 | ; |
|
52 | } |
|
53 | } |
|
54 |