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

Public Member Functions

 case_traverse ()
 
 case_check_behind ()
 
 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 behind iterator.

Definition at line 50 of file Lookbehind.php.

Member Function Documentation

Hoa\Iterator\Test\Unit\Lookbehind::case_check_behind ( )

Definition at line 65 of file Lookbehind.php.

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

Definition at line 124 of file Lookbehind.php.

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

Definition at line 160 of file Lookbehind.php.

161  {
162  $this
163  ->given(
164  $iterator = new LUT\Mock(),
165  $lookbehind = new LUT\Lookbehind($iterator)
166  )
167  ->when(
168  $lookbehind->rewind(),
169  $valid = $lookbehind->valid()
170  )
171  ->then
172  ->boolean($valid)
173  ->isFalse();
174  }
Hoa\Iterator\Test\Unit\Lookbehind::case_traverse ( )

Definition at line 52 of file Lookbehind.php.

53  {
54  $this
55  ->given(
56  $iterator = new LUT\Map(['a', 'b', 'c']),
57  $lookbehind = new LUT\Lookbehind($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: