Skip to content

Testing: ServeTest POST form submission via phpc serve #248

@PurHur

Description

@PurHur

Problem

test/real/ServeTest.php and test/real/ServeAotTest.php only exercise GET requests (httpGet). lib/Web/DevServer.php already passes REQUEST_BODY into Superglobals::populateFromEnvironment(), and PHPT cases under test/real/cases/web_post.phpt cover VM-style POST parsing — but no integration test proves phpc serve / bin/serve.php accepts a POST body end-to-end.

#67 / #210 MiniWebApp needs POST /contact; without a serve-level test, regressions in DevServer body reading or $_POST population will not fail CI.

Goal

Add ServeTest::testPostFormUrlencoded (name TBD) that:

  1. Starts serve against a tiny docroot with form.php reading $_POST['name']
  2. Sends POST /form.php with Content-Type: application/x-www-form-urlencoded body
  3. Asserts 200 and echoed field value

Optional follow-up: mirror in ServeAotTest when AOT POST refresh is ready (#49).

Implementation hints

  • Reuse ServeTest::httpGet() pattern; add httpPost($docroot, $path, $body, $headers = []) using stream_socket_client + raw HTTP/1.1 request (same as existing helper).
  • Fixture script:
<?php
header('Content-Type: text/plain');
echo 'name=', $_POST['name'] ?? 'missing';

Acceptance criteria

./script/ci-local.sh --filter ServeTest::testPost
# or full suite when serve tests enabled:
./script/docker-ci-local.sh

→ POST test runs (not skipped) unless PHP_COMPILER_SKIP_SERVE_TESTS=1.

Verification (local only)

Do not require GitHub Actions. GHA may skip serve tests; Docker/local must not.

Dependencies

Blocks

Files

  • test/real/ServeTest.php
  • lib/Web/DevServer.php, lib/Web/Superglobals.php

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions