RecursiveFileListingTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testInvalidDirectory() 0 2 1
A testFilterFiles() 0 6 1
A testFindFiles() 0 5 1
A testFilterRemoval() 0 7 1
1
<?php
2
3
namespace CSFCloud\Tests;
4
5
use PHPUnit\Framework\TestCase;
6
use CSFCloud\RecursiveFileListing;
7
8
final class RecursiveFileListingTest extends TestCase {
9
10
    /**
11
     * @expectedException Exception
12
     */
13
    public function testInvalidDirectory() {
14
        new RecursiveFileListing(__DIR__ . "/not_existing_dir");
15
    }
16
17
    public function testFindFiles() {
18
        $finder = new RecursiveFileListing(__DIR__ . "/RecFileListTestDir");
19
        $files = $finder->scan();
20
21
        $this->assertEquals(3, count($files));
22
    }
23
24
    public function testFilterFiles() {
25
        $finder = new RecursiveFileListing(__DIR__ . "/RecFileListTestDir");
26
        $finder->addFilter('/.*\.txt$/i');
27
        $files = $finder->scan();
28
29
        $this->assertEquals(2, count($files));
30
    }
31
32
    public function testFilterRemoval() {
33
        $finder = new RecursiveFileListing(__DIR__ . "/RecFileListTestDir");
34
        $finder->addFilter('/.*\.txt$/i');
35
        $finder->clearFilters();
36
        $files = $finder->scan();
37
38
        $this->assertEquals(3, count($files));
39
    }
40
41
}