Skip to content

Commit 9a13684

Browse files
committed
Added and modify the test case .
1 parent dd66839 commit 9a13684

File tree

5 files changed

+59
-40
lines changed

5 files changed

+59
-40
lines changed

tests/001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Check for Hashids presence
2+
Check for hashids presence
33
--SKIPIF--
44
<?php if (!extension_loaded("hashids")) print "skip"; ?>
55
--FILE--

tests/002.phpt

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Check for Hashids encode and decode
2+
Check for hashids encode and decode
33
--SKIPIF--
44
<?php if (!extension_loaded("hashids")) print "skip"; ?>
55
--FILE--
@@ -12,25 +12,6 @@ $numbers = $hashids->decode($hash); // [1, 2, 3, 4, 5]
1212

1313
echo $hash . "\n";
1414
print_r($numbers);
15-
16-
//or would you prefer to use a static method call
17-
$hash = Hashids::encode(1, 2, 3, 4, 5); // ADf9h9i0sQ
18-
$numbers = Hashids::decode($hash); // [1, 2, 3, 4, 5]
19-
20-
echo $hash . "\n";
21-
print_r($numbers);
22-
23-
//decode
24-
$numbers = $hashids->decode("ADf9h9i0sQ");
25-
print_r($numbers);
26-
27-
//encodeHex
28-
$hash = $hashids->encodeHex('FFFFDD'); // rYKPAK
29-
$hex = $hashids->decodeHex('rYKPAK'); // FFFFDD
30-
31-
echo $hash . "\n";
32-
echo $hex;
33-
3415
?>
3516
--EXPECT--
3617
ADf9h9i0sQ
@@ -42,22 +23,3 @@ Array
4223
[3] => 4
4324
[4] => 5
4425
)
45-
ADf9h9i0sQ
46-
Array
47-
(
48-
[0] => 1
49-
[1] => 2
50-
[2] => 3
51-
[3] => 4
52-
[4] => 5
53-
)
54-
Array
55-
(
56-
[0] => 1
57-
[1] => 2
58-
[2] => 3
59-
[3] => 4
60-
[4] => 5
61-
)
62-
rYKPAK
63-
FFFFDD

tests/003.phpt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Check for hashids static method call
3+
--SKIPIF--
4+
<?php if (!extension_loaded("hashids")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
8+
$hash = Hashids::encode(1, 2, 3, 4, 5); // ADf9h9i0sQ
9+
$numbers = Hashids::decode($hash); // [1, 2, 3, 4, 5]
10+
11+
echo $hash . "\n";
12+
print_r($numbers);
13+
?>
14+
--EXPECT--
15+
ADf9h9i0sQ
16+
Array
17+
(
18+
[0] => 1
19+
[1] => 2
20+
[2] => 3
21+
[3] => 4
22+
[4] => 5
23+
)

tests/004.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Check for hashids hex method
3+
--SKIPIF--
4+
<?php if (!extension_loaded("hashids")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
8+
$hashids = new Hashids();
9+
10+
$hash = $hashids->encodeHex('FFFFDD'); // rYKPAK
11+
$hex = $hashids->decodeHex('rYKPAK'); // FFFFDD
12+
13+
echo $hash . "\n";
14+
echo $hex . "\n";
15+
?>
16+
--EXPECT--
17+
rYKPAK
18+
FFFFDD

tests/005.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Check for hashids hex static method call
3+
--SKIPIF--
4+
<?php if (!extension_loaded("hashids")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
8+
$hash = Hashids::encodeHex('FFFFDD'); // rYKPAK
9+
$hex = Hashids::decodeHex('rYKPAK'); // FFFFDD
10+
11+
echo $hash . "\n";
12+
echo $hex . "\n";
13+
?>
14+
--EXPECT--
15+
rYKPAK
16+
FFFFDD

0 commit comments

Comments
 (0)