@@ 181-225 (lines=45) @@ | ||
178 | $this->v3MetadataAgainstXSD($d); |
|
179 | } |
|
180 | ||
181 | public function testAddManyToManyNavProperty() |
|
182 | { |
|
183 | list($msg, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); |
|
184 | ||
185 | list($principal, $dependent) = $metadataManager->addNavigationPropertyToEntityType( |
|
186 | $CategoryType, |
|
187 | "*", |
|
188 | "Customers", |
|
189 | $CustomerType, |
|
190 | "*", |
|
191 | "Categories" |
|
192 | ); |
|
193 | $this->assertEquals($principal->getFromRole(), $dependent->getToRole()); |
|
194 | $this->assertEquals($dependent->getFromRole(), $principal->getToRole()); |
|
195 | $this->assertEquals("Customers", $principal->getName()); |
|
196 | $this->assertEquals("Categories", $dependent->getName()); |
|
197 | ||
198 | $navProps = [$principal, $dependent]; |
|
199 | $assoc = $metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getAssociation(); |
|
200 | $this->assertEquals(1, count($assoc)); |
|
201 | $assoc = $assoc[0]; |
|
202 | $this->assertTrue($assoc instanceof TAssociationType); |
|
203 | $this->assertTrue($assoc->isOK($msg), $msg); |
|
204 | ||
205 | $this->assertEquals('Data.'.$assoc->getName(), $principal->getRelationship()); |
|
206 | $ends = $assoc->getEnd(); |
|
207 | ||
208 | $this->assertEquals(2, count($ends)); |
|
209 | foreach ($navProps as $prop) { |
|
210 | $fromMatch = $ends[0]->getRole() == $prop->getToRole() |
|
211 | || $ends[1]->getRole() == $prop->getToRole(); |
|
212 | $this->assertTrue($fromMatch, "toRole must match at least one end role"); |
|
213 | if ($ends[0]->getRole() == $prop->getToRole()) { |
|
214 | $this->assertEquals($ends[1]->getRole(), $prop->getFromRole()); |
|
215 | $this->assertNotEquals($ends[0]->getRole(), $prop->getFromRole()); |
|
216 | } else { |
|
217 | $this->assertEquals($ends[0]->getRole(), $prop->getFromRole()); |
|
218 | $this->assertNotEquals($ends[1]->getRole(), $prop->getFromRole()); |
|
219 | } |
|
220 | } |
|
221 | $principalEnd = ($ends[0]->getRole() == $principal->getToRole()) ? $ends[0] : $ends[1]; |
|
222 | $this->assertEquals('*', $principalEnd->getMultiplicity()); |
|
223 | $dependentEnd = ($ends[0]->getRole() == $dependent->getToRole()) ? $ends[0] : $ends[1]; |
|
224 | $this->assertEquals('*', $dependentEnd->getMultiplicity()); |
|
225 | } |
|
226 | ||
227 | public function testAddOneToManyNavProperty() |
|
228 | { |
|
@@ 227-271 (lines=45) @@ | ||
224 | $this->assertEquals('*', $dependentEnd->getMultiplicity()); |
|
225 | } |
|
226 | ||
227 | public function testAddOneToManyNavProperty() |
|
228 | { |
|
229 | list($msg, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); |
|
230 | ||
231 | list($principal, $dependent) = $metadataManager->addNavigationPropertyToEntityType( |
|
232 | $CategoryType, |
|
233 | "*", |
|
234 | "Customers", |
|
235 | $CustomerType, |
|
236 | "1", |
|
237 | "Categories" |
|
238 | ); |
|
239 | $this->assertEquals($principal->getFromRole(), $dependent->getToRole()); |
|
240 | $this->assertEquals($dependent->getFromRole(), $principal->getToRole()); |
|
241 | $this->assertEquals("Customers", $principal->getName()); |
|
242 | $this->assertEquals("Categories", $dependent->getName()); |
|
243 | ||
244 | $navProps = [$principal, $dependent]; |
|
245 | $assoc = $metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getAssociation(); |
|
246 | $this->assertEquals(1, count($assoc)); |
|
247 | $assoc = $assoc[0]; |
|
248 | $this->assertTrue($assoc instanceof TAssociationType); |
|
249 | $this->assertTrue($assoc->isOK($msg), $msg); |
|
250 | ||
251 | $this->assertEquals('Data.'.$assoc->getName(), $principal->getRelationship()); |
|
252 | $ends = $assoc->getEnd(); |
|
253 | ||
254 | $this->assertEquals(2, count($ends)); |
|
255 | foreach ($navProps as $prop) { |
|
256 | $fromMatch = $ends[0]->getRole() == $prop->getToRole() |
|
257 | || $ends[1]->getRole() == $prop->getToRole(); |
|
258 | $this->assertTrue($fromMatch, "toRole must match at least one end role"); |
|
259 | if ($ends[0]->getRole() == $prop->getToRole()) { |
|
260 | $this->assertEquals($ends[1]->getRole(), $prop->getFromRole()); |
|
261 | $this->assertNotEquals($ends[0]->getRole(), $prop->getFromRole()); |
|
262 | } else { |
|
263 | $this->assertEquals($ends[0]->getRole(), $prop->getFromRole()); |
|
264 | $this->assertNotEquals($ends[1]->getRole(), $prop->getFromRole()); |
|
265 | } |
|
266 | } |
|
267 | $principalEnd = ($ends[0]->getRole() == $principal->getToRole()) ? $ends[0] : $ends[1]; |
|
268 | $this->assertEquals('*', $principalEnd->getMultiplicity()); |
|
269 | $dependentEnd = ($ends[0]->getRole() == $dependent->getToRole()) ? $ends[0] : $ends[1]; |
|
270 | $this->assertEquals('1', $dependentEnd->getMultiplicity()); |
|
271 | } |
|
272 | ||
273 | public function testAddManyToOneNavProperty() |
|
274 | { |
|
@@ 273-317 (lines=45) @@ | ||
270 | $this->assertEquals('1', $dependentEnd->getMultiplicity()); |
|
271 | } |
|
272 | ||
273 | public function testAddManyToOneNavProperty() |
|
274 | { |
|
275 | list($msg, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); |
|
276 | ||
277 | list($principal, $dependent) = $metadataManager->addNavigationPropertyToEntityType( |
|
278 | $CategoryType, |
|
279 | "1", |
|
280 | "Customers", |
|
281 | $CustomerType, |
|
282 | "*", |
|
283 | "Categories" |
|
284 | ); |
|
285 | $this->assertEquals($principal->getFromRole(), $dependent->getToRole()); |
|
286 | $this->assertEquals($dependent->getFromRole(), $principal->getToRole()); |
|
287 | $this->assertEquals("Customers", $principal->getName()); |
|
288 | $this->assertEquals("Categories", $dependent->getName()); |
|
289 | ||
290 | $navProps = [$principal, $dependent]; |
|
291 | $assoc = $metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getAssociation(); |
|
292 | $this->assertEquals(1, count($assoc)); |
|
293 | $assoc = $assoc[0]; |
|
294 | $this->assertTrue($assoc instanceof TAssociationType); |
|
295 | $this->assertTrue($assoc->isOK($msg), $msg); |
|
296 | ||
297 | $this->assertEquals('Data.'.$assoc->getName(), $principal->getRelationship()); |
|
298 | $ends = $assoc->getEnd(); |
|
299 | ||
300 | $this->assertEquals(2, count($ends)); |
|
301 | foreach ($navProps as $prop) { |
|
302 | $fromMatch = $ends[0]->getRole() == $prop->getToRole() |
|
303 | || $ends[1]->getRole() == $prop->getToRole(); |
|
304 | $this->assertTrue($fromMatch, "toRole must match at least one end role"); |
|
305 | if ($ends[0]->getRole() == $prop->getToRole()) { |
|
306 | $this->assertEquals($ends[1]->getRole(), $prop->getFromRole()); |
|
307 | $this->assertNotEquals($ends[0]->getRole(), $prop->getFromRole()); |
|
308 | } else { |
|
309 | $this->assertEquals($ends[0]->getRole(), $prop->getFromRole()); |
|
310 | $this->assertNotEquals($ends[1]->getRole(), $prop->getFromRole()); |
|
311 | } |
|
312 | } |
|
313 | $principalEnd = ($ends[0]->getRole() == $principal->getToRole()) ? $ends[0] : $ends[1]; |
|
314 | $this->assertEquals('1', $principalEnd->getMultiplicity()); |
|
315 | $dependentEnd = ($ends[0]->getRole() == $dependent->getToRole()) ? $ends[0] : $ends[1]; |
|
316 | $this->assertEquals('*', $dependentEnd->getMultiplicity()); |
|
317 | } |
|
318 | ||
319 | public function testAddOneToOneForwardNavProperty() |
|
320 | { |
|
@@ 319-363 (lines=45) @@ | ||
316 | $this->assertEquals('*', $dependentEnd->getMultiplicity()); |
|
317 | } |
|
318 | ||
319 | public function testAddOneToOneForwardNavProperty() |
|
320 | { |
|
321 | list($msg, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); |
|
322 | ||
323 | list($principal, $dependent) = $metadataManager->addNavigationPropertyToEntityType( |
|
324 | $CategoryType, |
|
325 | "0..1", |
|
326 | "Customers", |
|
327 | $CustomerType, |
|
328 | "1", |
|
329 | "Categories" |
|
330 | ); |
|
331 | $this->assertEquals($principal->getFromRole(), $dependent->getToRole()); |
|
332 | $this->assertEquals($dependent->getFromRole(), $principal->getToRole()); |
|
333 | $this->assertEquals("Customers", $principal->getName()); |
|
334 | $this->assertEquals("Categories", $dependent->getName()); |
|
335 | ||
336 | $navProps = [$principal, $dependent]; |
|
337 | $assoc = $metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getAssociation(); |
|
338 | $this->assertEquals(1, count($assoc)); |
|
339 | $assoc = $assoc[0]; |
|
340 | $this->assertTrue($assoc instanceof TAssociationType); |
|
341 | $this->assertTrue($assoc->isOK($msg), $msg); |
|
342 | ||
343 | $this->assertEquals('Data.'.$assoc->getName(), $principal->getRelationship()); |
|
344 | $ends = $assoc->getEnd(); |
|
345 | ||
346 | $this->assertEquals(2, count($ends)); |
|
347 | foreach ($navProps as $prop) { |
|
348 | $fromMatch = $ends[0]->getRole() == $prop->getToRole() |
|
349 | || $ends[1]->getRole() == $prop->getToRole(); |
|
350 | $this->assertTrue($fromMatch, "toRole must match at least one end role"); |
|
351 | if ($ends[0]->getRole() == $prop->getToRole()) { |
|
352 | $this->assertEquals($ends[1]->getRole(), $prop->getFromRole()); |
|
353 | $this->assertNotEquals($ends[0]->getRole(), $prop->getFromRole()); |
|
354 | } else { |
|
355 | $this->assertEquals($ends[0]->getRole(), $prop->getFromRole()); |
|
356 | $this->assertNotEquals($ends[1]->getRole(), $prop->getFromRole()); |
|
357 | } |
|
358 | } |
|
359 | $principalEnd = ($ends[0]->getRole() == $principal->getToRole()) ? $ends[0] : $ends[1]; |
|
360 | $this->assertEquals('0..1', $principalEnd->getMultiplicity()); |
|
361 | $dependentEnd = ($ends[0]->getRole() == $dependent->getToRole()) ? $ends[0] : $ends[1]; |
|
362 | $this->assertEquals('1', $dependentEnd->getMultiplicity()); |
|
363 | } |
|
364 | ||
365 | public function testAddOneToOneReverseNavProperty() |
|
366 | { |
|
@@ 365-409 (lines=45) @@ | ||
362 | $this->assertEquals('1', $dependentEnd->getMultiplicity()); |
|
363 | } |
|
364 | ||
365 | public function testAddOneToOneReverseNavProperty() |
|
366 | { |
|
367 | list($msg, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); |
|
368 | ||
369 | list($principal, $dependent) = $metadataManager->addNavigationPropertyToEntityType( |
|
370 | $CategoryType, |
|
371 | "1", |
|
372 | "Customers", |
|
373 | $CustomerType, |
|
374 | "0..1", |
|
375 | "Categories" |
|
376 | ); |
|
377 | $this->assertEquals($principal->getFromRole(), $dependent->getToRole()); |
|
378 | $this->assertEquals($dependent->getFromRole(), $principal->getToRole()); |
|
379 | $this->assertEquals("Customers", $principal->getName()); |
|
380 | $this->assertEquals("Categories", $dependent->getName()); |
|
381 | ||
382 | $navProps = [$principal, $dependent]; |
|
383 | $assoc = $metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getAssociation(); |
|
384 | $this->assertEquals(1, count($assoc)); |
|
385 | $assoc = $assoc[0]; |
|
386 | $this->assertTrue($assoc instanceof TAssociationType); |
|
387 | $this->assertTrue($assoc->isOK($msg), $msg); |
|
388 | ||
389 | $this->assertEquals('Data.'.$assoc->getName(), $principal->getRelationship()); |
|
390 | $ends = $assoc->getEnd(); |
|
391 | ||
392 | $this->assertEquals(2, count($ends)); |
|
393 | foreach ($navProps as $prop) { |
|
394 | $fromMatch = $ends[0]->getRole() == $prop->getToRole() |
|
395 | || $ends[1]->getRole() == $prop->getToRole(); |
|
396 | $this->assertTrue($fromMatch, "toRole must match at least one end role"); |
|
397 | if ($ends[0]->getRole() == $prop->getToRole()) { |
|
398 | $this->assertEquals($ends[1]->getRole(), $prop->getFromRole()); |
|
399 | $this->assertNotEquals($ends[0]->getRole(), $prop->getFromRole()); |
|
400 | } else { |
|
401 | $this->assertEquals($ends[0]->getRole(), $prop->getFromRole()); |
|
402 | $this->assertNotEquals($ends[1]->getRole(), $prop->getFromRole()); |
|
403 | } |
|
404 | } |
|
405 | $principalEnd = ($ends[0]->getRole() == $principal->getToRole()) ? $ends[0] : $ends[1]; |
|
406 | $this->assertEquals('1', $principalEnd->getMultiplicity()); |
|
407 | $dependentEnd = ($ends[0]->getRole() == $dependent->getToRole()) ? $ends[0] : $ends[1]; |
|
408 | $this->assertEquals('0..1', $dependentEnd->getMultiplicity()); |
|
409 | } |
|
410 | ||
411 | public function testMetadataSerialiseRoundTrip() |
|
412 | { |