Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
IonBazan committed Oct 15, 2021
1 parent 500d030 commit b107eb9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/Doctrine/ODM/MongoDB/Tests/Mapping/Driver/XmlDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use TestDocuments\InvalidPartialFilterDocument;
use TestDocuments\UserCustomIdGenerator;
use TestDocuments\UserNonStringOptions;
use TestDocuments\WildcardIndexDocument;

class XmlDriverTest extends AbstractDriverTest
{
Expand Down Expand Up @@ -71,6 +72,19 @@ public function testInvalidPartialFilterExpressions()
$this->driver->loadMetadataForClass(InvalidPartialFilterDocument::class, $classMetadata);
}

public function testWildcardIndexName(): void
{
$classMetadata = new ClassMetadata(WildcardIndexDocument::class);
$this->driver->loadMetadataForClass(WildcardIndexDocument::class, $classMetadata);

$this->assertSame([
[
'keys' => ['fieldA.$**' => 1],
'options' => ['name' => 'fieldA.$**_1'],
],
], $classMetadata->getIndexes());
}

public function testAlsoLoadFieldMapping()
{
$classMetadata = new ClassMetadata(AlsoLoadDocument::class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace TestDocuments;

class WildcardIndexDocument
{
protected $id;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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"
xsi:schemaLocation="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping
http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">

<document name="TestDocuments\WildcardIndexDocument" db="documents" collection="wildcardIndexDocument">
<id />
<indexes>
<index name="fieldA.$**_1">
<key name="fieldA.$**" />
</index>
</indexes>
</document>
</doctrine-mongo-mapping>

0 comments on commit b107eb9

Please sign in to comment.