Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

Test iterator that skips future documents

Copyright: 2017 The Open University
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 250 lines (7 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

skip_future_documents_iterator_test:: (10 methods):
  test_iterator_all_in_past()
  test_iterator_performance()
  test_iterator_empty()
  test_iterator_some_in_future()
  test_iterator_all_in_future()
  test_iterator_some_false()
  test_iterator_all_false()
  test_iterator_past_false_and_future()
  make_doc()
  do_iterator()

test_counting_iterator:: (6 methods):
  current()
  get_count()
  next()
  key()
  valid()
  rewind()


Class: skip_future_documents_iterator_test  - X-Ref

Test iterator that skips future documents

test_iterator_all_in_past()   X-Ref
Test normal case with all documents in the past.


test_iterator_performance()   X-Ref
Confirm that the iterator does not call its parent iterator current() function too many
times.


test_iterator_empty()   X-Ref
Test with no documents at all.


test_iterator_some_in_future()   X-Ref
Test if some documents are in the future.


test_iterator_all_in_future()   X-Ref
Test if all documents are in the future.


test_iterator_some_false()   X-Ref
Test when some documents return error.


test_iterator_all_false()   X-Ref
Test when all documents return error.


test_iterator_past_false_and_future()   X-Ref
Test iterator with all cases.


make_doc($time, $index)   X-Ref
Helper function to create a search document.

param: int $time Modified time
param: int $index Item id
return: document Search document

do_iterator(array $documents)   X-Ref
Puts documents through the iterator and returns result as a string for easy testing.

param: document[] $documents Array of documents
return: string Documents converted to string

Class: test_counting_iterator  - X-Ref

Fake iterator just for counting how many times current() is called. It returns 'false' 3 times.

current()   X-Ref
Returns the current element.

return: mixed Can return any type.

get_count()   X-Ref
Counts iterator usage.

return: int Number of times current() was called

next()   X-Ref
Goes on to the next element.


key()   X-Ref
Gets the key (not supported)


valid()   X-Ref
Checks if iterato is valid (still has entries).

return: bool True if still valid

rewind()   X-Ref
Rewinds the iterator.