forked from doctrine/DoctrineBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestCase.php
83 lines (75 loc) · 3.23 KB
/
TestCase.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/*
* This file is part of the Doctrine Bundle
*
* The code was originally distributed inside the Symfony framework.
*
* (c) Fabien Potencier <[email protected]>
* (c) Doctrine Project, Benjamin Eberlei <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Doctrine\Bundle\DoctrineBundle\Tests;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
use Symfony\Component\DependencyInjection\Compiler\ResolveDefinitionTemplatesPass;
class TestCase extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
if (!class_exists('Doctrine\\Common\\Version')) {
$this->markTestSkipped('Doctrine is not available.');
}
}
public function createYamlBundleTestContainer()
{
$container = new ContainerBuilder(new ParameterBag(array(
'kernel.debug' => false,
'kernel.bundles' => array('YamlBundle' => 'Fixtures\Bundles\YamlBundle\YamlBundle'),
'kernel.cache_dir' => sys_get_temp_dir(),
'kernel.environment' => 'test',
'kernel.root_dir' => __DIR__.'/../../../../', // src dir
)));
$container->set('annotation_reader', new AnnotationReader());
$extension = new DoctrineExtension();
$container->registerExtension($extension);
$extension->load(array(array(
'dbal' => array(
'connections' => array(
'default' => array(
'driver' => 'pdo_mysql',
'charset' => 'UTF8',
'platform-service' => 'my.platform',
),
),
'default_connection' => 'default',
'types' => array(
'test' => 'Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestType',
),
), 'orm' => array(
'default_entity_manager' => 'default',
'entity_managers' => array (
'default' => array(
'mappings' => array('YamlBundle' => array(
'type' => 'yml',
'dir' => __DIR__.'/DependencyInjection/Fixtures/Bundles/YamlBundle/Resources/config/doctrine',
'prefix' => 'Fixtures\Bundles\YamlBundle\Entity',
)),
),
),
'resolve_target_entities' => array(
'Symfony\Component\Security\Core\User\UserInterface' => 'stdClass',
),
),
)), $container);
$container->setDefinition('my.platform', new Definition('Doctrine\DBAL\Platforms\MySqlPlatform'));
$container->getCompilerPassConfig()->setOptimizationPasses(array(new ResolveDefinitionTemplatesPass()));
$container->getCompilerPassConfig()->setRemovingPasses(array());
$container->compile();
return $container;
}
}