Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

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

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_testcase:: (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_testcase  - 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.