| @@ 306-361 (lines=56) @@ | ||
| 303 | ); |
|
| 304 | } |
|
| 305 | ||
| 306 | public function testBuildListOfEntityReachedDuringTheWalk() |
|
| 307 | { |
|
| 308 | $this->samepleJson = [ |
|
| 309 | "FooBundle\\Entity\\Zzz" => [ |
|
| 310 | "relations" => [ |
|
| 311 | "items" => "AppBundle\\Entity\\Foo", |
|
| 312 | ] |
|
| 313 | ], |
|
| 314 | "FooBundle\\Entity\\Item" => [ |
|
| 315 | "relations" => [ |
|
| 316 | "items" => "AppBundle\\Entity\\Foo", |
|
| 317 | ] |
|
| 318 | ], |
|
| 319 | "AppBundle\\Entity\\Foo" => [ |
|
| 320 | "relations" => [ |
|
| 321 | "item" => "ZarroBundle\\Entity\\Item", |
|
| 322 | ] |
|
| 323 | ], |
|
| 324 | "ZarroBundle\\Entity\\Item" => [ |
|
| 325 | "relations" => [ |
|
| 326 | "family" => "AppBundle\\Entity\\Family", |
|
| 327 | ] |
|
| 328 | ], |
|
| 329 | ]; |
|
| 330 | ||
| 331 | $this->mapper = $this |
|
| 332 | ->getMockBuilder('Mado\QueryBundle\Component\Meta\DataMapper') |
|
| 333 | ->disableOriginalConstructor() |
|
| 334 | ->getMock(); |
|
| 335 | ||
| 336 | $this->mapper->expects($this->once()) |
|
| 337 | ->method('getMap') |
|
| 338 | ->will($this->returnValue( |
|
| 339 | $this->samepleJson |
|
| 340 | )); |
|
| 341 | ||
| 342 | $this->pathFinder = new JsonPathFinder( |
|
| 343 | $this->mapper |
|
| 344 | ); |
|
| 345 | ||
| 346 | $this->pathFinder->setQueryStartEntity("FooBundle\\Entity\\Item"); |
|
| 347 | ||
| 348 | $this->assertEquals( |
|
| 349 | "_embedded.items.item.family", |
|
| 350 | $this->pathFinder->getPathToEntity("AppBundle\\Entity\\Family") |
|
| 351 | ); |
|
| 352 | ||
| 353 | $this->assertEquals( |
|
| 354 | [ |
|
| 355 | "AppBundle\\Entity\\Family", |
|
| 356 | "ZarroBundle\\Entity\\Item", |
|
| 357 | "AppBundle\\Entity\\Foo", |
|
| 358 | ], |
|
| 359 | $this->pathFinder->getEntitiesPath("AppBundle\\Entity\\Family") |
|
| 360 | ); |
|
| 361 | } |
|
| 362 | ||
| 363 | public function testBuildRightPathAlsoWhenAtTheEndThereIsAFork() |
|
| 364 | { |
|
| @@ 411-465 (lines=55) @@ | ||
| 408 | ); |
|
| 409 | } |
|
| 410 | ||
| 411 | public function testBuildRightPathAlsoWithForksIntPath() |
|
| 412 | { |
|
| 413 | $this->samepleJson = [ |
|
| 414 | "FooBundle\\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\\Sbagliato" => [ |
|
| 425 | "relations" => [ |
|
| 426 | "item" => "ZarroBundle\\Entity\\Item", |
|
| 427 | ] |
|
| 428 | ], |
|
| 429 | "AppBundle\\Entity\\Foo" => [ |
|
| 430 | "relations" => [ |
|
| 431 | "item" => "ZarroBundle\\Entity\\Item", |
|
| 432 | ] |
|
| 433 | ], |
|
| 434 | "ZarroBundle\\Entity\\Item" => [ |
|
| 435 | "relations" => [ |
|
| 436 | "family" => "AppBundle\\Entity\\Family", |
|
| 437 | ] |
|
| 438 | ], |
|
| 439 | ]; |
|
| 440 | ||
| 441 | $this->mapper = $this |
|
| 442 | ->getMockBuilder('Mado\QueryBundle\Component\Meta\DataMapper') |
|
| 443 | ->disableOriginalConstructor() |
|
| 444 | ->getMock(); |
|
| 445 | ||
| 446 | $this->mapper->expects($this->once()) |
|
| 447 | ->method('getMap') |
|
| 448 | ->will($this->returnValue( |
|
| 449 | $this->samepleJson |
|
| 450 | )); |
|
| 451 | ||
| 452 | $this->pathFinder = new JsonPathFinder( |
|
| 453 | $this->mapper |
|
| 454 | ); |
|
| 455 | ||
| 456 | $this->pathFinder->setQueryStartEntity("FooBundle\\Entity\\Item"); |
|
| 457 | ||
| 458 | $this->pathFinder->removeStep("AppBundle\\Entity\\Wrong"); |
|
| 459 | $this->pathFinder->removeStep("AppBundle\\Entity\\Sbagliato"); |
|
| 460 | ||
| 461 | $this->assertEquals( |
|
| 462 | "_embedded.items.item.family", |
|
| 463 | $this->pathFinder->getPathToEntity("AppBundle\\Entity\\Family") |
|
| 464 | ); |
|
| 465 | } |
|
| 466 | ||
| 467 | public function testGenerateHasKeyFoRequest() |
|
| 468 | { |
|