Completed
Pull Request — master (#100)
by Alex
18:05
created
tests/MetadataManagerTest.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     {
30 30
         $ds = DIRECTORY_SEPARATOR;
31 31
 
32
-        $goodxsd = dirname(__DIR__) . $ds . "xsd" . $ds . "Microsoft.Data.Entity.Design.Edmx_3.Fixed.xsd";
32
+        $goodxsd = dirname(__DIR__).$ds."xsd".$ds."Microsoft.Data.Entity.Design.Edmx_3.Fixed.xsd";
33 33
         if (!file_exists($goodxsd)) {
34 34
             return true;
35 35
         }
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $metadataManager = new MetadataManager();
44 44
 
45 45
         $eType = $metadataManager->addEntityType("Category");
46
-        $this->assertNotFalse($eType, "Etype is false not type " . $metadataManager->getLastError());
46
+        $this->assertNotFalse($eType, "Etype is false not type ".$metadataManager->getLastError());
47 47
         $metadataManager->addPropertyToEntityType($eType, "CategoryID", "Int32", null, false, true, "Identity");
48 48
         $metadataManager->addPropertyToEntityType($eType, "CategoryName", "String");
49 49
         $metadataManager->addPropertyToEntityType($eType, "Description", "String");
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         $metadataManager = new MetadataManager();
70 70
 
71 71
         $CategoryType = $metadataManager->addEntityType("Category");
72
-        $this->assertNotFalse($CategoryType, "Etype is false not type " . $metadataManager->getLastError());
72
+        $this->assertNotFalse($CategoryType, "Etype is false not type ".$metadataManager->getLastError());
73 73
         $metadataManager->addPropertyToEntityType($CategoryType, "CategoryID", "Int32", null, false, true, "Identity");
74 74
         $metadataManager->addPropertyToEntityType($CategoryType, "CategoryName", "String");
75 75
         $metadataManager->addPropertyToEntityType($CategoryType, "Description", "String");
Please login to merge, or discard this patch.
tests/TSchemaTypeTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         for ($i = 0; $i < 100; $i++) {
32 32
             $actualMax = max($type->getRand(), $actualMax);
33 33
         }
34
-        $this->assertTrue($expectedMax >= $actualMax, $actualMax . " must be less than ".$expectedMax);
34
+        $this->assertTrue($expectedMax >= $actualMax, $actualMax." must be less than ".$expectedMax);
35 35
     }
36 36
 
37 37
     public function testGetRandMinimum()
@@ -42,6 +42,6 @@  discard block
 block discarded – undo
42 42
         for ($i = 0; $i < 100; $i++) {
43 43
             $actualMin = min($type->getRand(), $actualMin);
44 44
         }
45
-        $this->assertTrue($expectedMin <= $actualMin, $actualMin . " must be less than ".$expectedMin);
45
+        $this->assertTrue($expectedMin <= $actualMin, $actualMin." must be less than ".$expectedMin);
46 46
     }
47 47
 }
Please login to merge, or discard this patch.
tests/EdmxTest.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         $edmx = new Edmx();
27 27
         $this->assertTrue($edmx->isOK($msg), $msg);
28 28
         $this->assertNull($msg);
29
-        $ymlDir = dirname(__DIR__) . $ds . "src" . $ds . "MetadataV3" . $ds . "JMSmetadata";
29
+        $ymlDir = dirname(__DIR__).$ds."src".$ds."MetadataV3".$ds."JMSmetadata";
30 30
         $serializer =
31 31
             \JMS\Serializer\SerializerBuilder::create()
32 32
                 ->addMetadataDir($ymlDir)
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     {
40 40
         $ds = DIRECTORY_SEPARATOR;
41 41
 
42
-        $goodxsd = dirname(__DIR__) . $ds . "xsd" . $ds . "Microsoft.Data.Entity.Design.Edmx_3.Fixed.xsd";
42
+        $goodxsd = dirname(__DIR__).$ds."xsd".$ds."Microsoft.Data.Entity.Design.Edmx_3.Fixed.xsd";
43 43
         if (!file_exists($goodxsd)) {
44 44
             return true;
45 45
         }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     private function checkEdmxSerialiseDeserialiseRoundTrip($ds, $edmx, $msg)
67 67
     {
68
-        $ymlDir = dirname(__DIR__) . $ds . "src" . $ds . "MetadataV3" . $ds . "JMSmetadata";
68
+        $ymlDir = dirname(__DIR__).$ds."src".$ds."MetadataV3".$ds."JMSmetadata";
69 69
         $serializer =
70 70
             \JMS\Serializer\SerializerBuilder::create()
71 71
                 ->addMetadataDir($ymlDir)
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
         $this->assertNull($msg);
113 113
 
114 114
 
115
-        $ymlDir = dirname(__DIR__) . $ds . "src" . $ds . "MetadataV3" . $ds . "JMSmetadata";
115
+        $ymlDir = dirname(__DIR__).$ds."src".$ds."MetadataV3".$ds."JMSmetadata";
116 116
         $serializer =
117 117
             \JMS\Serializer\SerializerBuilder::create()
118 118
                 ->addMetadataDir($ymlDir)
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
         $ds = DIRECTORY_SEPARATOR;
145 145
         $msg = null;
146 146
 
147
-        $docLocation = dirname(__DIR__) . $ds . "tests" . $ds . "exampleV3ServiceDocument.xml";
147
+        $docLocation = dirname(__DIR__).$ds."tests".$ds."exampleV3ServiceDocument.xml";
148 148
         $document = file_get_contents($docLocation);
149 149
         $type = 'AlgoWeb\ODataMetadata\MetadataV3\edmx\TDataServicesType';
150
-        $ymlDir = dirname(__DIR__) . $ds . "src" . $ds . "MetadataV3" . $ds . "JMSmetadata";
150
+        $ymlDir = dirname(__DIR__).$ds."src".$ds."MetadataV3".$ds."JMSmetadata";
151 151
 
152 152
         $serializer =
153 153
             \JMS\Serializer\SerializerBuilder::create()
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
         $ds = DIRECTORY_SEPARATOR;
165 165
         $msg = null;
166 166
 
167
-        $docLocation = dirname(__DIR__) . $ds . "tests" . $ds . "exampleV3ServiceMetadata.xml";
167
+        $docLocation = dirname(__DIR__).$ds."tests".$ds."exampleV3ServiceMetadata.xml";
168 168
         $document = file_get_contents($docLocation);
169 169
         $type = 'AlgoWeb\ODataMetadata\MetadataV3\edmx\Edmx';
170
-        $ymlDir = dirname(__DIR__) . $ds . "src" . $ds . "MetadataV3" . $ds . "JMSmetadata";
170
+        $ymlDir = dirname(__DIR__).$ds."src".$ds."MetadataV3".$ds."JMSmetadata";
171 171
 
172 172
         $serializer =
173 173
             \JMS\Serializer\SerializerBuilder::create()
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
         $ds = DIRECTORY_SEPARATOR;
186 186
         $msg = null;
187 187
 
188
-        $docLocation = dirname(__DIR__) . $ds . "tests" . $ds . "exampleV3ServiceMetadata.xml";
188
+        $docLocation = dirname(__DIR__).$ds."tests".$ds."exampleV3ServiceMetadata.xml";
189 189
         $document = file_get_contents($docLocation);
190 190
         $this->v3MetadataAgainstXSD($document);
191 191
         $type = 'AlgoWeb\ODataMetadata\MetadataV3\edmx\Edmx';
192
-        $ymlDir = dirname(__DIR__) . $ds . "src" . $ds . "MetadataV3" . $ds . "JMSmetadata";
192
+        $ymlDir = dirname(__DIR__).$ds."src".$ds."MetadataV3".$ds."JMSmetadata";
193 193
 
194 194
         $serializer =
195 195
             \JMS\Serializer\SerializerBuilder::create()
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
         $this->assertNull($msg);
231 231
 
232 232
 
233
-        $ymlDir = dirname(__DIR__) . $ds . "src" . $ds . "MetadataV3" . $ds . "JMSmetadata";
233
+        $ymlDir = dirname(__DIR__).$ds."src".$ds."MetadataV3".$ds."JMSmetadata";
234 234
         $serializer =
235 235
             \JMS\Serializer\SerializerBuilder::create()
236 236
                 ->addMetadataDir($ymlDir)
Please login to merge, or discard this patch.
src/MetadataManager.php 2 patches
Doc Comments   +17 added lines patch added patch discarded remove patch
@@ -48,6 +48,9 @@  discard block
 block discarded – undo
48 48
         return $this->serializer->serialize($this->getEdmx(), "xml");
49 49
     }
50 50
 
51
+    /**
52
+     * @param string $name
53
+     */
51 54
     public function addEntityType($name, $accessType = "Public", $summary = null, $longDescription = null)
52 55
     {
53 56
         $NewEntity = new TEntityTypeType();
@@ -112,6 +115,11 @@  discard block
 block discarded – undo
112 115
         }
113 116
     }
114 117
 
118
+    /**
119
+     * @param string $name
120
+     * @param string $type
121
+     * @param string $storeGeneratedPattern
122
+     */
115 123
     public function addPropertyToEntityType(
116 124
         $entityType,
117 125
         $name,
@@ -149,6 +157,11 @@  discard block
 block discarded – undo
149 157
         return $NewProperty;
150 158
     }
151 159
 
160
+    /**
161
+     * @param string $principalMultiplicity
162
+     * @param string $principalProperty
163
+     * @param string $dependentMultiplicity
164
+     */
152 165
     public function addNavigationPropertyToEntityType(
153 166
         TEntityTypeType $principalType,
154 167
         $principalMultiplicity,
@@ -325,6 +338,10 @@  discard block
 block discarded – undo
325 338
         return $association;
326 339
     }
327 340
 
341
+    /**
342
+     * @param string $principalEntitySetName
343
+     * @param string $dependentEntitySetName
344
+     */
328 345
     protected function createAssocationSetForAssocation(
329 346
         TAssociationType $association,
330 347
         $principalEntitySetName,
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         if (0 == strlen(trim($namespace))) {
66 66
             $entityTypeName = $NewEntity->getName();
67 67
         } else {
68
-            $entityTypeName = $namespace . "." . $NewEntity->getName();
68
+            $entityTypeName = $namespace.".".$NewEntity->getName();
69 69
         }
70 70
         $entitySet->setEntityType($entityTypeName);
71 71
         $entitySet->setGetterAccess($accessType);
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
         $last_letter = strtolower($singular[strlen($singular) - 1]);
105 105
         switch ($last_letter) {
106 106
             case 'y':
107
-                return substr($singular, 0, -1) . 'ies';
107
+                return substr($singular, 0, -1).'ies';
108 108
             case 's':
109
-                return $singular . 'es';
109
+                return $singular.'es';
110 110
             default:
111
-                return $singular . 's';
111
+                return $singular.'s';
112 112
         }
113 113
     }
114 114
 
@@ -169,21 +169,21 @@  discard block
 block discarded – undo
169 169
     ) {
170 170
         $principalEntitySetName = Str::plural($principalType->getName(), 2);
171 171
         $dependentEntitySetName = Str::plural($dependentType->getName(), 2);
172
-        $relationName = $principalType->getName() . "_" . $principalProperty . "_"
173
-                        . $dependentType->getName() . "_" . $dependentProperty;
172
+        $relationName = $principalType->getName()."_".$principalProperty."_"
173
+                        . $dependentType->getName()."_".$dependentProperty;
174 174
         $relationName = trim($relationName, "_");
175 175
 
176 176
         $namespace = $this->V3Edmx->getDataServiceType()->getSchema()[0]->getNamespace();
177 177
         if (0 == strlen(trim($namespace))) {
178 178
             $relationFQName = $relationName;
179 179
         } else {
180
-            $relationFQName = $namespace . "." . $relationName;
180
+            $relationFQName = $namespace.".".$relationName;
181 181
         }
182 182
 
183 183
         $principalNavigationProperty = new TNavigationPropertyType();
184 184
         $principalNavigationProperty->setName($principalProperty);
185
-        $principalNavigationProperty->setToRole(trim($dependentEntitySetName . "_" . $dependentProperty, "_"));
186
-        $principalNavigationProperty->setFromRole($principalEntitySetName . "_" . $principalProperty);
185
+        $principalNavigationProperty->setToRole(trim($dependentEntitySetName."_".$dependentProperty, "_"));
186
+        $principalNavigationProperty->setFromRole($principalEntitySetName."_".$principalProperty);
187 187
         $principalNavigationProperty->setRelationship($relationFQName);
188 188
         $principalNavigationProperty->setGetterAccess($principalGetterAccess);
189 189
         $principalNavigationProperty->setSetterAccess($principalSetterAccess);
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
         if (!empty($dependentProperty)) {
199 199
             $dependentNavigationProperty = new TNavigationPropertyType();
200 200
             $dependentNavigationProperty->setName($dependentProperty);
201
-            $dependentNavigationProperty->setToRole($principalEntitySetName . "_" . $principalProperty);
202
-            $dependentNavigationProperty->setFromRole($dependentEntitySetName . "_" . $dependentProperty);
201
+            $dependentNavigationProperty->setToRole($principalEntitySetName."_".$principalProperty);
202
+            $dependentNavigationProperty->setFromRole($dependentEntitySetName."_".$dependentProperty);
203 203
             $dependentNavigationProperty->setRelationship($relationFQName);
204 204
             $dependentNavigationProperty->setGetterAccess($dependentGetterAccess);
205 205
             $dependentNavigationProperty->setSetterAccess($dependentSetterAccess);
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
             $principalTypeFQName = $principalType->getName();
269 269
             $dependentTypeFQName = $dependentType->getName();
270 270
         } else {
271
-            $principalTypeFQName = $namespace . "." . $principalType->getName();
272
-            $dependentTypeFQName = $namespace . "." . $dependentType->getName();
271
+            $principalTypeFQName = $namespace.".".$principalType->getName();
272
+            $dependentTypeFQName = $namespace.".".$dependentType->getName();
273 273
         }
274 274
         $association = new TAssociationType();
275 275
         $relationship = $principalNavigationProperty->getRelationship();
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
         if (0 == strlen(trim($namespace))) {
338 338
             $associationSetName = $association->getName();
339 339
         } else {
340
-            $associationSetName = $namespace . "." . $association->getName();
340
+            $associationSetName = $namespace.".".$association->getName();
341 341
         }
342 342
         $as->setAssociation($associationSetName);
343 343
         $end1 = new EndAnonymousType();
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 
359 359
     private function initSerialiser()
360 360
     {
361
-        $ymlDir = __DIR__ . DIRECTORY_SEPARATOR . "MetadataV3" . DIRECTORY_SEPARATOR . "JMSmetadata";
361
+        $ymlDir = __DIR__.DIRECTORY_SEPARATOR."MetadataV3".DIRECTORY_SEPARATOR."JMSmetadata";
362 362
         $this->serializer =
363 363
             SerializerBuilder::create()
364 364
                 ->addMetadataDir($ymlDir)
Please login to merge, or discard this patch.