Closed alexislefebvre closed 2 years ago
Please try the alpha release: https://github.com/liip/LiipFunctionalTestBundle/releases/tag/4.6.0-alpha1
With a simple test this error show:
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "Liip\TestFixturesBundle\Services\DatabaseToolCollection".
Used like this in class UserTest extends KernelTestCase
:
public function setUp(): void
{
parent::setUp();
$this->databaseTool = static::getContainer()->get(DatabaseToolCollection::class)->get();
$this->entityManager = static::getContainer()->get(EntityManagerInterface::class);
$this->users = $this->entityManager->getRepository(User::class)->findAll();
}
As current doc said:
in config/package/test/framework.yaml
framework:
test: true
session:
storage_id: session.storage.mock_file
name: MOCKSESSION
liip_functional_test: ~
@kl3sk Thanks, I'll add it to the doc of the other bundle: https://github.com/liip/LiipTestFixturesBundle/pull/206
Ok thanks,
Just to be clear. This doen't work for me.
Edit:
As default, it is enabled as this in SF6
in: config/package/framework.yaml
when@test:
framework:
test: true
session:
storage_factory_id: session.storage.factory.mock_file
Thanks, I'll add this too for Symfony 6.
Edit: @kl3sk if this was enabled by default, why did you have this error?
This is a good question @alexislefebvre 🤣
I have a default installation and don't understand why this happen. A though because the compatibility is alpha at least.
After some reseach it appears that the cache was the problem.
A clear:cache
was not enough (many tries before). I have to remove the folder manually .
But now I face of an other error:
Testing
E 1 / 1 (100%)There is no active transaction
And this fix won't work for me.
Erratum: After removing the cache manually (again). It seems to work with:
liip_test_fixtures:
keep_database_and_schema: true
...
Based on #598
loginUser()
is called when it's available, it was added in Symfony 5.1: https://symfony.com/doc/5.4/testing.html#logging-in-users-authenticationWithout it, tests were broken. But with it, it may break some tests suites.