| @@ 363-409 (lines=47) @@ | ||
| 360 | ); |
|
| 361 | } |
|
| 362 | ||
| 363 | public function testFoo() |
|
| 364 | { |
|
| 365 | $this->samepleJson = [ |
|
| 366 | "GammaBundle\\Entity\\Zzz" => [ |
|
| 367 | "relations" => [ |
|
| 368 | "items" => "AppBundle\\Entity\\Foo", |
|
| 369 | ] |
|
| 370 | ], |
|
| 371 | "GammaBundle\\Entity\\Item" => [ |
|
| 372 | "relations" => [ |
|
| 373 | "items" => "AppBundle\\Entity\\Foo", |
|
| 374 | ] |
|
| 375 | ], |
|
| 376 | "AppBundle\\Entity\\Foo" => [ |
|
| 377 | "relations" => [ |
|
| 378 | "item" => "ZarroBundle\\Entity\\Item", |
|
| 379 | ] |
|
| 380 | ], |
|
| 381 | "ZarroBundle\\Entity\\Item" => [ |
|
| 382 | "relations" => [ |
|
| 383 | "family" => "AppBundle\\Entity\\Family", |
|
| 384 | ] |
|
| 385 | ], |
|
| 386 | ]; |
|
| 387 | ||
| 388 | $this->mapper = $this |
|
| 389 | ->getMockBuilder('Mado\QueryBundle\Component\Meta\RelationDatamapper') |
|
| 390 | ->disableOriginalConstructor() |
|
| 391 | ->getMock(); |
|
| 392 | ||
| 393 | $this->mapper->expects($this->once()) |
|
| 394 | ->method('getMap') |
|
| 395 | ->will($this->returnValue( |
|
| 396 | $this->samepleJson |
|
| 397 | )); |
|
| 398 | ||
| 399 | $this->pathFinder = new JsonPathFinder( |
|
| 400 | $this->mapper |
|
| 401 | ); |
|
| 402 | ||
| 403 | $this->pathFinder->setQueryStartEntity("GammaBundle\\Entity\\Item"); |
|
| 404 | ||
| 405 | $this->assertEquals( |
|
| 406 | "_embedded.items.item.family", |
|
| 407 | $this->pathFinder->getPathToEntity("AppBundle\\Entity\\Family") |
|
| 408 | ); |
|
| 409 | } |
|
| 410 | ||
| 411 | public function testBuildRightPathAlsoWithMoreDifferentParentsIntPath() |
|
| 412 | { |
|
| @@ 411-462 (lines=52) @@ | ||
| 408 | ); |
|
| 409 | } |
|
| 410 | ||
| 411 | public function testBuildRightPathAlsoWithMoreDifferentParentsIntPath() |
|
| 412 | { |
|
| 413 | $this->samepleJson = [ |
|
| 414 | "GammaBundle\\Entity\\Item" => [ |
|
| 415 | "relations" => [ |
|
| 416 | "items" => "AppBundle\\Entity\\Foo", |
|
| 417 | ] |
|
| 418 | ], |
|
| 419 | "AppBundle\\Entity\\Wrong" => [ |
|
| 420 | "relations" => [ |
|
| 421 | "item" => "ZarroBundle\\Entity\\Item", |
|
| 422 | ] |
|
| 423 | ], |
|
| 424 | "AppBundle\\Entity\\Foo" => [ |
|
| 425 | "relations" => [ |
|
| 426 | "item" => "ZarroBundle\\Entity\\Item", |
|
| 427 | ] |
|
| 428 | ], |
|
| 429 | "ZarroBundle\\Entity\\Item" => [ |
|
| 430 | "relations" => [ |
|
| 431 | "family" => "AppBundle\\Entity\\Family", |
|
| 432 | ] |
|
| 433 | ], |
|
| 434 | ]; |
|
| 435 | ||
| 436 | $this->mapper = $this |
|
| 437 | ->getMockBuilder('Mado\QueryBundle\Component\Meta\RelationDatamapper') |
|
| 438 | ->disableOriginalConstructor() |
|
| 439 | ->getMock(); |
|
| 440 | ||
| 441 | $this->mapper->expects($this->once()) |
|
| 442 | ->method('getMap') |
|
| 443 | ->will($this->returnValue( |
|
| 444 | $this->samepleJson |
|
| 445 | )); |
|
| 446 | ||
| 447 | $this->pathFinder = new JsonPathFinder( |
|
| 448 | $this->mapper |
|
| 449 | ); |
|
| 450 | ||
| 451 | $this->pathFinder->setQueryStartEntity("GammaBundle\\Entity\\Item"); |
|
| 452 | ||
| 453 | $this->pathFinder->skipStep( |
|
| 454 | "AppBundle\\Entity\\Wrong", |
|
| 455 | "ZarroBundle\\Entity\\Item" |
|
| 456 | ); |
|
| 457 | ||
| 458 | $this->assertEquals( |
|
| 459 | "_embedded.items.item.family", |
|
| 460 | $this->pathFinder->getPathToEntity("AppBundle\\Entity\\Family") |
|
| 461 | ); |
|
| 462 | } |
|
| 463 | } |
|
| 464 | ||