This repository was archived by the owner on Jan 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,9 @@ class RecursivePagination {
3333 */
3434 public function __construct (Grabber $ grabber , $ xpath = null ) {
3535 $ this ->grabber = $ grabber ;
36- $ this ->addXpath ($ xpath );
36+ if (isset ($ xpath )) {
37+ $ this ->addXpath ($ xpath );
38+ }
3739 }
3840
3941
Original file line number Diff line number Diff line change @@ -52,6 +52,25 @@ public function testOneLink() {
5252 }
5353
5454
55+ /**
56+ * Asserts that $allLinks array has 2 elements. Checking only first page, without pagination Xpath
57+ *
58+ */
59+ public function testOneLinkWithEmptyPaginationXpath () {
60+ $ grabber = new TestGrabber ();
61+
62+ $ paginator = new RecursivePagination ($ grabber );
63+ $ paginator ->addToQueue ('osmosis/page1.html ' );
64+
65+ $ allLinks = [];
66+ while ($ page = $ paginator ->getNextPage ()) {
67+ $ adsList = $ page ->attribute ("//h2/a/@href " )->getItems ();
68+ $ allLinks = array_values (array_unique (array_merge ($ allLinks , $ adsList )));
69+ }
70+ $ this ->assertTrue (count ($ allLinks ) == 2 );
71+ }
72+
73+
5574 /**
5675 * Asserts that $allLinks array has 10 elements.
5776 *
You can’t perform that action at this time.
0 commit comments