-
Notifications
You must be signed in to change notification settings - Fork 72
/
ContainerLoader.php
32 lines (24 loc) · 920 Bytes
/
ContainerLoader.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
namespace OAuth2\ServerBundle\Tests;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\Config\FileLocator;
class ContainerLoader
{
public static function buildTestContainer($configs = array())
{
if (!isset($_SERVER['CONTAINER_CONFIG'])) {
throw new \Exception('Must set CONTAINER_CONFIG in phpunit.xml or environment variable');
}
$container = new ContainerBuilder();
$locator = new FileLocator(__DIR__ . '/..');
$loader = new XmlFileLoader($container, $locator);
$loader->load($_SERVER['CONTAINER_CONFIG']);
foreach ($configs as $file) {
$loader->load($file);
}
// give the container some context
$container->setParameter('bundle_root_dir', __DIR__.'/..');
return $container;
}
}