Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeException: Cannot get Foundry's configuration. Possible Bug? #500

Closed
justpilot opened this issue Aug 29, 2023 · 1 comment
Closed

Comments

@justpilot
Copy link

Hello,

I'm experiencing a strange behavior during my tests. I'm getting this error at the end:

RuntimeException: Cannot get Foundry's configuration. If using faker in a data provider, consider passing attributes as a callable.

I have a file AdminLoginTest.php in /tests/Functional.

<?php

declare(strict_types=1);

namespace App\Tests\Functional;

use App\Factory\UserFactory;
use Zenstruck\Browser\HttpOptions;

class AdminLoginTest extends ApiTestCase
{
    public function testAdminUserLogin(): void
    {
        $user = UserFactory::new()->withRoles(['ROLE_ADMIN'])->create();

        dump($user);

        $this->browser()
            ->post('/api/admin/accounts/status', HttpOptions::json([
                'username' => $user->getUsername()
            ]))
            ->assertSuccessful()
            ->assertJson()
            ->dump();
    }
}

The strange thing is, just by renaming the file to XAdminLoginTest.php and the Class to XAdminLoginTest every test runs fine.
If I run a single Test "XAdminLoginTest", then the message reappears.
If the test is the first Test on the list, then the message reappears.

Any ideas?

  • Removing vendor, composer i -> no help
  • composer update -> no help
Symfony 6.3
api-platform/core                   v3.1.15            Build a fully-featured hypermedia or GraphQL API in minutes!
dama/doctrine-test-bundle           v7.2.1             Symfony bundle to isolate doctrine database tests and improve test performance
doctrine/data-fixtures              1.6.7              Data Fixtures for all Doctrine Object Managers
zenstruck/assert                    v1.4.0             Standalone, lightweight, framework agnostic, test assertion library.
zenstruck/browser                   v1.4.0             A fluent interface for your Symfony functional tests.
zenstruck/callback                  v1.5.0             Callable wrapper to validate and inject arguments.
zenstruck/foundry                   v1.35.0            A model factory library for creating expressive, auto-completable, on-demand dev/test fixtures with Symfony and Doctrine.
zenstruck/mailer-test               v1.3.0             Alternative, opinionated helpers for testing emails sent with symfony/mailer.
@justpilot
Copy link
Author

Symfony Docs: Enable Foundry in your TestCase

Add the Factories trait for tests using factories

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant