Created
December 5, 2015 22:44
-
-
Save Maff-/c9d2c1592a746da85d5b to your computer and use it in GitHub Desktop.
Symfony2 Service Availability Smoke Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace AppBundle\Tests; | |
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; | |
class ServiceAvailabilityFunctionalTest extends KernelTestCase | |
{ | |
protected $serviceBlacklist = [ | |
'request', | |
'form.csrf_provider', | |
'security.context', | |
'security.secure_random', | |
]; | |
/** | |
* @dataProvider serviceIdProvider | |
* @param string $serviceId | |
*/ | |
public function testServiceCreationIsSuccessful($serviceId) | |
{ | |
static::bootKernel(); | |
static::$kernel->getContainer()->get($serviceId); | |
} | |
public function serviceIdProvider() | |
{ | |
static::bootKernel(); | |
/** @var \Symfony\Component\DependencyInjection\Container $container */ | |
$container = static::$kernel->getContainer(); | |
$serviceIds = $container->getServiceIds(); | |
$serviceIds = array_diff($serviceIds, $this->serviceBlacklist); | |
return array_chunk($serviceIds, 1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Any way to simulate request scope to test related services and get rid of this error?