---
title: "Spiral Testing: withActor and line endings in PHP tests"
description: "Fixes in Spiral Testing in PHP: withActor() keeps the configured auth transports, and console and scaffolder output assertions ignore CRLF line endings."
url: "https://vulcode.com/en/opensource/contributions/spiral-testing"
lang: "en"
---

[All contributions](https://vulcode.com/en/opensource/contributions)

spiral/testing

# Spiral Testing

A testing toolkit for applications on the Spiral PHP framework: fake HTTP requests, console commands, the scaffolder and the container.

[See the repository](https://github.com/spiral/testing) [All contributions](https://vulcode.com/en/opensource/contributions)

- **Language**: PHP
- **GitHub stars**: 7
- **Merged changes**: 3
- **Project site**: [spiral.dev](https://spiral.dev/docs/packages-testing)

## What we changed

withActor() keeps the auth transports configured in the app, so a test with a fake user no longer ends in a 500 error. Console and scaffolder output assertions ignore line-ending differences, so text with CRLF passes the same way as with LF.

### What this work shows

- HTTP auth in Spiral (TransportRegistry)

- PHPUnit assertions independent of line endings

- Console command and scaffolder tests

What was broken

### withActor() ended in a 500 error

Faking a logged-in user with withActor() replaced the whole TransportRegistry with a single transport named testing. An app with its own transport, such as header, got an "Undefined auth transport header" error from AuthTransportMiddleware.

How we fixed it

### Transport names are kept

The fake registry takes over the names of all transports configured in the app and maps each one to the fake header transport. We added a test with a custom transport and a type annotation for Psalm.

[#91](https://github.com/spiral/testing/pull/91)

What was broken

### The console assertion depended on line endings

assertConsoleCommandOutputContainsStrings() compared text exactly, so an expected string with \r\n did not match output with \n, and the other way round. An issue in the project asked for an assertion that ignores line endings.

How we fixed it

### A comparison that ignores line endings

The assertion now uses PHPUnit's assertStringContainsStringIgnoringLineEndings. We added a test command, multiline, that prints two lines, and a test that expects them with \r\n.

[#94](https://github.com/spiral/testing/pull/94)

What was broken

### The scaffolder had the same problem

assertScaffolderCommandSame() and assertScaffolderCommandContains() checked the command output with a plain assertStringContainsString. Text with different line endings failed even when the content was the same.

How we fixed it

### Both scaffolder assertions ignore line endings

Both output assertions in InteractsWithScaffolder now use the comparison that ignores line endings. New tests generate a filter with create:filter and expect the message with \r\n.

[#95](https://github.com/spiral/testing/pull/95)

## Merged changes

3 from 21 September 2026 to 4 October 2026

- [01 #91Merged 21 September 2026 Keep configured auth transports when faking an actor](https://github.com/spiral/testing/pull/91)

- [02 #95Merged 4 October 2026 Ignore line endings in scaffolder output assertions](https://github.com/spiral/testing/pull/95)

- [03 #94Merged 4 October 2026 Ignore line endings in console output assertions](https://github.com/spiral/testing/pull/94)

## What it taught us

A fake in a testing toolkit has to keep the application's configuration rather than overwrite it, or the test fails where the real app works. Our text assertions ignore line endings, so a test result does not depend on the operating system.

[More about this technology: PHP](https://vulcode.com/en/technologies/php)

## Other projects we write code for

- [**Composer** PHP · 29,590 stars The dependency manager for PHP: it installs and updates a project's libraries from its composer.json.](https://vulcode.com/en/opensource/contributions/composer)

- [**PHPMailer** PHP · 22,347 stars The classic PHP library for sending email, used by WordPress and many other systems.](https://vulcode.com/en/opensource/contributions/phpmailer)

- [**Monolog** PHP · 21,407 stars A PHP logging library that sends records to files, sockets, inboxes, databases and web services. Symfony and Laravel use it, among others.](https://vulcode.com/en/opensource/contributions/monolog)

- [**Carbon** PHP · 16,583 stars A PHP DateTime extension for working with dates, standard in the Laravel ecosystem.](https://vulcode.com/en/opensource/contributions/carbon)

- [**Whoops** PHP · 13,231 stars A PHP library that turns uncaught exceptions into a readable error page with the stack trace, known from Laravel.](https://vulcode.com/en/opensource/contributions/whoops)

- [**ramsey/uuid** PHP · 12,642 stars A PHP library for generating universally unique identifiers (UUIDs).](https://vulcode.com/en/opensource/contributions/ramsey-uuid)

## Describe your project.

A free quote comes back within an hour during working hours.

### Rather skip the form?

Ask in the chat or write to us directly.

Open the chat

- **Email**: [hello@vulcode.com](mailto:hello@vulcode.com)
- **Phone**: [+48 576 043 920](tel:+48576043920)
- **Discord**: [discord.gg/vulcode](https://discord.gg/vulcode)
