CakePHP 4 PHPUnit testing - fixture listener

Hi, I’m having trouble setting up the fixture listener for my project.

I’ve added the xml in phpunit.xml.dist:

  <!-- Setup a listener for fixtures -->
    <listeners>
        <listener class="Cake\TestSuite\Fixture\FixtureInjector">
            <arguments>
                <object class="Cake\TestSuite\Fixture\FixtureManager"/>
            </arguments>
        </listener>
    </listeners>

My composer.json contains the following rows:

"autoload": {
    "psr-4": {
        "App\\": "src/"
    }
},
"autoload-dev": {
    "psr-4": {
        "App\\Test\\": "tests/",
        "Cake\\Test\\": "vendor/cakephp/cakephp/tests/"
    }
},

But when I run ‘phpunit.bat tests’ from the cli, it gives me the following error:

Class ‘Cake\TestSuite\Fixture\FixtureManager’ not found

Anyone knows why?

What does your complete phpunit.xml.dist file look like?

Thanks for the reply. I solved it by executing the tests with the framework’s phpunit.bat, instead of the one from my local web server (xampp):

vendor/bin/phpunit.bat tests