-
Notifications
You must be signed in to change notification settings - Fork 701
Expand file tree
/
Copy pathKernelTest.php
More file actions
56 lines (45 loc) · 1.68 KB
/
KernelTest.php
File metadata and controls
56 lines (45 loc) · 1.68 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
declare(strict_types=1);
namespace SimpleSAML\Test;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Configuration;
use SimpleSAML\Kernel;
use SimpleSAML\Module;
use Symfony\Component\Routing\Route;
use function sys_get_temp_dir;
use function uniqid;
#[CoversClass(Kernel::class)]
class KernelTest extends TestCase
{
#[RunInSeparateProcess]
public function testGlobalKernelLoadsPrefixedModuleRoutes(): void
{
Module::$module_info = [];
$cacheDir = sys_get_temp_dir() . '/simplesamlphp-global-kernel-' . uniqid();
$config = Configuration::loadFromArray([
'baseurlpath' => 'https://example.com/simplesaml/',
'cachedir' => $cacheDir,
'tempdir' => $cacheDir,
'logging.handler' => 'errorlog',
'secretsalt' => 'test-secret',
'module.enable' => [
'admin' => true,
'core' => true,
'saml' => true,
],
], '', 'simplesaml');
Configuration::setPreLoadedConfig($config);
$kernel = new Kernel();
$kernel->boot();
$routes = $kernel->getContainer()->get('router')->getRouteCollection();
$adminMain = $routes->get('admin-main');
$samlMetadata = $routes->get('saml-sp-metadata');
$this->assertInstanceOf(Route::class, $adminMain);
$this->assertEquals('/module/admin', $adminMain->getPath());
$this->assertInstanceOf(Route::class, $samlMetadata);
$this->assertEquals('/module/saml/sp/metadata/{sourceId}', $samlMetadata->getPath());
$kernel->shutdown();
}
}