Hoa central
Mock.php
Go to the documentation of this file.
1 <?php
2 
37 namespace Hoa\Iterator\Test\Unit;
38 
39 use Hoa\Iterator as LUT;
40 use Hoa\Test;
41 
50 class Mock extends Test\Unit\Suite
51 {
52  public function case_classic()
53  {
54  $this
55  ->given($iterator = new LUT\Mock())
56  ->when($result = iterator_to_array($iterator))
57  ->then
58  ->array($result)
59  ->isEmpty();
60  }
61 
62  public function case_recursive_mock_mock()
63  {
64  $this
65  ->when($iterator = new LUT\Recursive\Mock(new LUT\Mock()))
66  ->then
67  ->variable($iterator->getChildren())
68  ->isNull()
69  ->boolean($iterator->hasChildren())
70  ->isFalse();
71  }
72 
73  public function case_recursive()
74  {
75  $this
76  ->given(
77  $map = new LUT\Map(['a', 'b', 'c']),
78  $mock = new LUT\Recursive\Mock($map),
79  $iteratoriterator = new LUT\Recursive\Iterator($mock)
80  )
81  ->when($result = iterator_to_array($map, false))
82  ->then
83  ->array($result)
84  ->isEqualTo(['a', 'b', 'c']);
85  }
86 }