@@ -56,6 +56,10 @@ public function testParseIncludes()
5656 $ manager ->parseIncludes (['foo ' , 'foo ' , 'bar ' ]);
5757 $ this ->assertSame (['foo ' , 'bar ' ], $ manager ->getRequestedIncludes ());
5858
59+ $ manager ->parseIncludes (['foo.bar ' , 'foo:limit(10|1).bar ' ]);
60+ $ this ->assertSame (['foo ' , 'foo.bar ' ], $ manager ->getRequestedIncludes ());
61+ $ this ->assertSame (['10 ' , '1 ' ], $ manager ->getIncludeParams ('foo ' )->get ('limit ' ));
62+
5963 // Do requests for `baz.bart` also request `baz`?
6064 $ manager ->parseIncludes (['foo.bar ' ]);
6165 $ this ->assertSame (['foo ' , 'foo.bar ' ], $ manager ->getRequestedIncludes ());
@@ -74,6 +78,17 @@ public function testParseIncludes()
7478 $ this ->assertSame (['' ], $ params ['anotherparam ' ]);
7579
7680 $ this ->assertNull ($ params ['totallymadeup ' ]);
81+
82+ // Relation with params and sub relation
83+ $ manager ->parseIncludes ('foo:limit(5|1):order(name).bar,baz ' );
84+
85+ $ params = $ manager ->getIncludeParams ('foo ' );
86+
87+ $ this ->assertInstanceOf ('League\Fractal\ParamBag ' , $ params );
88+
89+ $ this ->assertSame (['5 ' , '1 ' ], $ params ['limit ' ]);
90+ $ this ->assertSame (['name ' ], $ params ['order ' ]);
91+ $ this ->assertSame (['foo ' , 'foo.bar ' , 'baz ' ], $ manager ->getRequestedIncludes ());
7792 }
7893
7994 public function testParseExcludeSelfie ()
@@ -151,6 +166,24 @@ public function testRecursionLimiting()
151166 $ manager ->getRequestedIncludes ()
152167 );
153168
169+ $ manager ->parseIncludes ('a:limit(5|1).b.c.d.e.f.g.h.i.j.NEVER ' );
170+
171+ $ this ->assertSame (
172+ [
173+ 'a ' ,
174+ 'a.b ' ,
175+ 'a.b.c ' ,
176+ 'a.b.c.d ' ,
177+ 'a.b.c.d.e ' ,
178+ 'a.b.c.d.e.f ' ,
179+ 'a.b.c.d.e.f.g ' ,
180+ 'a.b.c.d.e.f.g.h ' ,
181+ 'a.b.c.d.e.f.g.h.i ' ,
182+ 'a.b.c.d.e.f.g.h.i.j ' ,
183+ ],
184+ $ manager ->getRequestedIncludes ()
185+ );
186+
154187 // Try setting to 3 and see what happens
155188 $ manager ->setRecursionLimit (3 );
156189 $ manager ->parseIncludes ('a.b.c.NEVER ' );
@@ -163,6 +196,17 @@ public function testRecursionLimiting()
163196 ],
164197 $ manager ->getRequestedIncludes ()
165198 );
199+
200+ $ manager ->parseIncludes ('a:limit(5|1).b.c.NEVER ' );
201+
202+ $ this ->assertSame (
203+ [
204+ 'a ' ,
205+ 'a.b ' ,
206+ 'a.b.c ' ,
207+ ],
208+ $ manager ->getRequestedIncludes ()
209+ );
166210 }
167211
168212 public function testCreateDataWithCallback ()
0 commit comments