mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-01-01 05:57:54 -05:00
* Create a Base64 URL-Safe encoding and decoding helper * Rename web_helper to url_helper --------- Co-authored-by: El_Coloso <diegoramosp@gmail.com>
26 lines
757 B
PHP
26 lines
757 B
PHP
<?php
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class UrlHelperTest extends TestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
// Include the url_helper.php file
|
|
require_once __DIR__ . '/../../app/Helpers/url_helper.php';
|
|
}
|
|
|
|
public function testBase64urlEncode(): void
|
|
{
|
|
$data = 'Test data';
|
|
$encoded = base64url_encode($data);
|
|
|
|
// Assert that the encoded string is URL-safe
|
|
$this->assertMatchesRegularExpression('/^[A-Za-z0-9\-_]+$/', $encoded);
|
|
|
|
// Assert that decoding the encoded string returns the original data
|
|
$decoded = base64url_decode($encoded);
|
|
$this->assertEquals($data, $decoded);
|
|
}
|
|
}
|