Skip to content

Commit 7f411a1

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 04877d6 + e41cb80 commit 7f411a1

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/Runtime/ClientObjectCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@ public function getIterator(): Traversable
369369
}
370370

371371
if($this->pagedMode){
372-
$nextItems = $this->getNext()->executeQuery();
373372
if($this->hasNext()){
373+
$nextItems = $this->getNext()->executeQuery();
374374
foreach ($nextItems as $item){
375375
yield $item;
376376
}

tests/sharepoint/ListItemTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@ public function testItemsCount()
3838
$this->assertEquals($itemsCount, $items->getCount());
3939
}
4040

41+
public function testIterator()
42+
{
43+
// Test that list items can be iterated over without crashing
44+
// First, test a simple get with no paging
45+
foreach (self::$targetList->getItems()->get()->executeQuery() as $item) {
46+
$this->assertNotEmpty($item);
47+
}
48+
// Now test with explicit paging
49+
foreach (self::$targetList->getItems()->get()->paged(1)->executeQuery() as $item) {
50+
$this->assertNotEmpty($item);
51+
}
52+
// Now test with implicit paging via getAll()
53+
foreach (self::$targetList->getItems()->getAll()->executeQuery() as $item) {
54+
$this->assertNotEmpty($item);
55+
}
56+
}
57+
4158

4259
public function testCreateFolderInList(){
4360
//ensure Folder creation is enabled for a List

0 commit comments

Comments
 (0)