Skip to content

Pre-release 4.2.112 → 4.2.111 — task 2.17 step 1: v13 TestResponse from call() - #84

Merged
agissept merged 1 commit into
masterfrom
pre-release/4.2.112
Oct 1, 2026
Merged

agissept merged 1 commit into
masterfrom
pre-release/4.2.112

Conversation

@oonid

@oonid oonid commented Sep 30, 2026 •

Copy link
Copy Markdown

Task 2.17, step 1 — v13 TestResponse from call() (illuminate/testing v13)

Stacks on #83. Adds illuminate/testing: ^13 and makes the testing trait's call() return an Illuminate\Testing\TestResponse wrapped around the client's response. callSecure(), action() and route() go through call(), so they return one too.

Why a first step: 2.17 moves about 500 app test files from the L4.2 assertions to v13's fluent ones, which is too big for one reviewable PR. This step makes the fluent assertions available on today's call() without breaking the old ones. The app can then migrate in batches, and a later step removes the legacy assertions.

What stays the same

  • The L4.2 call() signature, ($method, $uri, $parameters, $files, $server, $content, $changeHistory). v13's call() takes $cookies fourth, so switching now would silently send files as cookies. It changes at the foundation flip (4.5).
  • The L4.2 assertions (assertResponseOk, assertResponseStatus, assertRedirectedTo/ToRoute/ToAction, assertViewHas, assertSessionHas*, assertHasOldInput) still read $this->client->getResponse().
  • Everything else on the result: TestResponse forwards unknown methods and properties to the real response (getContent(), getStatusCode(), headers, original, getTargetUrl(), …).

What changes for callers

  • The result is not a Symfony Response. A Response type hint on it fails, and so does assertInstanceOf(XResponse::class, $response). Type-hint TestResponse, and use $response->baseResponse for instance checks. The app pair fixes the 8 files that do this.
  • $response['key'] now reads JSON or view data (TestResponse implements ArrayAccess), and TestResponse has no __toString().

PHPUnit

  • illuminate/testing v13 suggests PHPUnit 11.5 or 12.5; the fork and the app run 9.6.
  • TestResponse only uses Assert, Constraint and ExpectationFailedException, which 9.6 has, and the new test runs the commonly used assertions on 9.6.
  • Moving to PHPUnit 11/12 is the rest of 2.17's "done when".

Tests

  • tests/Foundation/FoundationTestingResponseTest has 6 tests:
    • call() wraps the client's response and passes its arguments through unchanged;
    • the L4.2 assertions still work;
    • a failing fluent assertion is a PHPUnit failure;
    • the JSON, redirect-and-session and streamed-response assertions.
  • Reverting call() turns 5 of the 6 red.

Verification

  • Fork:
    • suite 321 green (6 added); ratchet green; composer validate OK;
    • the real composer.json (with rector) resolves illuminate/testing v13.34.0;
    • no fork import points at a deleted class.
  • Downstream: the dicoding app pair dicoding-dev/dicoding#5955 (feature/platform/framework-4.2.112-rc1), with vendor installed exactly from its lock and the local SMTP sink on 127.0.0.1:1025:
    • Psalm (full project, no cache): no errors.
    • Unit suite: 8468 green.
    • NotificationV2 (24), CourseCertificate (14), mail (TechnicalProblemMailerBoringTest, FatalErrorNotificationTest, InviteDevelopersTest) and BeanstalkdQueueBoringTest against a real worker: green.
    • Integration suite: all 2987 tests, run per directory. Their 1,810 $this->get/post/… calls, 64 direct call()s and 22 ajaxPost()s all go through the new call(). 5 failures, the same 5 as the 4.2.111 pair in the same setup: three learning-notes views that get a null date, one tutorial-graduation expectation, and one upload-size check.
    • RateLimitBoringTest (changed, outside the suites) passes its first 9 assertions and then errors on the last request, after a 61-second sleep. It errors identically on 4.2.111, so the problem is its timing and existed before this change.
  • Checks ran in a cloud container without deck (PHP 8.4.26, MariaDB 10.11, deck's Asia/Jakarta timezone and max_connections).

Rest of 2.17

  1. App: migrate the legacy assertions in batches: 1,594 calls in about 500 files.
    • assertRedirectedToRoute 583, assertResponseOk 378, assertResponseStatus 244, assertSessionHas 226, assertRedirectedTo 146, assertViewHas 14, others 3.
    • They are mechanical to convert (Rector), and a grep ratchet in the app's CI (like ci/check-console-handle.sh) can keep the count from growing.
  2. Fork: remove the legacy assertions once the app's count is 0. Take v13's call() signature at 4.5.
  3. PHPUnit 11/12, in both the app and the fork.

Tag

4.2.112 on dad83f75 is not pushed; tag pushes are refused for this session.

🤖 Generated with Claude Code

https://claude.ai/code/session_0169SsatCE8LhaTsQTPiGtVo

@agissept
agissept added this pull request to stack #91 October 1, 2026 06:28
Base automatically changed from pre-release/4.2.111 to master October 1, 2026 07:19
@agissept
agissept marked this pull request as ready for review October 1, 2026 07:35
Require illuminate/testing ^13 and wrap the response of the test
client in Illuminate\Testing\TestResponse. call() (and callSecure(),
action(), route(), which go through it) keep their L4.2 signature, so
existing tests run unchanged:
- TestResponse forwards unknown methods and properties to the real
  response (getContent(), getStatusCode(), headers, original, ...);
- the L4.2 assertions (assertResponseOk, assertRedirectedTo, ...) still
  read $this->client->getResponse().

Tests can now use the v13 fluent assertions on what call() returns
($this->get($uri)->assertOk()->assertJsonPath(...)), so the app can
move its ~500 test files over in batches before the legacy assertions
are removed. What breaks is code that treats the result as a Symfony
response: a Response type hint or an assertInstanceOf on it (use
->baseResponse).

illuminate/testing v13 depends only on components already on v13. Its
assertions run on PHPUnit 9.6, which the fork and the app still use;
tests/Foundation/FoundationTestingResponseTest covers the wrapping,
the legacy assertions, a failing fluent assertion, the JSON, redirect,
session and streamed-response assertions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0169SsatCE8LhaTsQTPiGtVo
@agissept
agissept force-pushed the pre-release/4.2.112 branch from 1f0d48e to 209fe9a Compare October 1, 2026 08:39
@agissept
agissept merged commit d6b4840 into master Oct 1, 2026
2 checks passed
@agissept
agissept deleted the pre-release/4.2.112 branch October 1, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants