FinderTest::testFindYmlOnVfs()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 16
rs 9.4285
cc 2
eloc 11
nc 2
nop 0
1
<?php
2
3
namespace Yoghi\Bundle\MaddaBundle\Finder;
4
5
/*
6
 * This file is part of the MADDA project.
7
 *
8
 * (c) Stefano Tamagnini <>
9
 *
10
 * This source file is subject to the GPLv3 license that is bundled
11
 * with this source code in the file LICENSE.
12
 */
13
14
use Yoghi\Bundle\MaddaBundleTest\Utils\AbstractCommonLogTest;
15
16
17
/**
18
 * @author Stefano Tamagnini <>
19
 */
20
class FinderTest extends \PHPUnit_Framework_TestCase
21
{
22
    use AbstractCommonLogTest;
23
24
    public function testFindYml()
25
    {
26
        $finder = new Finder();
27
        $finder->setLogger($this->logger);
28
        $finder->search(__DIR__.'/../Resources/finder', 'yml');
29
        $actual = $finder->getFindedFiles();
30
        $this->logger->info('File trovati '.count($actual));
31
        $this->assertCount(3, $actual, 'yml file not found');
32
33
        $names = [];
34
        foreach ($actual as $file) {
35
            $names[] = pathinfo($file, PATHINFO_FILENAME);
36
        }
37
38
        $expected = ['model', 'emptyModel', 'invalidModel'];
39
        $diff = array_diff($names, $expected);
40
41
        $this->assertEmpty($diff, 'yml not found');
42
    }
43
44
    public function testFindYmlOnVfs()
45
    {
46
        $directoryOutput = self::$directoryV->url().'/output';
47
        if (!file_exists($directoryOutput)) {
48
            mkdir($directoryOutput, 0700, true);
49
        }
50
51
        $data = file_get_contents(__DIR__.'/../Resources/finder/basemodel/model.yml');
52
        file_put_contents($directoryOutput.'/test.yml', $data);
53
54
        $finder = new Finder();
55
        $finder->setLogger($this->logger);
56
        $finder->search($directoryOutput, 'yml');
57
        $actual = $finder->getFindedFiles();
58
        $this->assertCount(1, $actual, 'yml file not found');
59
    }
60
}
61