public function testDecoding()
 {
     $su = new ShortUUID();
     $randomUid = Uuid::uuid4();
     $smallestUid = Uuid::fromInteger(0);
     $encodedRandom = $su->encode($randomUid);
     $encodedSmall = $su->encode($smallestUid);
     $this->assertEquals($su->decode($encodedSmall), $smallestUid);
     $this->assertEquals($su->decode($encodedRandom), $randomUid);
 }
Esempio n. 2
0
 public function testEncodedLength()
 {
     $su1 = new ShortUUID();
     $this->assertEquals($su1->encodedLength(), 22);
     $base64Alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
     $su2 = new ShortUUID($base64Alphabet);
     $this->assertEquals($su2->encodedLength(), 22);
     $binaryAlphabet = '01';
     $su3 = new ShortUUID($binaryAlphabet);
     $this->assertEquals($su3->encodedLength(), 128);
     $su4 = new ShortUUID();
     $this->assertEquals($su4->encodedLength(8), 11);
 }