Skip to content
This repository
Browse code

Add XmlDriver and tests

  • Loading branch information...
commit 8c046b48248d2d6211266301265dcd4ea1736251 1 parent 04d373b
Benjamin Eberlei authored May 21, 2011
40  lib/Doctrine/ODM/CouchDB/Mapping/ClassMetadataInfo.php
@@ -264,14 +264,35 @@ public function mapAttachments($fieldName)
264 264
         $this->hasAttachments = true;
265 265
         $this->attachmentField = $fieldName;
266 266
     }
  267
+    
  268
+    /**
  269
+     * Map an embedded object
  270
+     * 
  271
+     * - fieldName - The name of the property/field on the mapped php class
  272
+     * - jsonName - JSON key name of this field in CouchDB.
  273
+     * - targetDocument - Name of the target document
  274
+     * - embedded - one or many embedded objects?
  275
+     * 
  276
+     * @param array $mapping 
  277
+     */
  278
+    public function mapEmbedded(array $mapping)
  279
+    {
  280
+        //$mapping = $this->validateAndCompleteReferenceMapping($mapping);
  281
+        
  282
+        $this->mapField($mapping);
  283
+    }
267 284
 
268 285
     /**
269 286
      * Map a field.
270 287
      *
271 288
      * - type - The Doctrine Type of this field.
272 289
      * - fieldName - The name of the property/field on the mapped php class
  290
+     * - jsonName - JSON key name of this field in CouchDB.
273 291
      * - name - The JSON key of this field in the CouchDB document
274 292
      * - id - True for an ID field.
  293
+     * - strategy - ID Generator strategy when the field is an id-field.
  294
+     * - indexed - Is this field indexed for the Doctrine CouchDB repository view
  295
+     * - isVersionField - Is this field containing the revision number of this document?
275 296
      *
276 297
      * @param array $mapping The mapping information.
277 298
      */
@@ -289,6 +310,7 @@ public function mapField(array $mapping)
289 310
             $this->setIdentifier($mapping['fieldName']);
290 311
             if (isset($mapping['strategy'])) {
291 312
                 $this->idGenerator = constant('Doctrine\ODM\CouchDB\Mapping\ClassMetadata::IDGENERATOR_' . strtoupper($mapping['strategy']));
  313
+                unset($mapping['strategy']);
292 314
             }
293 315
         } else if (isset($mapping['isVersionField'])) {
294 316
             $this->isVersioned = true;
@@ -305,7 +327,7 @@ public function mapField(array $mapping)
305 327
 
306 328
     protected function validateAndCompleteFieldMapping($mapping)
307 329
     {
308  
-        if ( ! isset($mapping['fieldName'])) {
  330
+        if ( ! isset($mapping['fieldName']) || !$mapping['fieldName']) {
309 331
             throw new MappingException("Mapping a property requires to specify the name.");
310 332
         }
311 333
         if ( ! isset($mapping['jsonName'])) {
@@ -317,12 +339,9 @@ protected function validateAndCompleteFieldMapping($mapping)
317 339
 
318 340
         return $mapping;
319 341
     }
320  
-
321  
-    protected function validateAndCompleteAssociationMapping($mapping)
  342
+    
  343
+    protected function validateAndCompleteReferenceMapping($mapping)
322 344
     {
323  
-        $mapping = $this->validateAndCompleteFieldMapping($mapping);
324  
-
325  
-        $mapping['sourceDocument'] = $this->name;
326 345
         if (!isset($mapping['targetDocument'])) {
327 346
             throw new MappingException("You have to specify a 'targetDocument' class for the '" . $this->name . "#". $mapping['jsonName']."' association.");
328 347
         }
@@ -332,6 +351,15 @@ protected function validateAndCompleteAssociationMapping($mapping)
332 351
         return $mapping;
333 352
     }
334 353
 
  354
+    protected function validateAndCompleteAssociationMapping($mapping)
  355
+    {
  356
+        $mapping = $this->validateAndCompleteFieldMapping($mapping);
  357
+
  358
+        $mapping['sourceDocument'] = $this->name;
  359
+        $mapping = $this->validateAndCompleteReferenceMapping($mapping);
  360
+        return $mapping;
  361
+    }
  362
+
335 363
     public function mapManyToOne($mapping)
336 364
     {
337 365
         $mapping = $this->validateAndCompleteAssociationMapping($mapping);
6  lib/Doctrine/ODM/CouchDB/Mapping/Driver/AnnotationDriver.php
@@ -132,6 +132,7 @@ public function loadMetadataForClass($className, ClassMetadata $class)
132 132
                     }
133 133
 
134 134
                     $mapping = array_merge($mapping, (array) $fieldAnnot);
  135
+                    unset($mapping['value']);
135 136
                     $class->mapField($mapping);
136 137
                 } else if ($fieldAnnot instanceof \Doctrine\ODM\CouchDB\Mapping\ReferenceOne) {
137 138
                     $cascade = 0;
@@ -141,6 +142,7 @@ public function loadMetadataForClass($className, ClassMetadata $class)
141 142
                     $fieldAnnot->cascade = $cascade;
142 143
 
143 144
                     $mapping = array_merge($mapping, (array) $fieldAnnot);
  145
+                    unset($mapping['value']);
144 146
                     $class->mapManyToOne($mapping);
145 147
                 } else if ($fieldAnnot instanceof \Doctrine\ODM\CouchDB\Mapping\ReferenceMany) {
146 148
                     $cascade = 0;
@@ -150,12 +152,14 @@ public function loadMetadataForClass($className, ClassMetadata $class)
150 152
                     $fieldAnnot->cascade = $cascade;
151 153
 
152 154
                     $mapping = array_merge($mapping, (array) $fieldAnnot);
  155
+                    unset($mapping['value']);
153 156
                     $class->mapManyToMany($mapping);
154 157
                 } else if ($fieldAnnot instanceof \Doctrine\ODM\CouchDB\Mapping\Attachments) {
155 158
                     $class->mapAttachments($mapping['fieldName']);
156 159
                 } else if ($fieldAnnot instanceof \Doctrine\ODM\CouchDB\Mapping\EmbedOne || $fieldAnnot instanceof \Doctrine\ODM\CouchDB\Mapping\EmbedMany) {
157 160
                     $mapping = array_merge($mapping, (array) $fieldAnnot);
158  
-                    $class->mapField($mapping);
  161
+                    unset($mapping['value']);
  162
+                    $class->mapEmbedded($mapping);
159 163
                 }
160 164
             }
161 165
         }
2  lib/Doctrine/ODM/CouchDB/Mapping/Driver/PHPDriver.php
@@ -80,7 +80,7 @@ public function addPaths(array $paths)
80 80
      */
81 81
     public function loadMetadataForClass($className, ClassMetadata $metadata)
82 82
     {
83  
-        call_user_func_array(array($className, 'loadMetadata'), array($metadata));
  83
+        $className::loadMetadata($metadata);
84 84
     }
85 85
     
86 86
     /**
173  lib/Doctrine/ODM/CouchDB/Mapping/Driver/XmlDriver.php
@@ -28,8 +28,7 @@
28 28
  * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
29 29
  * @link        www.doctrine-project.org
30 30
  * @since       1.0
31  
- * @author      Jonathan H. Wage <jonwage@gmail.com>
32  
- * @author      Roman Borschel <roman@code-factory.org>
  31
+ * @author      Benjamin Eberlei <kontakt@beberlei.de>
33 32
  */
34 33
 class XmlDriver extends AbstractFileDriver
35 34
 {
@@ -45,88 +44,101 @@ class XmlDriver extends AbstractFileDriver
45 44
      */
46 45
     public function loadMetadataForClass($className, ClassMetadata $class)
47 46
     {
  47
+        /* @var $xmlRoot SimpleXMLElement */
48 48
         $xmlRoot = $this->getElement($className);
49  
-        if ( ! $xmlRoot) {
50  
-            return;
51  
-        }
52  
-        if ($xmlRoot->getName() == 'document') {
53  
-            if (isset($xmlRoot['repository-class'])) {
54  
-                $class->setCustomRepositoryClass((string) $xmlRoot['repository-class']);
  49
+        
  50
+        if ($xmlRoot->getName() == "document") {
  51
+            $class->setCustomRepositoryClass(
  52
+                isset($xmlRoot['repository-class']) ? (string)$xmlRoot['repository-class'] : null
  53
+            );
  54
+            
  55
+            if (isset($xmlRoot['indexed']) && $xmlRoot['indexed'] == true) {
  56
+                $class->indexed = true;
55 57
             }
56  
-        } elseif ($xmlRoot->getName() == 'embedded-document') {
  58
+        } else if ($xmlRoot->getName() == "embedded-document") {
57 59
             $class->isEmbeddedDocument = true;
  60
+        } else {
  61
+            throw MappingException::classIsNotAValidDocument($className);
58 62
         }
59  
-        if (isset($xmlRoot['db'])) {
60  
-            $class->setDB((string) $xmlRoot['db']);
61  
-        }
  63
+        
  64
+        // Evaluate <field ...> mappings
62 65
         if (isset($xmlRoot->field)) {
63  
-            foreach ($xmlRoot->field as $field) {
64  
-                $mapping = array();
65  
-                $attributes = $field->attributes();
66  
-                foreach ($attributes as $key => $value) {
67  
-                    $mapping[$key] = (string) $value;
68  
-                    $booleanAttributes = array('id', 'reference', 'embed', 'unique');
69  
-                    if (in_array($key, $booleanAttributes)) {
70  
-                        $mapping[$key] = ('true' === $mapping[$key]) ? true : false;
71  
-                    }
72  
-                }
73  
-                $this->addFieldMapping($class, $mapping);
  66
+            foreach ($xmlRoot->field as $fieldMapping) {
  67
+                $class->mapField(array(
  68
+                    'fieldName' => (string)$fieldMapping['name'],
  69
+                    'jsonName'  => (isset($fieldMapping['json-name'])) ? (string)$fieldMapping['json-name'] : null,
  70
+                    'indexed'   => (isset($fieldMapping['indexed'])) ? (bool)$fieldMapping['indexed'] : false,
  71
+                    'type'      => (isset($fieldMapping['type'])) ? (string)$fieldMapping['type'] : null,
  72
+                    'version'   => (isset($fieldMapping['version'])) ? (bool)$fieldMapping['version'] : null,
  73
+                ));
74 74
             }
75 75
         }
76  
-        if (isset($xmlRoot->{'embed-one'})) {
77  
-            foreach ($xmlRoot->{'embed-one'} as $embed) {
78  
-                $this->addEmbedMapping($class, $embed, 'one');
79  
-            }
  76
+        
  77
+        // Evaluate <id ..> mappings
  78
+        foreach ($xmlRoot->id as $idElement) {
  79
+            $class->mapField(array(
  80
+                'fieldName' => (string)$idElement['name'],
  81
+                'jsonName'  => (isset($idElement['json-name'])) ? (string)$idElement['json-name'] : null,
  82
+                'indexed'   => (isset($idElement['indexed'])) ? (bool)$idElement['indexed'] : false,
  83
+                'type'      => (isset($idElement['type'])) ? (string)$idElement['type'] : null,
  84
+                'id'        => true,
  85
+                'strategy'  => (isset($idElement['strategy'])) ? (string)$idElement['strategy'] : null,
  86
+            ));
80 87
         }
81  
-        if (isset($xmlRoot->{'embed-many'})) {
82  
-            foreach ($xmlRoot->{'embed-many'} as $embed) {
83  
-                $this->addEmbedMapping($class, $embed, 'many');
  88
+        
  89
+        // Evaluate <many-to-one ..> mappings
  90
+        if (isset($xmlRoot->{"reference-one"})) {
  91
+            foreach ($xmlRoot->{"reference-one"} as $referenceOneElement) {
  92
+                $class->mapManyToOne(array(
  93
+                    'cascade'           => (isset($referenceManyElement->cascade)) ? $this->getCascadeMode($referenceManyElement->cascade) : 0,
  94
+                    'targetDocument'    => (string)$referenceOneElement['target-document'],
  95
+                    'fieldName'         => (string)$referenceOneElement['field'],
  96
+                    'jsonName'          => (isset($referenceOneElement['json-name'])) ? (string)$referenceOneElement['json-name'] : null,
  97
+                ));
84 98
             }
85 99
         }
86  
-        if (isset($xmlRoot->{'reference-many'})) {
87  
-            foreach ($xmlRoot->{'reference-many'} as $reference) {
88  
-                $this->addReferenceMapping($class, $reference, 'many');
  100
+        
  101
+        // Evaluate <many-to-one ..> mappings
  102
+        if (isset($xmlRoot->{"reference-many"})) {
  103
+            foreach ($xmlRoot->{"reference-many"} as $referenceManyElement) {
  104
+                $class->mapManyToMany(array(
  105
+                    'cascade'           => (isset($referenceManyElement->cascade)) ? $this->getCascadeMode($referenceManyElement->cascade) : 0,
  106
+                    'targetDocument'    => (string)$referenceManyElement['target-document'],
  107
+                    'fieldName'         => (string)$referenceManyElement['field'],
  108
+                    'jsonName'          => (isset($referenceManyElement['json-name'])) ? (string)$referenceManyElement['json-name'] : null,
  109
+                    'mappedBy'          => (isset($referenceManyElement['mapped-by'])) ? (string)$referenceManyElement['mapped-by'] : null,
  110
+                ));
89 111
             }
90 112
         }
91  
-        if (isset($xmlRoot->{'reference-one'})) {
92  
-            foreach ($xmlRoot->{'reference-one'} as $reference) {
93  
-                $this->addReferenceMapping($class, $reference, 'one');
  113
+        
  114
+        // Evaluate <attachments ..> mapping
  115
+        if (isset($xmlRoot->{"attachments"})) {
  116
+            $class->mapAttachments((string)$xmlRoot->{"attachments"}[0]['field']);
  117
+        }
  118
+        
  119
+        // Evaluate <embed-one />
  120
+        if (isset($xmlRoot->{'embed-one'})) {
  121
+            foreach ($xmlRoot->{'embed-one'} AS $embedOneElement) {
  122
+                $class->mapEmbedded(array(
  123
+                    'targetDocument'    => (string)$embedOneElement['target-document'],
  124
+                    'fieldName'         => (string)$embedOneElement['field'],
  125
+                    'jsonName'          => (isset($embedOneElement['json-name'])) ? (string)$embedOneElement['json-name'] : null,
  126
+                    'embedded'          => 'one',
  127
+                ));
94 128
             }
95 129
         }
96  
-    }
97  
-
98  
-    private function addFieldMapping(ClassMetadata $class, $mapping)
99  
-    {
100  
-        $class->mapField($mapping);
101  
-    }
102  
-
103  
-    private function addEmbedMapping(ClassMetadata $class, $embed, $type)
104  
-    {
105  
-        $attributes = $embed->attributes();
106  
-        $mapping = array(
107  
-            'type'           => $type,
108  
-            'embedded'       => true,
109  
-            'targetDocument' => isset($attributes['target-document']) ? (string) $attributes['target-document'] : null,
110  
-            'name'           => (string) $attributes['field'],
111  
-        );
112  
-        $this->addFieldMapping($class, $mapping);
113  
-    }
114  
-
115  
-    private function addReferenceMapping(ClassMetadata $class, $reference, $type)
116  
-    {
117  
-        $cascade = array_keys((array) $reference->cascade);
118  
-        if (1 === count($cascade)) {
119  
-            $cascade = current($cascade) ?: next($cascade);
  130
+        
  131
+        // Evaluate <embed-many />
  132
+        if (isset($xmlRoot->{'embed-many'})) {
  133
+            foreach ($xmlRoot->{'embed-many'} AS $embedManyElement) {
  134
+                $class->mapEmbedded(array(
  135
+                    'targetDocument'    => (string)$embedManyElement['target-document'],
  136
+                    'fieldName'         => (string)$embedManyElement['field'],
  137
+                    'jsonName'          => (isset($embedManyElement['json-name'])) ? (string)$embedManyElement['json-name'] : null,
  138
+                    'embedded'          => 'many',
  139
+                ));
  140
+            }
120 141
         }
121  
-        $attributes = $reference->attributes();
122  
-        $mapping = array(
123  
-            'cascade'        => $cascade,
124  
-            'type'           => $type,
125  
-            'reference'      => true,
126  
-            'targetDocument' => isset($attributes['target-document']) ? (string) $attributes['target-document'] : null,
127  
-            'name'           => (string) $attributes['field'],
128  
-        );
129  
-        $this->addFieldMapping($class, $mapping);
130 142
     }
131 143
 
132 144
     protected function loadMappingFile($file)
@@ -134,7 +146,7 @@ protected function loadMappingFile($file)
134 146
         $result = array();
135 147
         $xmlElement = simplexml_load_file($file);
136 148
 
137  
-        foreach (array('document', 'embedded-document', 'mapped-superclass') as $type) {
  149
+        foreach (array('document', 'embedded-document') as $type) {
138 150
             if (isset($xmlElement->$type)) {
139 151
                 foreach ($xmlElement->$type as $documentElement) {
140 152
                     $documentName = (string) $documentElement['name'];
@@ -145,4 +157,25 @@ protected function loadMappingFile($file)
145 157
 
146 158
         return $result;
147 159
     }
  160
+    
  161
+    /**
  162
+     * Gathers a list of cascade options found in the given cascade element.
  163
+     *
  164
+     * @param $cascadeElement The cascade element.
  165
+     * @return array The list of cascade options.
  166
+     */
  167
+    private function getCascadeMode($cascadeElement)
  168
+    {
  169
+        $cascade = 0;
  170
+        foreach ($cascadeElement->children() as $action) {
  171
+            // According to the JPA specifications, XML uses "cascade-persist"
  172
+            // instead of "persist". Here, both variations
  173
+            // are supported because both YAML and Annotation use "persist"
  174
+            // and we want to make sure that this driver doesn't need to know
  175
+            // anything about the supported cascading actions
  176
+            $cascadeMode = str_replace('cascade-', '', $action->getName());
  177
+            $cascade = constant('Doctrine\ODM\CouchDB\Mapping\ClassMetadata::CASCADE_' . strtoupper($cascadeMode));
  178
+        }
  179
+        return $cascade;
  180
+    }
148 181
 }
79  lib/Doctrine/ODM/CouchDB/Mapping/Driver/YamlDriver.php
@@ -45,86 +45,7 @@ class YamlDriver extends AbstractFileDriver
45 45
     public function loadMetadataForClass($className, ClassMetadata $class)
46 46
     {
47 47
         $element = $this->getElement($className);
48  
-        if ( ! $element) {
49  
-            return;
50  
-        }
51  
-        $element['type'] = isset($element['type']) ? $element['type'] : 'document';
52 48
 
53  
-        if (isset($element['db'])) {
54  
-            $class->setDB($element['db']);
55  
-        }
56  
-        if ($element['type'] == 'document') {
57  
-            if (isset($element['repositoryClass'])) {
58  
-                $class->setCustomRepositoryClass($element['repositoryClass']);
59  
-            }
60  
-        } elseif ($element['type'] === 'mappedSuperclass') {
61  
-            $class->isMappedSuperclass = true;
62  
-        } elseif ($element['type'] === 'embeddedDocument') {
63  
-            $class->isEmbeddedDocument = true;
64  
-        }
65  
-        if (isset($element['fields'])) {
66  
-            foreach ($element['fields'] as $fieldName => $mapping) {
67  
-                if (is_string($mapping)) {
68  
-                    $type = $mapping;
69  
-                    $mapping = array();
70  
-                    $mapping['type'] = $type;
71  
-                }
72  
-                if ( ! isset($mapping['fieldName'])) {
73  
-                    $mapping['fieldName'] = $fieldName;
74  
-                }
75  
-                $this->addFieldMapping($class, $mapping);
76  
-            }
77  
-        }
78  
-        if (isset($element['embedOne'])) {
79  
-            foreach ($element['embedOne'] as $fieldName => $embed) {
80  
-                $this->addMappingFromEmbed($class, $fieldName, $embed, 'one');
81  
-            }
82  
-        }
83  
-        if (isset($element['embedMany'])) {
84  
-            foreach ($element['embedMany'] as $fieldName => $embed) {
85  
-                $this->addMappingFromEmbed($class, $fieldName, $embed, 'many');
86  
-            }
87  
-        }
88  
-        if (isset($element['referenceOne'])) {
89  
-            foreach ($element['referenceOne'] as $fieldName => $reference) {
90  
-                $this->addMappingFromReference($class, $fieldName, $reference, 'one');
91  
-            }
92  
-        }
93  
-        if (isset($element['referenceMany'])) {
94  
-            foreach ($element['referenceMany'] as $fieldName => $reference) {
95  
-                $this->addMappingFromReference($class, $fieldName, $reference, 'many');
96  
-            }
97  
-        }
98  
-    }
99  
-
100  
-    private function addFieldMapping(ClassMetadata $class, $mapping)
101  
-    {
102  
-        $class->mapField($mapping);
103  
-    }
104  
-
105  
-    private function addMappingFromEmbed(ClassMetadata $class, $fieldName, $embed, $type)
106  
-    {
107  
-        $mapping = array(
108  
-//            'type'           => $type,
109  
-            'embedded'       => $type,
110  
-            'targetDocument' => isset($embed['targetDocument']) ? $embed['targetDocument'] : null,
111  
-            'fieldName'      => $fieldName,
112  
-            'strategy'       => isset($embed['strategy']) ? (string) $embed['strategy'] : 'pushPull',
113  
-        );
114  
-        $this->addFieldMapping($class, $mapping);
115  
-    }
116  
-
117  
-    private function addMappingFromReference(ClassMetadata $class, $fieldName, $reference, $type)
118  
-    {
119  
-        $mapping = array(
120  
-            'cascade'        => isset($reference['cascade']) ? $reference['cascade'] : null,
121  
-            'type'           => $type,
122  
-            'reference'      => true,
123  
-            'targetDocument' => isset($reference['targetDocument']) ? $reference['targetDocument'] : null,
124  
-            'fieldName'      => $fieldName,
125  
-            'strategy'       => isset($reference['strategy']) ? (string) $reference['strategy'] : 'pushPull',
126  
-        );
127  
-        $this->addFieldMapping($class, $mapping);
128 49
     }
129 50
 
130 51
     protected function loadMappingFile($file)
19  tests/Doctrine/Tests/ODM/CouchDB/Mapping/AbstractMappingDriverTest.php
@@ -55,6 +55,7 @@ public function testStringFieldMappings($class)
55 55
     public function testIdentifier($class)
56 56
     {
57 57
         $this->assertEquals('id', $class->identifier);
  58
+        $this->assertEquals(ClassMetadata::IDGENERATOR_UUID, $class->idGenerator);
58 59
 
59 60
         return $class;
60 61
     }
@@ -72,7 +73,6 @@ public function testManyToOneAssociationMapping($class)
72 73
             'cascade' => 0,
73 74
             'jsonName' => 'rights',
74 75
             'targetDocument' => 'Doctrine\Tests\Models\CMS\CmsUserRights',
75  
-            'value' => null,
76 76
             'sourceDocument' => 'Doctrine\Tests\Models\CMS\CmsUser',
77 77
             'isOwning' => true,
78 78
             'type' => ClassMetadata::MANY_TO_ONE,
@@ -94,7 +94,6 @@ public function testManyToManyAssociationMapping($class)
94 94
             'cascade' => 0,
95 95
             'mappedBy' => null,
96 96
             'targetDocument' => 'Doctrine\Tests\Models\CMS\CmsGroup',
97  
-            'value' => null,
98 97
             'jsonName' => 'groups',
99 98
             'sourceDocument' => 'Doctrine\Tests\Models\CMS\CmsUser',
100 99
             'isOwning' => true,
@@ -115,4 +114,20 @@ public function testAttachmentMapping($class)
115 114
 
116 115
         return $class;
117 116
     }
  117
+    
  118
+    /**
  119
+     * @depends testManyToManyAssociationMapping
  120
+     * @param ClassMetadata $class
  121
+     */
  122
+    public function testEmbeddedMapping($class)
  123
+    {
  124
+        $this->assertArrayHasKey('address', $class->fieldMappings);
  125
+        $this->assertEquals(array(
  126
+            'fieldName' => 'address',
  127
+            'jsonName' => 'address',
  128
+            'embedded' => 'one',
  129
+            'targetDocument' => '',
  130
+            'type' => 'mixed',
  131
+        ), $class->fieldMappings['address']);
  132
+    }
118 133
 }
14  tests/Doctrine/Tests/ODM/CouchDB/Mapping/XmlDriverTest.php
... ...
@@ -0,0 +1,14 @@
  1
+<?php
  2
+
  3
+namespace Doctrine\Tests\ODM\CouchDB\Mapping;
  4
+
  5
+use Doctrine\ODM\CouchDB\Mapping\ClassMetadata;
  6
+use Doctrine\ODM\CouchDB\Mapping\Driver\XmlDriver;
  7
+
  8
+class XmlDriverTest extends AbstractMappingDriverTest
  9
+{
  10
+    protected function loadDriver()
  11
+    {
  12
+        return new XmlDriver(array(__DIR__."/xml"));
  13
+    }
  14
+}
17  tests/Doctrine/Tests/ODM/CouchDB/Mapping/xml/Doctrine.Tests.Models.CMS.CmsUser.dcm.xml
... ...
@@ -0,0 +1,17 @@
  1
+<?xml version="1.0" encoding="UTF-8"?>
  2
+<doctrine-mapping>
  3
+    <document name="Doctrine\Tests\Models\CMS\CmsUser">
  4
+        <id name="id" />
  5
+        <field name="status" type="string" indexed="true" />
  6
+        <field name="username" type="string" indexed="true" />
  7
+        <field name="name" type="string" indexed="true" />
  8
+        
  9
+        <embed-one field="address" />
  10
+        
  11
+        <reference-one field="rights" target-document="CmsUserRights" />
  12
+        <reference-many field="articles" target-document="CmsArticle" mapped-by="user" />
  13
+        <reference-many field="groups" target-document="CmsGroup" />
  14
+        
  15
+        <attachments field="attachments" />
  16
+    </document>
  17
+</doctrine-mapping>

0 notes on commit 8c046b4

Please sign in to comment.
Something went wrong with that request. Please try again.