Exemplo n.º 1
0
 public function testUseAReverseIteratorAndValiddateAuthors($expected)
 {
     $iterator = new BookListReverseIterator($this->bookList);
     while ($iterator->valid()) {
         $expectedBook = array_pop($expected);
         $this->assertEquals($expectedBook, $iterator->current()->getAuthorAndTitle());
         $iterator->next();
     }
 }
Exemplo n.º 2
0
$books->addBook($thirdBook);
echo "Testing the Iterator" . tagins("br");
$booksIterator = new BookListIterator($books);
while ($booksIterator->hasNextBook()) {
    $book = $booksIterator->getNextBook();
    echo "getting next book with iterator : " . tagins("br");
    echo $book->getAuthorAndTitle();
    echo tagins("br") . tagins("br");
}
$book = $booksIterator->getCurrentBook();
echo "getting current book with iterator : " . tagins("br");
echo $book->getAuthorAndTitle();
echo tagins("br") . tagins("br");
echo tagins("br");
echo "Testing the Reverse Iterator" . tagins("br");
$booksReverseIterator = new BookListReverseIterator($books);
while ($booksReverseIterator->hasNextBook()) {
    $book = $booksReverseIterator->getNextBook();
    echo "getting next book with reverse iterator : " . tagins("br");
    echo $book->getAuthorAndTitle();
    echo tagins("br") . tagins("br");
}
$book = $booksReverseIterator->getCurrentBook();
echo "getting current book with reverse iterator : " . tagins("br");
echo $book->getAuthorAndTitle();
echo tagins("br") . tagins("br");
echo tagins("br");
echo "END TESTING ITERATOR PATTERN";
echo tagins("br");
echo tagins("/body");
echo tagins("/html");