| Total Complexity | 4 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class RandomAlphaNumericFunctionTest extends TestCase |
||
| 8 | { |
||
| 9 | |||
| 10 | public function test_random_alpha_numeric_with_default_number() |
||
| 11 | { |
||
| 12 | $random = randomstring(); |
||
| 13 | $this->assertSame(16, strlen($random)); |
||
| 14 | $this->assertRegExp('~[a-z0-9]~i', $random); |
||
| 15 | } |
||
| 16 | |||
| 17 | public function test_random_alpha_numeric_with_prefix() |
||
| 18 | { |
||
| 19 | $random = randomstring(64, 'ABC'); |
||
| 20 | $this->assertSame(67, strlen($random)); |
||
| 21 | $this->assertSame('ABC', substr($random, 0, 3)); |
||
| 22 | } |
||
| 23 | |||
| 24 | public function test_random_alpha_numeric_with_suffix() |
||
| 25 | { |
||
| 26 | $random = randomstring(128, '', 'ABC'); |
||
| 27 | $this->assertSame(131, strlen($random)); |
||
| 28 | $this->assertSame('ABC', substr($random, -3)); |
||
| 29 | } |
||
| 30 | |||
| 31 | public function test_random_alpha_numeric_with_prefix_and_suffix() |
||
| 32 | { |
||
| 33 | $random = randomstring(4, 'ABC-', '-XYZ'); |
||
| 34 | $this->assertSame(12, strlen($random)); |
||
| 35 | $this->assertRegExp('~ABC\-[a-z0-9]{4}\-XYZ~i', $random); |
||
| 36 | } |
||
| 38 |