Skip to content

[Bug]: [macOS] php 8.5 & phpunit process isolation gives serialisation error #1674

@Harrald

Description

@Harrald

Platform

macOS

Operating system version

macOs Tahoe 26.3.1

System architecture

ARM64 (M1, M2, etc)

Herd Version

1.28.0

PHP Version

PHP 8.5.4

Bug description

With phpunit 12.5.16 and Herd 1.28.0

Tests that have:

#[RunTestsInSeparateProcesses]
#[PreserveGlobalState(true)]

Give this warning: Global variable $GLOBALS['__herd_closure'] was not preserved because it is a Closure.

When i remove #[PreserveGlobalState(true)] it will work without problems.

Steps to reproduce

<?php

namespace Tests\Unit;

use PHPUnit\Framework\Attributes\PreserveGlobalState;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
use PHPUnit\Framework\TestCase;

#[RunTestsInSeparateProcesses]
#[PreserveGlobalState(true)]
class ExampleTest extends TestCase
{
    public function test_that_true_is_true(): void
    {
        $this->assertTrue(true);
    }
}

Gives:

   WARN  Tests\Unit\ExampleTest
  ! that true is true → Global variable $GLOBALS['__herd_closure'] was not preserved because it is a Closure

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions