1 | <?php |
||
15 | class FilteredLsTest extends TestCase |
||
16 | { |
||
17 | |||
18 | /** |
||
19 | * @var Filesystem |
||
20 | */ |
||
21 | private $filesystem; |
||
22 | |||
23 | public function setUp() |
||
27 | |||
28 | public function testFilteredLsExercise() |
||
39 | |||
40 | public function testGetArgsCreatesFilesAndReturnsRandomExt() |
||
41 | { |
||
42 | $e = new FilteredLs($this->filesystem); |
||
43 | $args = $e->getArgs(); |
||
44 | $path = $args[0]; |
||
45 | $this->assertFileExists($path); |
||
46 | |||
47 | $files = [ |
||
48 | "learnyouphp.dat", |
||
49 | "learnyouphp.txt", |
||
50 | "learnyouphp.sql", |
||
51 | "api.html", |
||
52 | "README.md", |
||
53 | "CHANGELOG.md", |
||
54 | "LICENCE.md", |
||
55 | "md", |
||
56 | "data.json", |
||
57 | "data.dat", |
||
58 | "words.dat", |
||
59 | "w00t.dat", |
||
60 | "w00t.txt", |
||
61 | "wrrrrongdat", |
||
62 | "dat", |
||
63 | ]; |
||
64 | |||
65 | array_walk($files, function ($file) use ($path) { |
||
66 | $this->assertFileExists(sprintf('%s/%s', $path, $file)); |
||
67 | }); |
||
68 | |||
69 | $extensions = array_unique(array_map(function ($file) { |
||
70 | return pathinfo($file, PATHINFO_EXTENSION); |
||
71 | }, $files)); |
||
72 | |||
73 | $this->assertTrue(in_array($args[1], $extensions)); |
||
74 | } |
||
75 | |||
76 | public function testTearDownRemovesFile() |
||
87 | } |
||
88 |