forked from etsy/411
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomTest.php
More file actions
32 lines (25 loc) · 1020 Bytes
/
Copy pathRandomTest.php
File metadata and controls
32 lines (25 loc) · 1020 Bytes
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
<?php
class RandomTest extends TestCase {
const NUM_BYTES = 16;
public function testBytes() {
$a = FOO\Random::bytes(self::NUM_BYTES);
$b = FOO\Random::bytes(self::NUM_BYTES);
$this->assertNotSame($a, $b);
$this->assertSame(strlen($a), self::NUM_BYTES);
$this->assertSame(strlen($b), self::NUM_BYTES);
}
public function testBase64Bytes() {
$a = base64_decode(FOO\Random::base64_bytes(self::NUM_BYTES));
$b = base64_decode(FOO\Random::base64_bytes(self::NUM_BYTES));
$this->assertNotSame($a, $b);
$this->assertSame(strlen($a), self::NUM_BYTES);
$this->assertSame(strlen($b), self::NUM_BYTES);
}
public function testHexBytes() {
$a = hex2bin(FOO\Random::hex_bytes(self::NUM_BYTES));
$b = hex2bin(FOO\Random::hex_bytes(self::NUM_BYTES));
$this->assertNotSame($a, $b);
$this->assertSame(strlen($a), self::NUM_BYTES);
$this->assertSame(strlen($b), self::NUM_BYTES);
}
}