Skip to content

Commit f348cc6

Browse files
committed
test: cover listing files and directories
1 parent c2f9fe2 commit f348cc6

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/Tempest/Storage/tests/StorageTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,33 @@ public function test_storage_read(): void
5555
$this->assertSame('baz', $storage->read('foo.txt'));
5656
}
5757

58+
public function test_storage_list(): void
59+
{
60+
mkdir($this->fixtures);
61+
file_put_contents($this->fixtures . 'foo.txt', 'baz');
62+
63+
$storage = new GenericStorage(new LocalStorageConfig(
64+
path: $this->fixtures,
65+
));
66+
67+
$this->assertCount(1, $storage->list()->toArray());
68+
}
69+
70+
public function test_storage_list_deep(): void
71+
{
72+
mkdir($this->fixtures);
73+
file_put_contents($this->fixtures . 'foo.txt', 'baz');
74+
mkdir($this->fixtures . 'dir');
75+
file_put_contents($this->fixtures . 'dir/baz.txt', 'bar');
76+
77+
$storage = new GenericStorage(new LocalStorageConfig(
78+
path: $this->fixtures,
79+
));
80+
81+
$this->assertCount(3, $storage->list(deep: true)->toArray());
82+
$this->assertCount(1, $storage->list(location: 'dir')->toArray());
83+
}
84+
5885
public function test_storage_clean_directory(): void
5986
{
6087
mkdir($this->fixtures);

0 commit comments

Comments
 (0)