index/tests/Base62Test.php

37 lines
850 B
PHP
Raw Normal View History

2022-09-13 13:13:11 +00:00
<?php
// Base62Test.php
// Created: 2022-01-28
// Updated: 2022-02-03
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use Index\Serialisation\Serialiser;
/**
* @covers Base62Serialiser
*/
final class Base62Test extends TestCase {
public const TESTS = [
['aaaaaa', 9311514030],
['Soap', 12962613],
['', 0],
['1', 1],
['kPH', 80085],
['UC', 3510],
['p', 25],
['6zi', 25252],
['1ly7vk', 1234567890],
];
public function testDecode(): void {
foreach(self::TESTS as $test)
$this->assertEquals($test[1], Serialiser::base62()->deserialise($test[0]));
}
public function testEncode(): void {
foreach(self::TESTS as $test)
$this->assertEquals($test[0], (string)Serialiser::base62()->serialise($test[1]));
}
}