1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Yoghi\Bundle\MaddaBundle\Generator; |
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\MaddaBundle\Finder\Finder; |
15
|
|
|
use Yoghi\Bundle\MaddaBundleTest\Utils\AbstractCommonLogTest; |
16
|
|
|
use Yoghi\Bundle\MaddaBundleTest\Utils\FileCompare; |
17
|
|
|
use Yoghi\Bundle\MaddaBundleTest\Utils\PhpunitFatalErrorHandling; |
18
|
|
|
use Yoghi\Bundle\MaddaBundleTest\Utils\VfsAdapter; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @author Stefano Tamagnini <> |
22
|
|
|
*/ |
23
|
|
|
class RestGeneratorTest extends \PHPUnit_Framework_TestCase |
24
|
|
|
{ |
25
|
|
|
use AbstractCommonLogTest; |
26
|
|
|
use FileCompare; |
27
|
|
|
use PhpunitFatalErrorHandling; |
28
|
|
|
|
29
|
|
|
public function testImpresaRestGenerator() |
30
|
|
|
{ |
31
|
|
|
$directoryOutput = self::$directoryV->url().'/output'; |
32
|
|
|
|
33
|
|
|
if (!file_exists($directoryOutput)) { |
34
|
|
|
mkdir($directoryOutput, 0700, true); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
$resourcesDir = __DIR__.'/../Resources'; |
38
|
|
|
|
39
|
|
|
$rgen = new RestGenerator(); |
40
|
|
|
$rgen->setLogger($this->logger); |
41
|
|
|
$rgen->generateRest($resourcesDir.'/raml/api.raml', new VfsAdapter($directoryOutput)); |
42
|
|
|
|
43
|
|
|
// $finderV = new Finder(); |
|
|
|
|
44
|
|
|
// $finderV->search($directoryOutput, 'php'); |
|
|
|
|
45
|
|
|
// foreach ($finderV->getFindedFiles() as $file) { |
|
|
|
|
46
|
|
|
// $namespace = str_replace('vfs://root/output/', '', pathinfo($file, PATHINFO_DIRNAME)); |
|
|
|
|
47
|
|
|
// $name = str_replace('.php', '', pathinfo($file, PATHINFO_FILENAME)); |
|
|
|
|
48
|
|
|
// $this->logger->info('$mappaToCheck[\''.$namespace.'\'] = \''.$name.'\';'); |
|
|
|
|
49
|
|
|
// } |
50
|
|
|
// echo $this->readLog(); |
|
|
|
|
51
|
|
|
// exit; |
52
|
|
|
|
53
|
|
|
$mappaToCheck = []; |
54
|
|
|
$mappaToCheck['AppBundle/Controller'][] = 'StatusController'; |
55
|
|
|
$mappaToCheck['AppBundle/Controller'][] = 'BadgeController'; |
56
|
|
|
$mappaToCheck['AppBundle/Controller'][] = 'WorkspaceController'; |
57
|
|
|
$mappaToCheck['AppBundle/Controller'][] = 'StreamController'; |
58
|
|
|
|
59
|
|
View Code Duplication |
foreach ($mappaToCheck as $namespace => $classList) { |
|
|
|
|
60
|
|
|
foreach ($classList as $className) { |
61
|
|
|
$this->compareClassPhp($resourcesDir.'/raml/generated/'.$namespace, $namespace, $className, $directoryOutput, true); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
// $routingFile = 'AppBundle/Resources/config/routing.yml'; |
|
|
|
|
66
|
|
|
// $this->compareFile($resourcesDir.'/raml/generated/', $directoryOutput, $routingFile, false); |
|
|
|
|
67
|
|
|
|
68
|
|
|
$errors = $rgen->getErrors(); |
69
|
|
|
$this->assertCount(0, $errors, 'errori durante la generazione'); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.