@@ 10-39 (lines=30) @@ | ||
7 | { |
|
8 | private $samepleJson; |
|
9 | ||
10 | public function testRecognizeFirstChildOfAnEntity() |
|
11 | { |
|
12 | $this->samepleJson = [ |
|
13 | "AppBundle\\Entity\\Bar" => [ |
|
14 | "relations" => [ |
|
15 | "fizz" => "AppBundle\\Entity\\Fizz", |
|
16 | ] |
|
17 | ], |
|
18 | ]; |
|
19 | ||
20 | $this->mapper = $this |
|
21 | ->getMockBuilder('Mado\QueryBundle\Component\Meta\DataMapper') |
|
22 | ->disableOriginalConstructor() |
|
23 | ->getMock(); |
|
24 | ||
25 | $this->mapper->expects($this->once()) |
|
26 | ->method('getMap') |
|
27 | ->will($this->returnValue( |
|
28 | $this->samepleJson |
|
29 | )); |
|
30 | ||
31 | $this->pathFinder = new JsonPathFinder( |
|
32 | $this->mapper |
|
33 | ); |
|
34 | ||
35 | $this->assertEquals( |
|
36 | "AppBundle\\Entity\\Fizz", |
|
37 | $this->pathFinder->getFirstChildOf("AppBundle\\Entity\\Bar") |
|
38 | ); |
|
39 | } |
|
40 | ||
41 | public function testCatchRootEntityOfInnerOne() |
|
42 | { |
|
@@ 41-70 (lines=30) @@ | ||
38 | ); |
|
39 | } |
|
40 | ||
41 | public function testCatchRootEntityOfInnerOne() |
|
42 | { |
|
43 | $this->samepleJson = [ |
|
44 | "AppBundle\\Entity\\Bar" => [ |
|
45 | "relations" => [ |
|
46 | "fizz" => "AppBundle\\Entity\\Fizz", |
|
47 | ] |
|
48 | ], |
|
49 | ]; |
|
50 | ||
51 | $this->mapper = $this |
|
52 | ->getMockBuilder('Mado\QueryBundle\Component\Meta\DataMapper') |
|
53 | ->disableOriginalConstructor() |
|
54 | ->getMock(); |
|
55 | ||
56 | $this->mapper->expects($this->once()) |
|
57 | ->method('getMap') |
|
58 | ->will($this->returnValue( |
|
59 | $this->samepleJson |
|
60 | )); |
|
61 | ||
62 | $this->pathFinder = new JsonPathFinder( |
|
63 | $this->mapper |
|
64 | ); |
|
65 | ||
66 | $this->assertEquals( |
|
67 | "AppBundle\\Entity\\Bar", |
|
68 | $this->pathFinder->getFirstParentOf("AppBundle\\Entity\\Fizz") |
|
69 | ); |
|
70 | } |
|
71 | ||
72 | public function testCatchRelationNameToInnerEntity() |
|
73 | { |
|
@@ 72-101 (lines=30) @@ | ||
69 | ); |
|
70 | } |
|
71 | ||
72 | public function testCatchRelationNameToInnerEntity() |
|
73 | { |
|
74 | $this->samepleJson = [ |
|
75 | "AppBundle\\Entity\\Bar" => [ |
|
76 | "relations" => [ |
|
77 | "fizz" => "AppBundle\\Entity\\Fizz", |
|
78 | ] |
|
79 | ], |
|
80 | ]; |
|
81 | ||
82 | $this->mapper = $this |
|
83 | ->getMockBuilder('Mado\QueryBundle\Component\Meta\DataMapper') |
|
84 | ->disableOriginalConstructor() |
|
85 | ->getMock(); |
|
86 | ||
87 | $this->mapper->expects($this->once()) |
|
88 | ->method('getMap') |
|
89 | ->will($this->returnValue( |
|
90 | $this->samepleJson |
|
91 | )); |
|
92 | ||
93 | $this->pathFinder = new JsonPathFinder( |
|
94 | $this->mapper |
|
95 | ); |
|
96 | ||
97 | $this->assertEquals( |
|
98 | "fizz", |
|
99 | $this->pathFinder->getSourceRelation("AppBundle\\Entity\\Fizz") |
|
100 | ); |
|
101 | } |
|
102 | ||
103 | public function testLookForPathFromStartEntityToDestination() |
|
104 | { |
|
@@ 578-606 (lines=29) @@ | ||
575 | /** |
|
576 | * @expectedException \Mado\QueryBundle\Component\Meta\Exceptions\NestingException |
|
577 | */ |
|
578 | public function testCatchNesting() |
|
579 | { |
|
580 | $this->samepleJson = [ |
|
581 | "AppBundle\\Entity\\Fizz" => [ |
|
582 | "relations" => [ |
|
583 | "fizz" => "AppBundle\\Entity\\Fizz", |
|
584 | ] |
|
585 | ], |
|
586 | ]; |
|
587 | ||
588 | $this->mapper = $this |
|
589 | ->getMockBuilder('Mado\QueryBundle\Component\Meta\DataMapper') |
|
590 | ->disableOriginalConstructor() |
|
591 | ->getMock(); |
|
592 | ||
593 | $this->mapper->expects($this->once()) |
|
594 | ->method('getMap') |
|
595 | ->will($this->returnValue( |
|
596 | $this->samepleJson |
|
597 | )); |
|
598 | ||
599 | $this->pathFinder = new JsonPathFinder( |
|
600 | $this->mapper |
|
601 | ); |
|
602 | ||
603 | $this->pathFinder->setEntity("AppBundle\\Entity\\Root"); |
|
604 | $this->pathFinder->getPathTo("AppBundle\\Entity\\Fizz"); |
|
605 | } |
|
606 | ||
607 | public function testReloadMapWheneverPathIsRequestedTwice() |
|
608 | { |
|
609 | $this->samepleJson = [ |