@@ -56,6 +56,10 @@ public function testParseIncludes()
56
56
$ manager ->parseIncludes (['foo ' , 'foo ' , 'bar ' ]);
57
57
$ this ->assertSame (['foo ' , 'bar ' ], $ manager ->getRequestedIncludes ());
58
58
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
+
59
63
// Do requests for `baz.bart` also request `baz`?
60
64
$ manager ->parseIncludes (['foo.bar ' ]);
61
65
$ this ->assertSame (['foo ' , 'foo.bar ' ], $ manager ->getRequestedIncludes ());
@@ -74,6 +78,17 @@ public function testParseIncludes()
74
78
$ this ->assertSame (['' ], $ params ['anotherparam ' ]);
75
79
76
80
$ 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 ());
77
92
}
78
93
79
94
public function testParseExcludeSelfie ()
@@ -151,6 +166,24 @@ public function testRecursionLimiting()
151
166
$ manager ->getRequestedIncludes ()
152
167
);
153
168
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
+
154
187
// Try setting to 3 and see what happens
155
188
$ manager ->setRecursionLimit (3 );
156
189
$ manager ->parseIncludes ('a.b.c.NEVER ' );
@@ -163,6 +196,17 @@ public function testRecursionLimiting()
163
196
],
164
197
$ manager ->getRequestedIncludes ()
165
198
);
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
+ );
166
210
}
167
211
168
212
public function testCreateDataWithCallback ()
0 commit comments