如何使我的存根行爲像一個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