Skip to content
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

Allow elements from other namespaces #2607

Open
wants to merge 1 commit into
base: 2.10.x
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions doctrine-mongo-mapping.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<xs:element name="shard-key" type="odm:shard-key" minOccurs="0" />
<xs:element name="read-preference" type="odm:read-preference" minOccurs="0" />
<xs:element name="schema-validation" type="odm:schema-validation" minOccurs="0" />
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:choice>

<xs:attribute name="db" type="xs:NMTOKEN" />
Expand Down
17 changes: 17 additions & 0 deletions tests/Doctrine/ODM/MongoDB/Tests/Mapping/XmlMappingDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\ODM\MongoDB\Mapping\Driver\XmlDriver;
use Doctrine\ODM\MongoDB\Mapping\MappingException;
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
use ReflectionMethod;
use SimpleXMLElement;
use stdClass;
Expand Down Expand Up @@ -50,4 +51,20 @@ public function testInvalidMappingFileTriggersException(): void

$mappingDriver->loadMetadataForClass($className, $class);
}

#[DoesNotPerformAssertions]
public function testExtensionTagsAreAllowedWhenNamespaced(): void
{
$className = DocumentWithExtension::class;
$mappingDriver = $this->loadDriver();

$class = new ClassMetadata($className);

$mappingDriver->loadMetadataForClass($className, $class);
}
}

class DocumentWithExtension
{
public ?string $id;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<doctrine-mongo-mapping
xmlns="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping"
xsi:schemaLocation="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping
http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd"
>
<document name="Doctrine\ODM\MongoDB\Tests\Mapping\DocumentWithExtension">
<field name="id"/>
<gedmo:loggable/>
</document>
</doctrine-mongo-mapping>
Loading