-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathBase64DriverTest.php
32 lines (25 loc) · 1.05 KB
/
Base64DriverTest.php
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
namespace ElfSundae\Laravel\Hashid\Test;
use ElfSundae\Laravel\Hashid\Base64Driver;
use ElfSundae\Laravel\Hashid\Base64IntegerDriver;
class Base64DriverTest extends DriverTestCase
{
protected $driver = Base64Driver::class;
protected $integerDriver = Base64IntegerDriver::class;
public function testInstantiation()
{
$this->assertInstanceOf($this->driver, $this->makeDriver());
$this->assertInstanceOf($this->integerDriver, $this->makeDriver($this->integerDriver));
}
public function testEncoding()
{
$this->assertEncodedData('Laravel', 'TGFyYXZlbA');
$this->runForBytes();
$this->assertUniformEncoding(random_bytes(128));
$this->assertEncodedData(1234567, 'MTIzNDU2Nw', $this->integerDriver);
$this->runForIntegers($this->integerDriver);
$this->assertUniformEncoding(random_int(0, PHP_INT_MAX), $this->integerDriver);
$integerDriver = $this->makeDriver($this->integerDriver);
$this->assertSame(0, $integerDriver->decode(base64_encode('123a')));
}
}