winzik/engine/tests/Kernel/StartParamsTest.php
David Nurdin 7c3833eda5 Engine: the page gives the first scene's params (window.JUMPHP_GAME.start_params -> JUMPHP_START_PARAMS, over project.yaml start_params) and the TCP ticket address (tcp_ticket_url -> JUMPHP_TCP_URL)
A server that serves the page (the playground embedding an application on a partner's
site, docs/embed.md) passes the fields of the partner's form and the visitor's
provenance, and points the tickets at the partner's relay. Pure addition: a page
without these keys behaves as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-14 02:09:59 +01:00

25 lines
1 KiB
PHP

<?php
namespace JumPHP\Tests\Kernel;
use JumPHP\Kernel\Engine;
use PHPUnit\Framework\TestCase;
/** The first scene's params: project.yaml start_params, with what the page gives (JUMPHP_START_PARAMS, docs/embed.md) on top. */
final class StartParamsTest extends TestCase
{
public function testThePageParamsGoOverTheProjectOnes(): void
{
$merged = Engine::startParams(['mode' => 'solo', 'port' => 7000], '{"nickname":"ada","site":"example.com","port":7001}');
self::assertSame(['mode' => 'solo', 'port' => 7001, 'nickname' => 'ada', 'site' => 'example.com'], $merged);
}
public function testNothingOrSomethingElseThanAnObjectChangesNothing(): void
{
$configured = ['mode' => 'solo'];
foreach ([null, '', 'not json', '[1,2]', '"text"', '42', '{}'] as $json) {
self::assertSame($configured, Engine::startParams($configured, $json), var_export($json, true));
}
self::assertSame($configured, Engine::startParams($configured, ['nickname' => 'x']), 'only a JSON string is read');
}
}