winzik/skeleton-app/tests/MainTest.php
David Nurdin 54415b60f0 Desktop apps (Tauri): native windows with HTML pages, driven by PHP
PHP stays the program: JumPHP\Tauri\App starts the Tauri runtime (tauri/, a Rust C library loaded with FFI) from
its main thread; Tauri runs its native loop there and calls PHP back at every frame, like the browser engine.
Pages talk to PHP with window.jumphp (invoke / send / on); PHP drives windows, dialogs, notifications and decides
what closing does. Native only, Linux for now.

- tauri/: libjumphp_tauri (jt_run / jt_poll / jt_send / jt_version), pages served from the app's folder at run time
- engine: JumPHP\Tauri (App, Window, AppMain, TauriRuntime, FakeRuntime, NativeCommands), JumPHP\Native (Dialog,
  FilePicker, Notification, Shell; providers tauri / sdl / browser / none), Testing\AppTestCase (no window)
- bin/jumphp app:new / app:run / app:test / app:shot / app:export, tauri:setup / tauri:build (tools/app-commands.sh);
  run / test / shot hand over to them for an app, pages skips apps
- app:export: export:standalone with optional settings (extension list with FFI, boot class, native library,
  injected php.ini); unset, games build and find the same micro as before (same key)
- skeleton-app/, games/hello-desktop (a notepad), docker/tauri, docs/tauri.md + docs/tauri.fr.md, AGENTS.md §16

Nothing changes for SDL games (desktop, browser, standalone, Android, Apple).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JkYTqpYNZKwTnRZHQRD5HP
2026-10-31 21:41:41 +01:00

32 lines
1 KiB
PHP

<?php
namespace Tests;
use JumPHP\Testing\AppTestCase;
/** The app played without a window: the test is the page (AppTestCase, docs/tauri.md). */
final class MainTest extends AppTestCase
{
public function testThePageIsGreetedByPhp(): void
{
$answer = $this->invoke('greet', ['name' => 'Ada']);
self::assertStringStartsWith('Hello Ada from PHP', $answer['message']);
self::assertSame(1, $answer['clicks']);
}
public function testTheClockReachesThePageEverySecond(): void
{
$this->wait(1.2);
self::assertNotNull($this->lastSent('webview.emit'));
self::assertSame('clock', $this->lastSent('webview.emit')['name']);
}
public function testClosingAfterUseAsksFirst(): void
{
$this->invoke('greet', ['name' => 'Ada']);
$this->requestClose();
self::assertSame([], $this->sent('window.close')); // still open: a dialog asks
$this->answerDialog(true);
self::assertNotNull($this->lastSent('app.exit'));
}
}