Skip to content

Instantly share code, notes, and snippets.

View jamesdb's full-sized avatar

James Baxter jamesdb

View GitHub Profile
@jamesdb
jamesdb / IteratorMock.php
Created October 16, 2015 09:18
Mock an Iterator
<?php
function mockIteratorItems(\Iterator $iterator, array $items, $includeCallsToKey = false)
{
$iterator->expects($this->at(0))->method('rewind');
$counter = 1;
foreach ($items as $k => $v) {
$iterator->expects($this->at($counter++))->method('valid')->will($this->returnValue(true));