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

Public Member Functions

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

Detailed Description

Class .

Test suite of the directory iterator.

Definition at line 50 of file Directory.php.

Member Function Documentation

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

Definition at line 52 of file Directory.php.

53  {
54  $this
55  ->given(
56  $root = resolve('hoa://Test/Vfs/Root?type=directory'),
57  resolve('hoa://Test/Vfs/Root/A'),
58  resolve('hoa://Test/Vfs/Root/Aa'),
59  resolve('hoa://Test/Vfs/Root/Aaa'),
60  $iterator = new LUT\Directory($root),
61  $result = []
62  )
63  ->when(function () use ($iterator, &$result) {
64  foreach ($iterator as $key => $file) {
65  $result[$key] = $file->getFilename();
66 
67  $this
68  ->object($file)
69  ->isInstanceOf('Hoa\Iterator\Directory');
70  }
71  })
72  ->then
73  ->array($result)
74  ->isEqualTo([
75  0 => 'A',
76  1 => 'Aa',
77  2 => 'Aaa'
78  ]);
79  }
Hoa\Iterator\Test\Unit\Directory::case_recursive ( )

Definition at line 122 of file Directory.php.

123  {
124  $this
125  ->given(
126  $root = resolve('hoa://Test/Vfs/Root?type=directory'),
127  resolve('hoa://Test/Vfs/Root/A'),
128  resolve('hoa://Test/Vfs/Root/Aa'),
129  resolve('hoa://Test/Vfs/Root/Aaa'),
130  resolve('hoa://Test/Vfs/Root/Foo?type=directory'),
131  resolve('hoa://Test/Vfs/Root/Foo/Bar?type=directory'),
132  resolve('hoa://Test/Vfs/Root/Foo/Bar/B'),
133  resolve('hoa://Test/Vfs/Root/Foo/Bar/Bb'),
134  resolve('hoa://Test/Vfs/Root/Foo/Bar/Bbb'),
135  resolve('hoa://Test/Vfs/Root/Foo/C'),
136  resolve('hoa://Test/Vfs/Root/Foo/Cc'),
137  resolve('hoa://Test/Vfs/Root/Foo/Ccc'),
138  $directory = new LUT\Recursive\Directory($root),
139  $iterator = new LUT\Recursive\Iterator($directory),
140  $result = []
141  )
142  ->when(function () use ($iterator, &$result) {
143  foreach ($iterator as $file) {
144  $result[] = $file->getFilename();
145  }
146  })
147  ->then
148  ->array($result)
149  ->isEqualTo([
150  'A',
151  'Aa',
152  'Aaa',
153  'B',
154  'Bb',
155  'Bbb',
156  'C',
157  'Cc',
158  'Ccc'
159  ]);
160  }
Hoa\Iterator\Test\Unit\Directory::case_recursive_splFileClassInfo ( )

Definition at line 201 of file Directory.php.

202  {
203  $this
204  ->given(
205  $splFileInfo = 'Hoa\Iterator\SplFileInfo',
206  $root = resolve('hoa://Test/Vfs/Root?type=directory'),
207  resolve('hoa://Test/Vfs/Root/A?type=directory'),
208  resolve('hoa://Test/Vfs/Root/A/a'),
209  resolve('hoa://Test/Vfs/Root/A/b'),
210  resolve('hoa://Test/Vfs/Root/A/c'),
211  resolve('hoa://Test/Vfs/Root/B?type=directory'),
212  resolve('hoa://Test/Vfs/Root/B/d'),
213  resolve('hoa://Test/Vfs/Root/B/e'),
214  resolve('hoa://Test/Vfs/Root/B/c?type=directory'),
215  resolve('hoa://Test/Vfs/Root/B/c/f'),
216  $directory = new LUT\Recursive\Directory(
217  $root,
218  LUT\FileSystem::CURRENT_AS_FILEINFO,
219  $splFileInfo
220  ),
221  $iterator = new LUT\Recursive\Iterator($directory),
222  $result = []
223  )
224  ->when(function () use ($iterator, $splFileInfo, &$result) {
225  foreach ($iterator as $file) {
226  $this
227  ->object($file)
228  ->isInstanceOf($splFileInfo);
229 
230  $result[] = $file->getFilename();
231  }
232  })
233  ->then
234  ->array($result)
235  ->isEqualTo([
236  'a',
237  'b',
238  'c',
239  'd',
240  'e',
241  'f'
242  ]);
243  }
Hoa\Iterator\Test\Unit\Directory::case_seek_and_dots ( )

Definition at line 81 of file Directory.php.

82  {
83  $this
84  ->given(
85  $root = resolve('hoa://Test/Vfs/Root?type=directory'),
86  resolve('hoa://Test/Vfs/Root/.'),
87  resolve('hoa://Test/Vfs/Root/..'),
88  resolve('hoa://Test/Vfs/Root/Skip'),
89  resolve('hoa://Test/Vfs/Root/Gotcha'),
90  $iterator = new LUT\Directory($root)
91  )
92  ->when($result = $iterator->current())
93  ->then
94  ->boolean($result->isDot())
95  ->isTrue()
96 
97  ->when(
98  $iterator->next(),
99  $result = $iterator->current()
100  )
101  ->then
102  ->boolean($result->isDot())
103  ->isTrue()
104 
105  ->when(
106  $iterator->seek(3),
107  $result = $iterator->current()
108  )
109  ->then
110  ->string($result->getFilename())
111  ->isEqualTo('Gotcha')
112 
113  ->when(
114  $iterator->seek(2),
115  $result = $iterator->current()
116  )
117  ->then
118  ->string($result->getFilename())
119  ->isEqualTo('Skip');
120  }
Hoa\Iterator\Test\Unit\Directory::case_splFileClassInfo ( )

Definition at line 162 of file Directory.php.

163  {
164  $this
165  ->given(
166  $splFileInfo = 'Hoa\Iterator\SplFileInfo',
167  $root = resolve('hoa://Test/Vfs/Root?type=directory'),
168  resolve('hoa://Test/Vfs/Root/a'),
169  resolve('hoa://Test/Vfs/Root/b'),
170  resolve('hoa://Test/Vfs/Root/c'),
171  resolve('hoa://Test/Vfs/Root/d'),
172  resolve('hoa://Test/Vfs/Root/e'),
173  resolve('hoa://Test/Vfs/Root/f'),
174  $iterator = new LUT\Directory(
175  $root,
176  $splFileInfo
177  ),
178  $result = []
179  )
180  ->when(function () use ($iterator, $splFileInfo, &$result) {
181  foreach ($iterator as $file) {
182  $this
183  ->object($file)
184  ->isInstanceOf($splFileInfo);
185 
186  $result[] = $file->getFilename();
187  }
188  })
189  ->then
190  ->array($result)
191  ->isEqualTo([
192  'a',
193  'b',
194  'c',
195  'd',
196  'e',
197  'f'
198  ]);
199  }

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