Skip to content

Commit 33ba0c2

Browse files
committed
FIxed test case .
1 parent 9d456d2 commit 33ba0c2

File tree

3 files changed

+74
-55
lines changed

3 files changed

+74
-55
lines changed
File renamed without changes.

tests/001.phpt

Lines changed: 11 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4,60 +4,16 @@ Check for hashids presence
44
<?php if (!extension_loaded("hashids")) print "skip"; ?>
55
--FILE--
66
<?php
7-
8-
$hashids = new Hashids();
9-
10-
$hash = $hashids->encode(1, 2, 3, 4, 5); // ADf9h9i0sQ
11-
$numbers = $hashids->decode($hash); // [1, 2, 3, 4, 5]
12-
13-
echo $hash . "\n";
14-
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-
7+
echo "hashids extension is available";
8+
/*
9+
you can add regression tests for your extension here
10+
the output of your test code has to be equal to the
11+
text in the --EXPECT-- section below for the tests
12+
to pass, differences between the output and the
13+
expected text are interpreted as failure
14+
see php5/README.TESTING for further information on
15+
writing regression tests
16+
*/
3417
?>
3518
--EXPECT--
36-
ADf9h9i0sQ
37-
Array
38-
(
39-
[0] => 1
40-
[1] => 2
41-
[2] => 3
42-
[3] => 4
43-
[4] => 5
44-
)
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
19+
hashids extension is available

tests/002.phpt

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
--TEST--
2+
Check for Hashids encode and decode
3+
--SKIPIF--
4+
<?php if (!extension_loaded("hashids")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
8+
$hashids = new Hashids();
9+
10+
$hash = $hashids->encode(1, 2, 3, 4, 5); // ADf9h9i0sQ
11+
$numbers = $hashids->decode($hash); // [1, 2, 3, 4, 5]
12+
13+
echo $hash . "\n";
14+
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+
34+
?>
35+
--EXPECT--
36+
ADf9h9i0sQ
37+
Array
38+
(
39+
[0] => 1
40+
[1] => 2
41+
[2] => 3
42+
[3] => 4
43+
[4] => 5
44+
)
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

0 commit comments

Comments
 (0)