Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 11
Línea 38... Línea 38...
38
class skip_future_documents_iterator_test extends \basic_testcase {
38
class skip_future_documents_iterator_test extends \basic_testcase {
Línea 39... Línea 39...
39
 
39
 
40
    /**
40
    /**
41
     * Test normal case with all documents in the past.
41
     * Test normal case with all documents in the past.
42
     */
42
     */
43
    public function test_iterator_all_in_past() {
43
    public function test_iterator_all_in_past(): void {
44
        $past = strtotime('2017-11-01');
44
        $past = strtotime('2017-11-01');
45
        $documents = [
45
        $documents = [
46
            self::make_doc($past, 1),
46
            self::make_doc($past, 1),
47
            self::make_doc($past + 1, 2),
47
            self::make_doc($past + 1, 2),
Línea 53... Línea 53...
53
 
53
 
54
    /**
54
    /**
55
     * Confirm that the iterator does not call its parent iterator current() function too many
55
     * Confirm that the iterator does not call its parent iterator current() function too many
56
     * times.
56
     * times.
57
     */
57
     */
58
    public function test_iterator_performance() {
58
    public function test_iterator_performance(): void {
59
        $counter = new test_counting_iterator();
59
        $counter = new test_counting_iterator();
60
        $iterator = new skip_future_documents_iterator($counter);
60
        $iterator = new skip_future_documents_iterator($counter);
61
        $items = 0;
61
        $items = 0;
62
        foreach ($iterator as $value) {
62
        foreach ($iterator as $value) {
Línea 68... Línea 68...
68
    }
68
    }
Línea 69... Línea 69...
69
 
69
 
70
    /**
70
    /**
71
     * Test with no documents at all.
71
     * Test with no documents at all.
72
     */
72
     */
73
    public function test_iterator_empty() {
73
    public function test_iterator_empty(): void {
74
        $this->assertEquals('', self::do_iterator([]));
74
        $this->assertEquals('', self::do_iterator([]));
Línea 75... Línea 75...
75
    }
75
    }
76
 
76
 
77
    /**
77
    /**
78
     * Test if some documents are in the future.
78
     * Test if some documents are in the future.
79
     */
79
     */
80
    public function test_iterator_some_in_future() {
80
    public function test_iterator_some_in_future(): void {
81
        $past = strtotime('2017-11-01');
81
        $past = strtotime('2017-11-01');
82
        $future = time() + 1000;
82
        $future = time() + 1000;
83
        $documents = [
83
        $documents = [
Línea 90... Línea 90...
90
    }
90
    }
Línea 91... Línea 91...
91
 
91
 
92
    /**
92
    /**
93
     * Test if all documents are in the future.
93
     * Test if all documents are in the future.
94
     */
94
     */
95
    public function test_iterator_all_in_future() {
95
    public function test_iterator_all_in_future(): void {
96
        $future = time() + 1000;
96
        $future = time() + 1000;
97
        $documents = [
97
        $documents = [
98
            self::make_doc($future, 1),
98
            self::make_doc($future, 1),
99
            self::make_doc($future + 1, 2),
99
            self::make_doc($future + 1, 2),
Línea 103... Línea 103...
103
    }
103
    }
Línea 104... Línea 104...
104
 
104
 
105
    /**
105
    /**
106
     * Test when some documents return error.
106
     * Test when some documents return error.
107
     */
107
     */
108
    public function test_iterator_some_false() {
108
    public function test_iterator_some_false(): void {
109
        $past = strtotime('2017-11-01');
109
        $past = strtotime('2017-11-01');
110
        $documents = [
110
        $documents = [
111
            self::make_doc($past, 1),
111
            self::make_doc($past, 1),
112
            false,
112
            false,
Línea 117... Línea 117...
117
    }
117
    }
Línea 118... Línea 118...
118
 
118
 
119
    /**
119
    /**
120
     * Test when all documents return error.
120
     * Test when all documents return error.
121
     */
121
     */
122
    public function test_iterator_all_false() {
122
    public function test_iterator_all_false(): void {
123
        $documents = [
123
        $documents = [
124
            false,
124
            false,
125
            false,
125
            false,
126
            false
126
            false
Línea 130... Línea 130...
130
    }
130
    }
Línea 131... Línea 131...
131
 
131
 
132
    /**
132
    /**
133
     * Test iterator with all cases.
133
     * Test iterator with all cases.
134
     */
134
     */
135
    public function test_iterator_past_false_and_future() {
135
    public function test_iterator_past_false_and_future(): void {
136
        $past = strtotime('2017-11-01');
136
        $past = strtotime('2017-11-01');
137
        $future = time() + 1000;
137
        $future = time() + 1000;
138
        $documents = [
138
        $documents = [
139
            false,
139
            false,