Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
AttributeDriver example
use
Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\EnumString;
use
Symfony\Component\PropertyInfo\Type;
/** * @author Kévin Dunglas <dunglas@gmail.com> */
class
DoctrineExtractorTest
extends
TestCase
{
private
function
createExtractor
(
)
: DoctrineExtractor
{
$config
= ORMSetup::
createConfiguration
(
true
)
;
$config
->
setMetadataDriverImpl
(
new
AttributeDriver
(
[
__DIR__.'/../Tests/Fixtures' => 'Symfony\Bridge\Doctrine\Tests\Fixtures'
]
, true
)
)
;
if
(
class_exists
(
DefaultSchemaManagerFactory::
class
)
)
{
$config
->
setSchemaManagerFactory
(
new
DefaultSchemaManagerFactory
(
)
)
;
}
$config
->
setLazyGhostObjectEnabled
(
true
)
;
$eventManager
=
new
EventManager
(
)
;
$entityManager
=
new
EntityManager
(
DriverManager::
getConnection
(
[
'driver' => 'pdo_sqlite'
]
,
$config
,
$eventManager
)
,
$config
,
$eventManager
)
;
if
(
!DBALType::
hasType
(
'foo'
)
)
{
DBALType::
addType
(
'foo', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineFooType'
)
;
$entityManager
->
getConnection
(
)
->
getDatabasePlatform
(
)
->
registerDoctrineTypeMapping
(
'custom_foo', 'foo'
)
;
}
return
new
EntityManager
(
DriverManager::
getConnection
(
$params
,
$config
,
$eventManager
)
,
$config
,
$eventManager
)
;
}
public
static
function
createTestConfiguration
(
)
: Configuration
{
$config
= ORMSetup::
createConfiguration
(
true
)
;
$config
->
setEntityNamespaces
(
[
'SymfonyTestsDoctrine' => 'Symfony\Bridge\Doctrine\Tests\Fixtures'
]
)
;
$config
->
setAutoGenerateProxyClasses
(
true
)
;
$config
->
setProxyDir
(
sys_get_temp_dir
(
)
)
;
$config
->
setProxyNamespace
(
'SymfonyTests\Doctrine'
)
;
$config
->
setMetadataDriverImpl
(
new
AttributeDriver
(
[
__DIR__.'/../Tests/Fixtures' => 'Symfony\Bridge\Doctrine\Tests\Fixtures'
]
, true
)
)
;
if
(
class_exists
(
DefaultSchemaManagerFactory::
class
)
)
{
$config
->
setSchemaManagerFactory
(
new
DefaultSchemaManagerFactory
(
)
)
;
}
$config
->
setLazyGhostObjectEnabled
(
true
)
;
return
$config
;
}
public
static
function
createTestConfigurationWithXmlLoader
(
)
: Configuration
{
$config
= self::
createTestConfiguration
(
)
;