Hoa central
Counter.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 Counter extends Test\Unit\Suite
51 {
52  public function case_classic()
53  {
54  $this
55  ->given($iterator = new LUT\Counter(0, 12, 3))
56  ->when($result = iterator_to_array($iterator))
57  ->then
58  ->array($result)
59  ->isEqualTo([0, 3, 6, 9]);
60  }
61 
62  public function case_offset()
63  {
64  $this
65  ->given($iterator = new LUT\Counter(6, 12, 3))
66  ->when($result = iterator_to_array($iterator))
67  ->then
68  ->array($result)
69  ->isEqualTo([6, 9]);
70  }
71 
72  public function case_too_small()
73  {
74  $this
75  ->exception(function () {
76  new LUT\Counter(0, 0, 0);
77  })
78  ->isInstanceOf('Hoa\Iterator\Exception');
79  }
80 
81  public function case_too_big()
82  {
83  $this
84  ->given($iterator = new LUT\Counter(0, 12, 13))
85  ->when($result = iterator_to_array($iterator))
86  ->then
87  ->array($result)
88  ->isEqualTo([0]);
89  }
90 }