Skip to content

Commit 65cfa4e

Browse files
committed
support phpcr-bundle 3
1 parent 504f9ab commit 65cfa4e

File tree

6 files changed

+40
-18
lines changed

6 files changed

+40
-18
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
Changelog
22
=========
33

4+
4.x
5+
===
6+
7+
4.4.3
8+
-----
9+
10+
* Support phpcr-bundle 3.
11+
412
4.4.2
513
-----
614

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"require-dev": {
1717
"doctrine/doctrine-bundle": "^1.8 || ^2.0",
18-
"doctrine/phpcr-bundle": "^1.3 || ^2.0.0",
18+
"doctrine/phpcr-bundle": "^1.3 || ^2.0 || ^3.0",
1919
"symfony/console": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0",
2020
"symfony/dependency-injection": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0",
2121
"symfony/doctrine-bridge": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0",

src/Functional/BaseTestCase.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,14 @@ protected function getDbManager(string $type)
167167
));
168168
}
169169

170-
$dbManager = new $className($this->getContainer());
170+
$refl = new \ReflectionClass($className);
171+
if (1 === $refl->getConstructor()->getNumberOfParameters()) {
172+
// phpcr-bundle < 3
173+
$dbManager = new $className(self::getContainer());
174+
} else {
175+
// phpcr-bundle >= 3
176+
$dbManager = new $className(self::getContainer()->get('doctrine_phpcr'), self::getContainer()->get('doctrine_phpcr.initializer_manager'));
177+
}
171178

172179
$this->dbManagers[$type] = $dbManager;
173180

@@ -178,10 +185,10 @@ protected static function assertResponseSuccess(Response $response)
178185
{
179186
libxml_use_internal_errors(true);
180187

181-
$dom = new \DomDocument();
188+
$dom = new \DOMDocument();
182189
$dom->loadHTML($response->getContent());
183190

184-
$xpath = new \DOMXpath($dom);
191+
$xpath = new \DOMXPath($dom);
185192
$result = $xpath->query('//div[contains(@class,"text-exception")]/h1');
186193
$exception = null;
187194
if ($result->length) {

tests/Functional/BaseTestCaseTest.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Cmf\Component\Testing\Tests\Functional;
1313

14+
use Doctrine\Bundle\PHPCRBundle\Initializer\InitializerManager;
15+
use Doctrine\Bundle\PHPCRBundle\ManagerRegistryInterface;
1416
use Doctrine\Bundle\PHPCRBundle\Test\RepositoryManager;
1517
use PHPUnit\Framework\MockObject\MockObject;
1618
use PHPUnit\Framework\TestCase;
@@ -25,12 +27,12 @@
2527
class BaseTestCaseTest extends TestCase
2628
{
2729
/**
28-
* @var ContainerInterface|MockObject
30+
* @var ContainerInterface&MockObject
2931
*/
3032
private $container;
3133

3234
/**
33-
* @var KernelInterface|MockObject
35+
* @var KernelInterface&MockObject
3436
*/
3537
private $kernel;
3638

@@ -47,20 +49,24 @@ class BaseTestCaseTest extends TestCase
4749
protected function setUp(): void
4850
{
4951
$this->container = $this->createMock(ContainerInterface::class);
50-
$this->container->expects($this->any())
52+
$this->container
5153
->method('get')
52-
->will($this->returnCallback(function ($name) {
53-
$dic = ['test.client' => $this->client];
54+
->willReturnCallback(function ($name) {
55+
$dic = [
56+
'test.client' => $this->client,
57+
'doctrine_phpcr' => $this->createMock(ManagerRegistryInterface::class),
58+
'doctrine_phpcr.initializer_manager' => $this->createMock(InitializerManager::class),
59+
];
5460

5561
return $dic[$name];
56-
}));
62+
});
5763

5864
$this->kernel = $this->createMock(KernelInterface::class);
59-
$this->kernel->expects($this->any())
65+
$this->kernel
6066
->method('getContainer')
6167
->willReturn($this->container)
6268
;
63-
$this->kernel->expects($this->any())
69+
$this->kernel
6470
->method('getEnvironment')
6571
->willReturn('phpcr')
6672
;
@@ -74,7 +80,7 @@ protected function setUp(): void
7480
$this->client = $this->createMock(Client::class);
7581
}
7682

77-
$this->client->expects($this->any())
83+
$this->client
7884
->method('getContainer')
7985
->willReturn($this->container);
8086
}
@@ -122,6 +128,7 @@ public function provideTestDb()
122128

123129
/**
124130
* @dataProvider provideTestDb
131+
*
125132
* @depends testGetContainer
126133
*/
127134
public function testDb($dbName, $expected)

tests/Unit/Constraint/SchemaAcceptsXmlTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ public function getAssertingData()
5353

5454
$data = [];
5555

56-
$dom1 = new \DomDocument();
56+
$dom1 = new \DOMDocument();
5757
$dom1->loadXML('<container><config xmlns="http://cmf.symfony.com/schema/dic/foo" required="f"/></container>');
5858
$data[] = [[$dom1], $schema1, true];
5959

60-
$dom2 = new \DomDocument();
60+
$dom2 = new \DOMDocument();
6161
$dom2->loadXML('<container><config xmlns="http://cmf.symfony.com/schema/dic/foo" /></container>');
6262
$data[] = [[$dom2], $schema1, false];
6363

@@ -70,7 +70,7 @@ public function getAssertingData()
7070

7171
public function testFailsIfNoConfigElementIsAvailable()
7272
{
73-
$dom = new \DomDocument();
73+
$dom = new \DOMDocument();
7474
$dom->loadXML('<container></container>');
7575

7676
$constraint = new SchemaAcceptsXml([$dom]);

tests/Unit/XmlSchemaTestCaseTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ class XmlSchemaTestCaseTest extends XmlSchemaTestCase
1717
{
1818
public function testAcceptsSingleDomsWithoutArray()
1919
{
20-
$dom = new \DomDocument();
20+
$dom = new \DOMDocument();
2121
$dom->loadXML('<container><config xmlns="http://cmf.symfony.com/schema/dic/foo" required="f"/></container>');
2222
$this->assertSchemaAcceptsXml($dom, __DIR__.'/../Fixtures/schema/schema1.xsd');
2323
}
2424

2525
public function testNegativeAssertion()
2626
{
27-
$dom = new \DomDocument();
27+
$dom = new \DOMDocument();
2828
$dom->loadXML('<container><config xmlns="http://cmf.symfony.com/schema/dic/foo" /></container>');
2929

3030
$this->assertSchemaRefusesXml($dom, __DIR__.'/../Fixtures/schema/schema1.xsd');

0 commit comments

Comments
 (0)