如何使我的存根行为像一个ArrayIterator,例如?我的意思是,我想遍历这个存根。这是来自实践PHP测试的练习。PHPUnit - 存根类似于构建类型
7.2
Write a EvenIterator which takes a FibonacciIterator an iterates only
on the even-indexed values (returning 0, 1, 3, 8, 21...).
7.3
Write tests for the EvenIterator class, stubbing out the
FibonacciIterator using an ArrayIterator in substitution, which is provided
by the Spl (otherwise it will never terminate!)
谢谢。
对FibonacciIterator的正常调用看起来像什么? – Fenton
它实现了一个迭代器。你可以调用$ a = new FibonacciIterator(7)。之后,您可以迭代0,1,1,2,3,5,8。谢谢。 – thom
这个任务不是说'使用ArrayIterator作为FibonacciIterator的存根'吗? – Mchl