Closed
Description
Hi there,
Symfony version(s) affected: 4.2.3
Description
An old PR #26499 should allow us to use private services in test
env as public.
On my local, I am struggling to make it work. Post here
How to reproduce
- Install the latest version of Symfony and Symfony Bridge
- Create a service
- Create a test
<?php
namespace App\Tests;
// My service namespace here
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class ServiceTest extends WebTestCase
{
/**
* {@inheritdoc}
*/
public function setUp(): void
{
self::bootKernel();
}
public function test(): void
{
self::$container->get(Service::class);
}
}
- Run
./bin/phpunit --stop-on-failure
- Output
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: The "CLASS 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.
Additional context
File: vendor/symfony/framework-bundle/Test/TestContainer
Method: get
dump($this->getPrivateContainer()->has($id)); // False
dump($this->getPublicContainer()->has($id)); // False
dump($this->getRemovedIds()); // There is my service
Many thanks for your time,
Lelle
Metadata
Metadata
Assignees
Labels
No labels