1: <?php
2:
3: namespace PHPassLib\Test;
4:
5: use PHPassLib\Utilities;
6: use PHPUnit_Framework_TestCase as TestCase;
7:
8: class UtilitiesTest extends TestCase
9: {
10:
11: 12: 13: 14:
15: public function randomGeneratorReturnsExpectedStringLength()
16: {
17: $this->assertEquals(6, strlen(Utilities::genRandomBytes(6)));
18: $this->assertEquals(8, strlen(Utilities::genRandomBytes(8)));
19: $this->assertEquals(10, strlen(Utilities::genRandomBytes(10)));
20: }
21:
22: 23: 24: 25: 26:
27: public function alternativeBase64EncoderWorksAsExpected()
28: {
29: $this->assertEquals('', Utilities::altBase64Encode(''));
30: $this->assertEquals('Zg', Utilities::altBase64Encode('f'));
31: $this->assertEquals('Zm8', Utilities::altBase64Encode('fo'));
32: $this->assertEquals('Zm9v', Utilities::altBase64Encode('foo'));
33: $this->assertEquals('Zm9vYg', Utilities::altBase64Encode('foob'));
34: $this->assertEquals('Zm9vYmE', Utilities::altBase64Encode('fooba'));
35: $this->assertEquals('Zm9vYmFy', Utilities::altBase64Encode('foobar'));
36:
37: $this->assertEquals('', Utilities::altBase64Decode(''));
38: $this->assertEquals('f', Utilities::altBase64Decode('Zg'));
39: $this->assertEquals('fo', Utilities::altBase64Decode('Zm8'));
40: $this->assertEquals('foo', Utilities::altBase64Decode('Zm9v'));
41: $this->assertEquals('foob', Utilities::altBase64Decode('Zm9vYg'));
42: $this->assertEquals('fooba', Utilities::altBase64Decode('Zm9vYmE'));
43: $this->assertEquals('foobar', Utilities::altBase64Decode('Zm9vYmFy'));
44: }
45:
46: }
47: