Skip to content

support phpcr-bundle 3 #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Changelog
=========

4.x
===

4.4.3
-----

* Support phpcr-bundle 3.

4.4.2
-----

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"require-dev": {
"doctrine/doctrine-bundle": "^1.8 || ^2.0",
"doctrine/phpcr-bundle": "^1.3 || ^2.0.0",
"doctrine/phpcr-bundle": "^1.3 || ^2.0 || ^3.0",
"symfony/console": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0",
"symfony/dependency-injection": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0",
"symfony/doctrine-bridge": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0",
Expand Down
13 changes: 10 additions & 3 deletions src/Functional/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,14 @@ protected function getDbManager(string $type)
));
}

$dbManager = new $className($this->getContainer());
$refl = new \ReflectionClass($className);
if (1 === $refl->getConstructor()->getNumberOfParameters()) {
// phpcr-bundle < 3
$dbManager = new $className(self::getContainer());
} else {
// phpcr-bundle >= 3
$dbManager = new $className(self::getContainer()->get('doctrine_phpcr'), self::getContainer()->get('doctrine_phpcr.initializer_manager'));
}

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

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

$dom = new \DomDocument();
$dom = new \DOMDocument();
$dom->loadHTML($response->getContent());

$xpath = new \DOMXpath($dom);
$xpath = new \DOMXPath($dom);
$result = $xpath->query('//div[contains(@class,"text-exception")]/h1');
$exception = null;
if ($result->length) {
Expand Down
2 changes: 1 addition & 1 deletion src/Unit/Constraint/SchemaAcceptsXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function matches($schemaFile): bool
throw new \InvalidArgumentException(sprintf('Can only test a file if it contains 1 <config> element, %d given', $configElement->length));
}

$configDom = new \DomDocument();
$configDom = new \DOMDocument();
$configDom->appendChild($configDom->importNode($configElement->item(0), true));

libxml_use_internal_errors(true);
Expand Down
25 changes: 16 additions & 9 deletions tests/Functional/BaseTestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

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

use Doctrine\Bundle\PHPCRBundle\Initializer\InitializerManager;
use Doctrine\Bundle\PHPCRBundle\ManagerRegistryInterface;
use Doctrine\Bundle\PHPCRBundle\Test\RepositoryManager;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
Expand All @@ -25,12 +27,12 @@
class BaseTestCaseTest extends TestCase
{
/**
* @var ContainerInterface|MockObject
* @var ContainerInterface&MockObject
*/
private $container;

/**
* @var KernelInterface|MockObject
* @var KernelInterface&MockObject
*/
private $kernel;

Expand All @@ -47,20 +49,24 @@ class BaseTestCaseTest extends TestCase
protected function setUp(): void
{
$this->container = $this->createMock(ContainerInterface::class);
$this->container->expects($this->any())
$this->container
->method('get')
->will($this->returnCallback(function ($name) {
$dic = ['test.client' => $this->client];
->willReturnCallback(function ($name) {
$dic = [
'test.client' => $this->client,
'doctrine_phpcr' => $this->createMock(ManagerRegistryInterface::class),
'doctrine_phpcr.initializer_manager' => $this->createMock(InitializerManager::class),
];

return $dic[$name];
}));
});

$this->kernel = $this->createMock(KernelInterface::class);
$this->kernel->expects($this->any())
$this->kernel
->method('getContainer')
->willReturn($this->container)
;
$this->kernel->expects($this->any())
$this->kernel
->method('getEnvironment')
->willReturn('phpcr')
;
Expand All @@ -74,7 +80,7 @@ protected function setUp(): void
$this->client = $this->createMock(Client::class);
}

$this->client->expects($this->any())
$this->client
->method('getContainer')
->willReturn($this->container);
}
Expand Down Expand Up @@ -122,6 +128,7 @@ public function provideTestDb()

/**
* @dataProvider provideTestDb
*
* @depends testGetContainer
*/
public function testDb($dbName, $expected)
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Constraint/SchemaAcceptsXmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ public function getAssertingData()

$data = [];

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

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

Expand All @@ -70,7 +70,7 @@ public function getAssertingData()

public function testFailsIfNoConfigElementIsAvailable()
{
$dom = new \DomDocument();
$dom = new \DOMDocument();
$dom->loadXML('<container></container>');

$constraint = new SchemaAcceptsXml([$dom]);
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/XmlSchemaTestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ class XmlSchemaTestCaseTest extends XmlSchemaTestCase
{
public function testAcceptsSingleDomsWithoutArray()
{
$dom = new \DomDocument();
$dom = new \DOMDocument();
$dom->loadXML('<container><config xmlns="http://cmf.symfony.com/schema/dic/foo" required="f"/></container>');
$this->assertSchemaAcceptsXml($dom, __DIR__.'/../Fixtures/schema/schema1.xsd');
}

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

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