Passed
Push — master ( 54c793...ee66e8 )
by Lluís
05:11 queued 10s
created

FilesTreatmentTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A filesFromDirectoryAreCorrect() 0 13 1
A FilesTreatmentCannotBeInstantiatedFromInvalidFile() 0 3 1
A FilesTreatmentCannotBeInstantiatedFromInvalidPath() 0 3 1
1
<?php
2
namespace tests;
3
4
require '../vendor/autoload.php';
5
require '../src/application/FilesTreatment.php';
6
7
use phpDocumentor\Reflection\File\LocalFile;
8
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use application\FilesTreatment;
10
11
class FilesTreatmentTest extends TestCase
12
{
13
    /**
14
     * @test
15
     */
16
    public function FilesTreatmentCannotBeInstantiatedFromInvalidFile(): void {
17
        $this->expectException(\Exception::class);
18
        new FilesTreatment('invalid-file.php');
19
    }
20
21
    /**
22
     * @test
23
     */
24
    public function FilesTreatmentCannotBeInstantiatedFromInvalidPath(): void {
25
        $this->expectException(\Exception::class);
26
        new FilesTreatment('invalid-path');
27
    }
28
29
    /**
30
     * @test
31
     * @throws \Exception
32
     */
33
    public function filesFromDirectoryAreCorrect(): void {
34
        $attribute = (new \ReflectionClass('application\FilesTreatment'))->getProperty('files');
35
        $attribute->setAccessible(true);
36
        $filesAttribute = array_map(function(LocalFile $localFileObject): string {
37
            $localFileObjectAttribute = (new \ReflectionClass('\phpDocumentor\Reflection\File\LocalFile'))->getProperty('path');
38
            $localFileObjectAttribute->setAccessible(true);
39
            return $localFileObjectAttribute->getValue($localFileObject);
40
        }, ($attribute->getValue(new FilesTreatment(dirname(__DIR__ . '/tests')))));
41
        $expectedFilesAttribute = array(
42
            dirname(__DIR__) . '/tests/FilesTreatmentTest.php',
43
            dirname(__DIR__) . '/tests/PDFFileTest.php'
44
        );
45
        $this->assertEquals($expectedFilesAttribute, $filesAttribute);
46
    }
47
}