Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

trevorpan's avatar

Test code or tested code did not (only) close its own output buffers & actingAs()

https://laracasts.com/discuss/channels/testing/php-unit-risky-test-whats-the-cause-of-it-and-how-to-avoid

Have an unusual error here. It seems to be related to a brew update, but I'm not certain. At any rate I went through the blade views on the risky tests as the above post mentions. That does not seem to have fixed the error.

I am concerned it may be a session issue as the failing tests all have this method.

Recently updated the auth scaffolding... Any thoughts would be amazing!

0 likes
7 replies
BrandonSurowiec's avatar

I had this error during testing as well. It was due in my case to the @section shorthand value being null. Example :

@section('shorthand', $value) // where $value = null

When that happens the output buffer isn't closed because it expects the long syntax version:

@section('shorthand')
Like this.
@endsection

So the fix was to cast to a string or wrap the whole section in an @if.

@section('shorthand', (string) $value)
5 likes
Daniel-Pablo's avatar

thanks this really help, in my case I got to CLOSE all the tags with @endsection

like this

 @section
// here all the data and then...
 @endsection

1 like
wit's avatar

Thank you so much for pointing this out. There was indeed a hidden missing @endsection in some deep included subview in my case.

1 like
chrispage1's avatar

I've just come across this, exactly the same as @brandonsurowiec where my shorthand sections were defaulting to null. A simple change to an empty string and all sorted.

Thank you for the answer!

3 likes
Disciple's avatar

make sure you have $value probably it's really null

Please or to participate in this conversation.