Closed
Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | no |
RFC? | no |
Symfony version | 3.3.11 |
Hello there. I have the following test class.
namespace Tests\SmokeTests;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerInterface;
class ServicesTest extends WebTestCase
{
/**
* @var Container|ContainerInterface
*/
private static $container;
/**
* @var array
*/
private static $ignoreServices = [
'lexik_jwt_authentication.encoder.lcobucci',
'monolog.activation_strategy.not_found',
'monolog.handler.fingers_crossed.error_level_activation_strategy',
];
/**
* @inheritdoc
*/
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
self::bootKernel();
self::$container = self::$kernel->getContainer();
}
/**
* Smoke test that checks whether all the services
* load properly or not
*/
public function testSmokeTestServiceLoading()
{
$serviceIds = self::$container->getServiceIds();
foreach ($serviceIds as $serviceId) {
if (in_array($serviceId, self::$ignoreServices, true)) {
continue;
}
$service = self::$container->get($serviceId);
$this->assertNotNull($service);
}
}
}
The goal of this Test Class is to detect if in your Yaml if you have declared services in a wrong way. Something like this:
services:
app.myservice:
class: NotExisting\Namespace
app.yourservice:
class: Existing\Namespace
The above will throw a test error when it will try to fetch app.myservice
.
After updating to 3.3.11 my tests are failing because of this:
1) Tests\SmokeTests\ServicesTest::testSmokeTestServiceLoading
RuntimeException: Failed to set the session handler because headers have already been sent by "/MY_PATH/vendor/phpunit/phpunit/src/Util/Printer.php" at line 134.
/MY_PATH/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php:394
/MY_PATH/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php:120
/MY_PATH/var/cache/test/appTestDebugProjectContainer.php:4294
/MY_PATH/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php:329
/MY_PATH/tests/SmokeTests/ServicesTest.php:58