I am trying to migrate my Symfony 3.4 app to Symfony 4.1.
The tests are not working because the services are by default private (and it's a good news).
Following this post: https://symfony.com/blog/new-in-symfony-4-1-simpler-service-testing, I am still facing the issue of private service :
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: The "my.service" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.
In the following compiler pass, my private service was not found in the $definitions
: vendor/symfony/framework-bundle/DependencyInjection/Compiler/TestServiceContainerRealRefPass.php
What should be the problem?
UPDATED
Here the definition :
<service id="my.service"
class="My\Bundle\GreatService">
<argument type="service" id="doctrine.orm.entity_manager" />
</service>
UPDATED (again)
Here the Unit test
<?php
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
class MyServiceTest extends KernelTestCase
{
protected $myService;
public function setUp()
{
self::bootKernel();
$this->myService = self::$container->get('my.service');
}
//...
}