Skip to content

PersistedObjectsTracker::$buffer must not be accessed before initialization since v2.7.6Β #1012

@HSken

Description

@HSken

If running test with a Factory create in it gives me:

Error: Typed static property Zenstruck\Foundry\Persistence\Proxy\PersistedObjectsTracker::$buffer must not be accessed before initialization
/var/www/html/vendor/zenstruck/foundry/src/Persistence/Proxy/PersistedObjectsTracker.php:53
/var/www/html/vendor/zenstruck/foundry/src/Persistence/PersistenceManager.php:89
/var/www/html/vendor/zenstruck/foundry/src/Persistence/PersistentObjectFactory.php:266
/var/www/html/vendor/zenstruck/foundry/src/Factory.php:66
/var/www/html/tests/ApiResource/DemoTest.php:21

UserFactory is a default generated factory of a simple default symfony user.

DemoTest:

<?php

declare(strict_types=1);

namespace App\Tests\ApiResource;

use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use App\Factory\User\UserFactory;
use Zenstruck\Foundry\Test\Factories;
use Zenstruck\Foundry\Test\ResetDatabase;


final class DemoTest extends ApiTestCase
{
    use ResetDatabase;
    use Factories;

    protected static ?bool $alwaysBootKernel = false;

    public function testDemo():void{
        $user = UserFactory::createOne();
        self::assertNotNull($user);
    }
}

Reverting to v2.7.5 Solves the issue.

I don't have the issue when I run the whole suite, only when I run the one test or test file with phpstorm.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions