Skip to content

Commit 7463d4d

Browse files
committed
Various changes
- Fixed manager factory to not return new instances. - Enabled custom documents to be loaded from `Tests\Functional\App\Document`
1 parent 336731b commit 7463d4d

File tree

5 files changed

+61
-25
lines changed

5 files changed

+61
-25
lines changed

skeleton/app/config/default.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
<?php
22

3+
$kernelRootDir = $container->getParameter('kernel.root_dir');
4+
$bundleName = null;
5+
6+
if (preg_match('&/([a-zA-Z]*?)Bundle&', $kernelRootDir, $matches)) {
7+
$bundleName = $matches[1].'Bundle';
8+
$bundleFQN = 'Symfony\\Cmf\\Bundle\\'.$matches[1].'Bundle';
9+
$container->setParameter('cmf_testing.bundle_name', $bundleName);
10+
$container->setParameter('cmf_testing.bundle_fqn', $bundleFQN);
11+
}
12+
313
$loader->import('dist/parameters.yml');
414
$loader->import('dist/framework.yml');
515
$loader->import('dist/doctrine.yml');
6-
$loader->import('dist/phpcrodm.yml');
716
$loader->import('dist/security.yml');
17+
$loader->import('dist/phpcrodm.php');

skeleton/app/config/dist/phpcrodm.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
$config = array(
4+
'session' => array(
5+
'backend' => '%phpcr_backend%',
6+
'workspace' => '%phpcr_workspace%',
7+
'username' => '%phpcr_user%',
8+
'password' => '%phpcr_pass%',
9+
),
10+
'odm' => array(
11+
'auto_mapping' => true,
12+
'auto_generate_proxy_classes' => '%kernel.debug%',
13+
'locales' => array(
14+
'en' => array('de', 'fr'),
15+
'de' => array('en', 'fr'),
16+
'fr' => array('en', 'de'),
17+
),
18+
),
19+
);
20+
21+
$kernelRootDir = $container->getParameter('kernel.root_dir');
22+
$bundleFQN = $container->getParameter('cmf_testing.bundle_fqn');
23+
$phpcrOdmDocDir = sprintf('%s/../Document', $kernelRootDir);
24+
$phpcrOdmDocPrefix = sprintf('%s\Tests\Functional\App\Document', $bundleFQN);
25+
26+
if (file_exists($phpcrOdmDocDir)) {
27+
$config['odm']['mappings'] = array(
28+
'test' => array(
29+
'type' => 'annotation',
30+
'prefix' => $phpcrOdmDocPrefix,
31+
'dir' => $phpcrOdmDocDir,
32+
'is_bundle' => false,
33+
),
34+
);
35+
}
36+
37+
$container->loadFromExtension('doctrine_phpcr', $config);

skeleton/app/config/dist/phpcrodm.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/Symfony/Cmf/Component/Testing/Functional/BaseTestCase.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
abstract class BaseTestCase extends WebTestCase
88
{
99
protected $db;
10+
protected $dbManagers = array();
1011

1112
public function getContainer()
1213
{
@@ -22,6 +23,10 @@ public function db($type)
2223

2324
public function getDbManager($type)
2425
{
26+
if (isset($this->dbManagers[$type])) {
27+
return $this->dbManagers[$type];
28+
}
29+
2530
$className = sprintf(
2631
'Symfony\Cmf\Component\Testing\Functional\DbManager\%s',
2732
$type
@@ -36,6 +41,8 @@ public function getDbManager($type)
3641

3742
$dbManager = new $className($this->getContainer());
3843

39-
return $dbManager;
44+
$this->dbManagers[$type] = $dbManager;
45+
46+
return $this->getDbManager($type);
4047
}
4148
}

src/Symfony/Cmf/Component/Testing/Functional/DbManager/PHPCR.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
class PHPCR
1414
{
1515
protected $container;
16+
protected $om;
1617

1718
public function __construct(ContainerInterface $container)
1819
{
@@ -26,8 +27,10 @@ public function getRegistry()
2627

2728
public function getOm()
2829
{
29-
$om = $this->getRegistry()->getManager();
30-
return $om;
30+
if (!$this->om) {
31+
$this->om = $this->getRegistry()->getManager();
32+
}
33+
return $this->om;
3134
}
3235

3336
public function loadFixtures(array $classNames)

0 commit comments

Comments
 (0)