DSP Project first push, date: 29/01/2026
This commit is contained in:
38
tests/Helpers/JupyterHelpersTest.php
Normal file
38
tests/Helpers/JupyterHelpersTest.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class JupyterHelpersTest extends TestCase
|
||||
{
|
||||
protected function tearDown(): void
|
||||
{
|
||||
putenv('JUPYTERHUB_USERNAME_TEMPLATE');
|
||||
}
|
||||
|
||||
public function testResolveJupyterHubUsernameWithDefaultTemplate(): void
|
||||
{
|
||||
$username = dsp_resolve_jupyterhub_username(42, 'alice', 'alice@example.com');
|
||||
$this->assertSame('user_42', $username);
|
||||
}
|
||||
|
||||
public function testResolveJupyterHubUsernameUsesCustomTemplate(): void
|
||||
{
|
||||
putenv('JUPYTERHUB_USERNAME_TEMPLATE=hub-{username}-{person_id}');
|
||||
$username = dsp_resolve_jupyterhub_username(7, 'bob', 'bob@example.com');
|
||||
$this->assertSame('hub-bob-7', $username);
|
||||
}
|
||||
|
||||
public function testResolveJupyterHubUsernameSanitisesOutput(): void
|
||||
{
|
||||
putenv('JUPYTERHUB_USERNAME_TEMPLATE={email}');
|
||||
$username = dsp_resolve_jupyterhub_username(99, 'carol', 'carol+demo@example.com');
|
||||
$this->assertSame('carol-demo-example.com', $username);
|
||||
}
|
||||
|
||||
public function testResolveJupyterHubUsernameRejectsMissingPersonId(): void
|
||||
{
|
||||
$this->assertNull(dsp_resolve_jupyterhub_username(null, 'dave', 'dave@example.com'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user