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

Public Member Functions

 case_classic ()
 
 case_all_callback_parameters ()
 
 case_remove_all ()
 
 case_remove_none ()
 
 case_recursive ()
 
 case_recursive_remove_all ()
 
 case_recursive_remove_none ()
 
- Public Member Functions inherited from Hoa\Test\Unit\Suite
 __construct ()
 
 getTestedClassName ()
 
 getTestedClassNamespace ()
 
 beforeTestMethod ($methodName)
 

Protected Member Functions

 getDummyIterator ()
 
 getDummyRecursiveIterator ()
 

Detailed Description

Class .

Test suite of the callback filter iterator.

Definition at line 50 of file CallbackFilter.php.

Member Function Documentation

Hoa\Iterator\Test\Unit\CallbackFilter::case_all_callback_parameters ( )

Definition at line 74 of file CallbackFilter.php.

75  {
76  $self = $this;
77 
78  $this
79  ->given(
80  $foobar = $this->getDummyIterator(),
81  $keys = [],
82  $values = [],
83  $filter = new LUT\CallbackFilter(
84  $foobar,
85  function ($value, $key, $iterator) use (
86  $self,
87  $foobar,
88  &$keys,
89  &$values
90  ) {
91  $self
92  ->object($iterator)
93  ->isIdenticalTo($foobar);
94 
95  $keys[] = $key;
96  $values[] = $value;
97 
98  return false === in_array($value, ['a', 'e', 'i', 'o', 'u']);
99  }
100  )
101  )
102  ->when($result = iterator_to_array($filter))
103  ->then
104  ->array($result)
105  ->isEqualTo([
106  0 => 'f',
107  3 => 'b',
108  5 => 'r'
109  ])
110  ->array(array_combine($keys, $values))
111  ->isEqualTo(iterator_to_array($foobar));
112  }

Here is the call graph for this function:

Hoa\Iterator\Test\Unit\CallbackFilter::case_classic ( )

Definition at line 52 of file CallbackFilter.php.

53  {
54  $this
55  ->given(
56  $foobar = $this->getDummyIterator(),
57  $filter = new LUT\CallbackFilter(
58  $foobar,
59  function ($value) {
60  return false === in_array($value, ['a', 'e', 'i', 'o', 'u']);
61  }
62  )
63  )
64  ->when($result = iterator_to_array($filter))
65  ->then
66  ->array($result)
67  ->isEqualTo([
68  0 => 'f',
69  3 => 'b',
70  5 => 'r'
71  ]);
72  }

Here is the call graph for this function:

Hoa\Iterator\Test\Unit\CallbackFilter::case_recursive ( )

Definition at line 153 of file CallbackFilter.php.

154  {
155  $this
156  ->given(
157  $foobar = $this->getDummyRecursiveIterator(),
158  $filter = new LUT\Recursive\CallbackFilter(
159  $foobar,
160  function ($value) {
161  return false === in_array($value, ['a', 'e', 'i', 'o', 'u']);
162  }
163  ),
164  $iterator = new LUT\Recursive\Iterator($filter)
165  )
166  ->when($result = iterator_to_array($iterator, false))
167  ->then
168  ->array($result)
169  ->isEqualTo([
170  0 => 'f',
171  1 => 'b',
172  2 => 'r'
173  ]);
174  }

Here is the call graph for this function:

Hoa\Iterator\Test\Unit\CallbackFilter::case_recursive_remove_all ( )

Definition at line 176 of file CallbackFilter.php.

177  {
178  $this
179  ->given(
180  $foobar = $this->getDummyRecursiveIterator(),
181  $filter = new LUT\Recursive\CallbackFilter(
182  $foobar,
183  function () {
184  return false;
185  }
186  ),
187  $iterator = new LUT\Recursive\Iterator($filter)
188  )
189  ->when($result = iterator_to_array($iterator))
190  ->then
191  ->array($result)
192  ->isEmpty();
193  }

Here is the call graph for this function:

Hoa\Iterator\Test\Unit\CallbackFilter::case_recursive_remove_none ( )

Definition at line 195 of file CallbackFilter.php.

196  {
197  $this
198  ->given(
199  $foobar = $this->getDummyRecursiveIterator(),
200  $filter = new LUT\Recursive\CallbackFilter(
201  $foobar,
202  function () {
203  return true;
204  }
205  ),
206  $foobarIterator = new LUT\Recursive\Iterator($foobar),
207  $filterIterator = new LUT\Recursive\Iterator($filter)
208  )
209  ->when(
210  $foobarResult = iterator_to_array($foobarIterator),
211  $filterResult = iterator_to_array($filterIterator)
212  )
213  ->then
214  ->array($foobarResult)
215  ->isEqualTo($filterResult);
216  }

Here is the call graph for this function:

Hoa\Iterator\Test\Unit\CallbackFilter::case_remove_all ( )

Definition at line 114 of file CallbackFilter.php.

115  {
116  $this
117  ->given(
118  $foobar = $this->getDummyIterator(),
119  $filter = new LUT\CallbackFilter(
120  $foobar,
121  function () {
122  return false;
123  }
124  )
125  )
126  ->when($result = iterator_to_array($filter))
127  ->then
128  ->array($result)
129  ->isEmpty();
130  }

Here is the call graph for this function:

Hoa\Iterator\Test\Unit\CallbackFilter::case_remove_none ( )

Definition at line 132 of file CallbackFilter.php.

133  {
134  $this
135  ->given(
136  $foobar = $this->getDummyIterator(),
137  $filter = new LUT\CallbackFilter(
138  $foobar,
139  function () {
140  return true;
141  }
142  )
143  )
144  ->when(
145  $foobarResult = iterator_to_array($foobar),
146  $filterResult = iterator_to_array($filter)
147  )
148  ->then
149  ->array($foobarResult)
150  ->isEqualTo($filterResult);
151  }

Here is the call graph for this function:

Hoa\Iterator\Test\Unit\CallbackFilter::getDummyIterator ( )
protected

Definition at line 218 of file CallbackFilter.php.

219  {
220  return new LUT\Map(['f', 'o', 'o', 'b', 'a', 'r']);
221  }

Here is the caller graph for this function:

Hoa\Iterator\Test\Unit\CallbackFilter::getDummyRecursiveIterator ( )
protected

Definition at line 223 of file CallbackFilter.php.

224  {
225  return new LUT\Recursive\Map([['f', 'o', 'o'], ['b', 'a', 'r']]);
226  }

Here is the caller graph for this function:


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