Skip to content

Commit 79c6eeb

Browse files
Merge pull request #3 from negreanucalin/dev
Dev
2 parents 64d86e4 + dd0691e commit 79c6eeb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+566
-160
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
- master
8+
pull_request:
9+
branches:
10+
- dev
11+
- master
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: php-actions/composer@v5
18+
- name: PHPUnit tests
19+
uses: php-actions/phpunit@v3
20+
with:
21+
configuration: phpunit.xml

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"symfony/dependency-injection": "5.*",
2828
"symfony/filesystem": "5.*",
2929
"symfony/config": "5.*",
30-
"negreanucalin/sparkle-dto": "~0.1",
30+
"negreanucalin/sparkle-dto": "dev-dev",
3131
"ext-json": "*"
3232
}
3333
}

composer.lock

Lines changed: 10 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpunit.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
colors="true"
5+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
6+
bootstrap="vendor/autoload.php"
7+
>
8+
<coverage>
9+
<include>
10+
<directory suffix=".php">src</directory>
11+
</include>
12+
</coverage>
13+
<testsuites>
14+
<testsuite name="feature">
15+
<directory prefix="Feature">.</directory>
16+
</testsuite>
17+
</testsuites>
18+
<logging/>
19+
</phpunit>

src/DTO/EnvironmentDto.php

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/DTO/ProjectDto.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
* @property string $logo
1313
* @property string $definitionFile
1414
* @property CategoryDto[] $categories
15-
* @property EnvironmentDto[] $environments
15+
* @property VariableDto[] $variables
1616
*/
1717
class ProjectDto extends DataTransferObject
1818
{
1919
protected $casts = [
20-
'environments' => EnvironmentDto::class,
2120
'categories' => CategoryDto::class,
22-
'version'=>'string'
21+
'version' => 'string',
22+
'variables*' => VariableDto::class
2323
];
2424

2525
protected $hidden = [
@@ -35,13 +35,13 @@ public function __construct($arguments)
3535
public function jsonSerialize()
3636
{
3737
$return = [
38-
'name'=>$this->name,
39-
'version'=>$this->version,
40-
'description'=>$this->description,
41-
'buildDate'=>$this->buildDate,
38+
'name' => $this->name,
39+
'version' => $this->version,
40+
'description' => $this->description,
41+
'buildDate' => $this->buildDate,
4242
];
43-
if ($this->environments) {
44-
$return['environments'] = $this->environments;
43+
if ($this->variables) {
44+
$return['variables'] = $this->variables;
4545
}
4646
if ($this->logo) {
4747
$return['logo'] = $this->logo;

src/DTO/VariableDto.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace MultidocParser\DTO;
4+
5+
use SparkleDto\DataTransferObject;
6+
7+
/**
8+
* @property string $default
9+
* @property string $description
10+
*/
11+
class VariableDto extends DataTransferObject
12+
{
13+
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace MultidocParser\Exceptions;
4+
5+
class DefinitionFileException extends \Exception
6+
{
7+
8+
}

src/Services/FileContentParserService.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use MultidocParser\DTO\ProjectDto;
66
use MultidocParser\DTO\RouteDto;
77
use MultidocParser\Exceptions\CategoriesNotFoundException;
8+
use MultidocParser\Exceptions\DefinitionFileException;
89
use MultidocParser\Exceptions\MultipleProjectsException;
910
use MultidocParser\Exceptions\ProjectNotDefinedException;
1011
use MultidocParser\Exceptions\RoutesNotDefinedException;
@@ -27,6 +28,9 @@ class FileContentParserService
2728
public const PARAMETER_TYPE_FILE = 'file';
2829
public const TEMPLATES_KEY = 'templates';
2930
public const PROJECT_KEY = 'project';
31+
public const VARIABLES_KEY = 'variables';
32+
// Protected because it composes routed in the ui
33+
public const ENVIRONMENT_KEY = 'environment';
3034

3135
private DataNormalizer $dataNormalizer;
3236
private CategoryNormalizer $categoryNormalizer;
@@ -112,6 +116,7 @@ private function readFiles($fileList)
112116
* @throws ProjectNotDefinedException
113117
* @throws RoutesNotDefinedException
114118
* @throws CategoriesNotFoundException
119+
* @throws DefinitionFileException
115120
*/
116121
private function validateParsedData(array $data)
117122
{
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace MultidocParser\Tests\Feature;
4+
5+
use MultidocParser\Tests\MultidocParserTestFeature;
6+
7+
class VariablesFeatureTest extends MultidocParserTestFeature
8+
{
9+
protected string $dataPath = __DIR__.'/../data_in/variables';
10+
protected string $outPath = __DIR__.'/../data_out/variables';
11+
12+
public function test_basic_template_exist()
13+
{
14+
$this->assertRouteHasParameterName('userId','User retrieval', $this->project);
15+
$this->assertRouteHasHeaders(['Accept'=>'application/json'], 'User deletion', $this->project);
16+
$this->assertRouteHasHeaders(['Authorization'=>'Bearer APPLICATION_TOKEN'], 'User deletion', $this->project);
17+
$this->assertHasVariables($this->project);
18+
$this->assertHasVariable('OTHER_TOKEN', $this->project);
19+
}
20+
}

0 commit comments

Comments
 (0)