mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-04-01 22:04:15 -04:00
fix: add autoload-dev for Tests namespace and fix UrlHelperTest namespace
- Add autoload-dev section to composer.json for Tests namespace - Rename tests/helpers to tests/Helpers for PSR-4 compliance - Add proper namespace to UrlHelperTest.php This fixes PHPUnit test discovery - previously only 6 tests were running instead of ~132 due to missing namespace autoloading.
This commit is contained in:
@@ -63,6 +63,11 @@
|
||||
"**/Database/Migrations/**"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"phpstan/extension-installer": true
|
||||
|
||||
24
tests/Helpers/UrlHelperTest.php
Normal file
24
tests/Helpers/UrlHelperTest.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Helpers;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class UrlHelperTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
require_once __DIR__ . '/../../app/Helpers/url_helper.php';
|
||||
}
|
||||
|
||||
public function testBase64urlEncode(): void
|
||||
{
|
||||
$data = 'Test data';
|
||||
$encoded = base64url_encode($data);
|
||||
|
||||
$this->assertMatchesRegularExpression('/^[A-Za-z0-9\-_]+$/', $encoded);
|
||||
|
||||
$decoded = base64url_decode($encoded);
|
||||
$this->assertEquals($data, $decoded);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user