configure($browser); $module->configure($console); self::assertSame( [ 'test_context' => [ 'handle' => 'test_context', 'namespace' => 'TestContext', 'version' => '0.0.1', 'label' => 'Test Context', 'author' => 'Ktrix', 'description' => 'Tests module contexts', 'boot' => 'static/module.mjs', ], ], $browser->modules(), ); self::assertSame( ['test' => ['tenant' => 'tenant-id', 'identity' => 'identity-id']], $browser->configuration(), ); self::assertSame(['ExampleCommand'], $console->commands()); self::assertSame(ModuleContextType::Browser, $browser->type()); self::assertSame(ModuleContextType::Console, $console->type()); } #[Test] public function rejectsDuplicateBrowserConfigurationKeys(): void { $context = new BrowserModuleContext('tenant-id', 'identity-id'); $context->set('test', true); $this->expectException(LogicException::class); $context->set('test', false); } } final class TestContextModule extends ModuleInstanceAbstract { public function handle(): string { return 'test_context'; } public function version(): string { return '0.0.1'; } public function label(): string { return 'Test Context'; } public function description(): string { return 'Tests module contexts'; } public function author(): string { return 'Ktrix'; } public function configure(ModuleContextInterface $context): void { if ($context instanceof BrowserModuleContextInterface) { $context->registerModule($this, 'TestContext', 'static/module.mjs'); $context->set('test', [ 'tenant' => $context->tenantIdentifier(), 'identity' => $context->identityIdentifier(), ]); } if ($context instanceof ConsoleModuleContextInterface) { $context->registerCommand('ExampleCommand'); $context->registerCommand('ExampleCommand'); } } }