@@ -87,6 +87,19 @@ public function testCollectionGetRoot()
8787 self ::assertTrue (false !== strpos ($ body , 'Nodes (3) ' ), $ body );
8888 self ::assertTrue (false !== strpos ($ body , '<a href="/dir/"> ' ));
8989 self ::assertTrue (false !== strpos ($ body , '<span class="btn disabled"> ' ));
90+
91+ $ dom = new \DOMDocument ('1.0 ' , 'utf-8 ' );
92+ $ dom ->loadXML ($ body );
93+ $ xpath = new \DOMXPath ($ dom );
94+
95+ $ sections = $ xpath ->query ('//section ' );
96+
97+ $ firstSectionContainsNodes = false ;
98+ if ($ sections ->length > 0 ) {
99+ $ firstH1 = $ xpath ->query ('.//h1[text()="Nodes (3)"] ' , $ sections ->item (0 ));
100+ $ firstSectionContainsNodes = $ firstH1 ->length > 0 ;
101+ }
102+ self ::assertTrue ($ firstSectionContainsNodes , 'First section is listing Nodes (3) ' );
90103 }
91104
92105 public function testGETPassthru ()
@@ -186,6 +199,38 @@ public function testGetAssetEscapeBasePath()
186199 self ::assertEquals (404 , $ this ->response ->getStatus (), 'Error: ' .$ this ->response ->getBodyAsString ());
187200 }
188201
202+ public function testCollectionWithManyNodesGetSubdir ()
203+ {
204+ $ dir = $ this ->server ->tree ->getNodeForPath ('dir2 ' );
205+ $ dir ->createDirectory ('subdir ' );
206+ $ maxNodes = 20 ; // directory + 20 files
207+ for ($ i = 1 ; $ i <= $ maxNodes ; $ i ++) {
208+ $ dir ->createFile ("file $ i " );
209+ }
210+
211+ $ request = new HTTP \Request ('GET ' , '/dir2 ' );
212+ $ this ->server ->httpRequest = ($ request );
213+ $ this ->server ->exec ();
214+
215+ $ body = $ this ->response ->getBodyAsString ();
216+ self ::assertTrue (false !== strpos ($ body , 'Nodes (21) ' ), $ body );
217+ self ::assertTrue (false !== strpos ($ body , '<a href="/dir2/subdir/"> ' ));
218+
219+ $ dom = new \DOMDocument ('1.0 ' , 'utf-8 ' );
220+ $ dom ->loadXML ($ body );
221+ $ xpath = new \DOMXPath ($ dom );
222+
223+ $ sections = $ xpath ->query ('//section ' );
224+
225+ $ lastSectionContainsNodes = false ;
226+ if ($ sections ->length > 1 ) {
227+ $ lastH1 = $ xpath ->query ('.//h1[text()="Nodes (21)"] ' , $ sections ->item ($ sections ->length - 1 ));
228+ $ lastSectionContainsNodes = $ lastH1 ->length > 0 ;
229+ }
230+ self ::assertTrue ($ lastSectionContainsNodes , 'Last section is listing Nodes (21) ' );
231+ }
232+
233+
189234 public function testCollectionNodesOrder ()
190235 {
191236 $ compareNodes = new \ReflectionMethod ($ this ->plugin , 'compareNodes ' );
0 commit comments