|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PSFS\tests\services; |
|
4
|
|
|
|
|
5
|
|
|
use PHPUnit\Framework\Attributes\Before; |
|
|
|
|
|
|
6
|
|
|
use PSFS\base\Router; |
|
7
|
|
|
use PSFS\base\types\helpers\GeneratorHelper; |
|
8
|
|
|
use PSFS\services\DocumentorService as Service; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class DocumentServiceTest |
|
12
|
|
|
* @package PSFS\tests\services |
|
13
|
|
|
*/ |
|
14
|
|
|
class DocumentorServiceTest extends GeneratorServiceTest |
|
15
|
|
|
{ |
|
16
|
|
|
|
|
17
|
|
|
public static $namespaces = [ |
|
18
|
|
|
'\CLIENT\Api\Test\Test', |
|
19
|
|
|
'\CLIENT\Api\Related\Related', |
|
20
|
|
|
'\CLIENT\Api\Solo', |
|
21
|
|
|
]; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @throws \PSFS\base\exception\GeneratorException |
|
25
|
|
|
*/ |
|
26
|
|
|
#[Before] |
|
27
|
|
|
public function prepareDocumentRoot(): void |
|
28
|
|
|
{ |
|
29
|
|
|
if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json')) { |
|
30
|
|
|
unlink(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json'); |
|
31
|
|
|
} |
|
32
|
|
|
$this->assertFileDoesNotExist(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', 'Previous generated domains json, please delete it before testing'); |
|
33
|
|
|
GeneratorHelper::deleteDir(CACHE_DIR); |
|
34
|
|
|
$this->assertDirectoryDoesNotExist(CACHE_DIR, 'Cache folder already exists with data'); |
|
35
|
|
|
GeneratorHelper::createRoot(WEB_DIR, null, true); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param string $modulePath |
|
40
|
|
|
*/ |
|
41
|
|
|
protected function clearContext(string $modulePath): void |
|
42
|
|
|
{ |
|
43
|
|
|
GeneratorHelper::deleteDir($modulePath); |
|
44
|
|
|
$this->assertDirectoryDoesNotExist($modulePath, 'Error trying to delete the module'); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @throws \PSFS\base\exception\GeneratorException |
|
49
|
|
|
* @throws \ReflectionException |
|
50
|
|
|
*/ |
|
51
|
|
|
public function testApiDocumentation() |
|
52
|
|
|
{ |
|
53
|
|
|
$modulePath = $this->checkCreateExistingModule(); |
|
54
|
|
|
$this->assertDirectoryExists($modulePath, 'Module did not exists'); |
|
55
|
|
|
|
|
56
|
|
|
Router::getInstance()->init(); |
|
57
|
|
|
$documentorService = Service::getInstance(); |
|
58
|
|
|
$module = $documentorService->getModules(self::MODULE_NAME); |
|
59
|
|
|
$doc = $documentorService->extractApiEndpoints($module); |
|
60
|
|
|
foreach ($doc as $namespace => $endpoints) { |
|
61
|
|
|
$this->assertContains($namespace, self::$namespaces, 'Namespace not included in the test'); |
|
62
|
|
|
$this->assertCount(7, $endpoints, 'Different number of endpoints'); |
|
63
|
|
|
} |
|
64
|
|
|
$this->clearContext($modulePath); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths