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
|
|
|
|