Skip to content

Commit dd8d71d

Browse files
committed
the repositorymanager is not BC with the PHPCR manager
1 parent c0aff04 commit dd8d71d

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

src/Functional/BaseTestCase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\Bundle\PHPCRBundle\Test\RepositoryManager;
1515
use Symfony\Bundle\FrameworkBundle\Client;
1616
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
17+
use Symfony\Cmf\Component\Testing\Functional\DbManager\PhpcrDecorator;
1718
use Symfony\Component\DependencyInjection\Container;
1819
use Symfony\Component\HttpFoundation\Response;
1920

@@ -114,7 +115,7 @@ public function getDbManager($type)
114115
);
115116

116117
if ('phpcr' === strtolower($type) && class_exists(RepositoryManager::class)) {
117-
$className = RepositoryManager::class;
118+
$className = PhpcrDecorator::class;
118119
}
119120

120121
if (!class_exists($className)) {
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony CMF package.
5+
*
6+
* (c) 2011-2017 Symfony CMF
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Cmf\Component\Testing\Functional\DbManager;
13+
14+
use Doctrine\Bundle\PHPCRBundle\Test\RepositoryManager;
15+
use Doctrine\ODM\PHPCR\DocumentManagerInterface;
16+
17+
/**
18+
* A decorator around the DoctrinePHPCRBundle RepositoryManager class to
19+
* provide BC with the PHPCR manager in this bundle.
20+
*/
21+
class PhpcrDecorator extends RepositoryManager
22+
{
23+
public function getOm(string $managerName = null): DocumentManagerInterface
24+
{
25+
return $this->getDocumentManager($managerName);
26+
}
27+
28+
/**
29+
* Create a test node, if the test node already exists, remove it.
30+
*/
31+
public function createTestNode()
32+
{
33+
$session = $this->getDocumentManager()->getPhpcrSession();
34+
35+
if ($session->nodeExists('/test')) {
36+
$session->getNode('/test')->remove();
37+
}
38+
39+
$session->getRootNode()->addNode('test', 'nt:unstructured');
40+
41+
$session->save();
42+
}
43+
}

0 commit comments

Comments
 (0)