Hoa central
Public Member Functions | List of all members
Hoa\Iterator\Test\Unit\Lookahead Class Reference
Inheritance diagram for Hoa\Iterator\Test\Unit\Lookahead:

Public Member Functions

 case_traverse ()
 
 case_check_ahead ()
 
 case_double_rewind ()
 
 case_empty ()
 
- Public Member Functions inherited from Hoa\Test\Unit\Suite
 __construct ()
 
 getTestedClassName ()
 
 getTestedClassNamespace ()
 
 beforeTestMethod ($methodName)
 

Detailed Description

Class .

Test suite of the look ahead iterator.

Definition at line 50 of file Lookahead.php.

Member Function Documentation

Hoa\Iterator\Test\Unit\Lookahead::case_check_ahead ( )

Definition at line 65 of file Lookahead.php.

66  {
67  $this
68  ->given(
69  $iterator = new LUT\Map(['a', 'b', 'c']),
70  $lookahead = new LUT\Lookahead($iterator)
71  )
72  ->when(
73  $lookahead->rewind(),
74  $key = $lookahead->key(),
75  $current = $lookahead->current(),
76  $hasNext = $lookahead->hasNext(),
77  $next = $lookahead->getNext()
78  )
79  ->then
80  ->integer($key)
81  ->isEqualTo(0)
82  ->string($current)
83  ->isEqualTo('a')
84  ->boolean($hasNext)
85  ->isTrue()
86  ->string($next)
87  ->isEqualTo('b')
88 
89  ->when(
90  $lookahead->next(),
91  $key = $lookahead->key(),
92  $current = $lookahead->current(),
93  $hasNext = $lookahead->hasNext(),
94  $next = $lookahead->getNext()
95  )
96  ->then
97  ->integer($key)
98  ->isEqualTo(1)
99  ->string($current)
100  ->isEqualTo('b')
101  ->boolean($hasNext)
102  ->isTrue()
103  ->string($next)
104  ->isEqualTo('c')
105 
106  ->when(
107  $lookahead->next(),
108  $key = $lookahead->key(),
109  $current = $lookahead->current(),
110  $hasNext = $lookahead->hasNext(),
111  $next = $lookahead->getNext()
112  )
113  ->then
114  ->integer($key)
115  ->isEqualTo(2)
116  ->string($current)
117  ->isEqualTo('c')
118  ->boolean($hasNext)
119  ->isFalse()
120  ->variable($next)
121  ->isNull();
122  }
Hoa\Iterator\Test\Unit\Lookahead::case_double_rewind ( )

Definition at line 124 of file Lookahead.php.

125  {
126  $this
127  ->given(
128  $iterator = new LUT\Map(['a', 'b', 'c']),
129  $lookahead = new LUT\Lookahead($iterator)
130  )
131  ->when(
132  $lookahead->rewind(),
133  $key = $lookahead->key(),
134  $current = $lookahead->current(),
135  $hasNext = $lookahead->hasNext(),
136  $next = $lookahead->getNext()
137  )
138  ->then
139  ->integer($key)
140  ->isEqualTo(0)
141  ->string($current)
142  ->isEqualTo('a')
143  ->boolean($hasNext)
144  ->isTrue()
145  ->string($next)
146  ->isEqualTo('b')
147 
148  ->when(
149  $lookahead->rewind(),
150  $key = $lookahead->key(),
151  $current = $lookahead->current(),
152  $hasNext = $lookahead->hasNext(),
153  $next = $lookahead->getNext()
154  )
155  ->then
156  ->integer($key)
157  ->isEqualTo(0)
158  ->string($current)
159  ->isEqualTo('a')
160  ->boolean($hasNext)
161  ->isTrue()
162  ->string($next)
163  ->isEqualTo('b');
164  }
Hoa\Iterator\Test\Unit\Lookahead::case_empty ( )

Definition at line 166 of file Lookahead.php.

167  {
168  $this
169  ->given(
170  $iterator = new LUT\Mock(),
171  $lookahead = new LUT\Lookahead($iterator)
172  )
173  ->when(
174  $lookahead->rewind(),
175  $valid = $lookahead->valid()
176  )
177  ->then
178  ->boolean($valid)
179  ->isFalse();
180  }
Hoa\Iterator\Test\Unit\Lookahead::case_traverse ( )

Definition at line 52 of file Lookahead.php.

53  {
54  $this
55  ->given(
56  $iterator = new LUT\Map(['a', 'b', 'c']),
57  $lookahead = new LUT\Lookahead($iterator)
58  )
59  ->when($result = iterator_to_array($iterator))
60  ->then
61  ->array($result)
62  ->isEqualTo(['a', 'b', 'c']);
63  }

The documentation for this class was generated from the following file: