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

Public Member Functions

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

Static Private Attributes

static $_dummyArray = ['f', 'o', 'o', 'b', 'a', 'r']
 

Detailed Description

Class .

Test suite of the map iterator.

Definition at line 50 of file Map.php.

Member Function Documentation

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

Definition at line 56 of file Map.php.

57  {
58  $this
59  ->given($iterator = new LUT\Map(self::$_dummyArray))
60  ->when($result = iterator_to_array($iterator))
61  ->then
62  ->array($result)
63  ->isEqualTo(self::$_dummyArray);
64  }
Hoa\Iterator\Test\Unit\Map::case_empty ( )

Definition at line 66 of file Map.php.

67  {
68  $this
69  ->given($iterator = new LUT\Map())
70  ->when($result = iterator_to_array($iterator))
71  ->then
72  ->array($result)
73  ->isEmpty();
74  }
Hoa\Iterator\Test\Unit\Map::case_recursive ( )

Definition at line 76 of file Map.php.

77  {
78  $this
79  ->given(
80  $array = [
81  'a' => ['b', 'c', 'd'],
82  'e' => ['f', 'g', 'i'],
83  'k'
84  ],
85  $iterator = new LUT\Recursive\Map($array)
86  )
87  ->when(function () use ($iterator) {
88  foreach ($iterator as $key => $value) {
89  if ('a' === $key) {
90  $this
91  ->boolean($iterator->hasChildren())
92  ->isTrue()
93  ->object($children = $iterator->getChildren())
94  ->isInstanceOf('Hoa\Iterator\Recursive\Map')
95  ->array(iterator_to_array($children))
96  ->isEqualTo(['b', 'c', 'd']);
97  } elseif ('e' === $key) {
98  $this
99  ->boolean($iterator->hasChildren())
100  ->isTrue()
101  ->object($children = $iterator->getChildren())
102  ->isInstanceOf('Hoa\Iterator\Recursive\Map')
103  ->array(iterator_to_array($children))
104  ->isEqualTo(['f', 'g', 'i']);
105  } elseif ('k' === $value) {
106  $this
107  ->boolean($iterator->hasChildren())
108  ->isFalse();
109  }
110  }
111  });
112  }

Member Data Documentation

Hoa\Iterator\Test\Unit\Map::$_dummyArray = ['f', 'o', 'o', 'b', 'a', 'r']
staticprivate

Definition at line 52 of file Map.php.


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