/
DoctrineMongoTestCase.php
55 lines (46 loc) · 1.67 KB
/
DoctrineMongoTestCase.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
<?php
/*
* This file is part of the GenemuFormBundle package.
*
* (c) Olivier Chauvel <olivier@generation-multiple.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Genemu\Bundle\FormBundle\Tests;
use Doctrine\ODM\MongoDB\Configuration;
use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\MongoDB\Connection;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Cache\ArrayCache;
/**
* @author Olivier Chauvel <olivier@generation-multiple.com>
*/
abstract class DoctrineMongoTestCase extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
if (!class_exists('Mongo')) {
$this->markTestSkipped('Mongo PHP/PECL Extension is not available.');
}
if (!class_exists('Doctrine\\Common\\Version')) {
$this->markTestSkipped('Doctrine is not available.');
}
}
/**
* @return EntityManager
*/
public static function createTestDocumentManager($paths = array())
{
$config = new Configuration();
$config->setAutoGenerateProxyClasses(true);
$config->setProxyDir(\sys_get_temp_dir());
$config->setHydratorDir(\sys_get_temp_dir());
$config->setProxyNamespace('GenemuFormBundleTests\Doctrine');
$config->setHydratorNamespace('GenemuFormBundleTests\Doctrine');
$config->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader(), $paths));
$config->setMetadataCacheImpl(new ArrayCache());
return DocumentManager::create(new Connection(), $config);
}
}