-
-
Notifications
You must be signed in to change notification settings - Fork 102
Closed as duplicate of#235
Description
So a bit while ago I've (and not only me appearantly) had this problem with Foundry v1 booting with app container instead of test on behat setup. Now as I've upgraded project's php and symfony, a v2 Foundry came along and it seems I have same problem again, except the old fix doesn't work anymore as TestState
was removed and I have no idea how to pass the test's container now.
A thread about v1 issue: #234
A bit of context follows.
my setup is:
php 8.4
mysql 8.4
symfony 6.4
dama (8.3, not using database reset)
foundry 2.6.0
foundry config:
when@dev: &dev
zenstruck_foundry:
auto_refresh_proxies: true
orm:
auto_persist: true
reset:
connections: [default]
entity_managers: [default]
mode: schema
when@test: *dev
if I run this code in the test command (with test
env) using cli, all works fine:
protected function execute(InputInterface $input, OutputInterface $output): int
{
StaticDriver::setKeepStaticConnections(true);
$user = UserFactory::new()
->password('test')
->create(['email' => '[email protected]']);
$this->entityManager->refresh($user->_real());
StaticDriver::rollBack();
return 0;
}
but if I do the same from behat context step:
#[Given('/^user is created$/')]
public function userIsCreated(): void
{
$user = UserFactory::new()
->password('test')
->create(['email' => '[email protected]']);
$this->entityManager->refresh($user->_real());
}
I get an error:
Entity [email protected] is not managed. An entity is managed if its fetched from the database or registered as new through EntityManager#persist in...
Let me know if additional info is needed.
I would gladly propose a PR with a fix if someone would guide me towards the solution.
Metadata
Metadata
Assignees
Labels
No labels