Issues (3877)

...nGeneratorOpenApiContentGeneratorPluginTest.php (1 issue)

1
<?php
2
3
/**
4
 * Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerTest\Glue\DocumentationGeneratorOpenApi\Plugin;
9
10
use Codeception\Test\Unit;
11
use LogicException;
12
use Spryker\Glue\DocumentationGeneratorOpenApi\Plugin\DocumentationGeneratorApi\DocumentationGeneratorOpenApiContentGeneratorStrategyPlugin;
13
14
/**
15
 * Auto-generated group annotations
16
 *
17
 * @group SprykerTest
18
 * @group Glue
19
 * @group DocumentationGeneratorOpenApi
20
 * @group Plugin
21
 * @group DocumentationGeneratorOpenApiContentGeneratorPluginTest
22
 * Add your own group annotations below this line
23
 */
24
class DocumentationGeneratorOpenApiContentGeneratorPluginTest extends Unit
25
{
26
    /**
27
     * @var string
28
     */
29
    protected const TMP_DIR_NAME = 'DocumentationGeneratorOpenApiContentGeneratorPluginTest';
30
31
    /**
32
     * @var string
33
     */
34
    protected const TMP_FILE_NAME = 'generated.yaml.example';
35
36
    /**
37
     * @return void
38
     */
39
    public function testCallGenerateContentIsValid(): void
40
    {
41
        //Arrange
42
        $formattedData = [
43
            'openapi' => '3.0.1',
44
            'info' => [
45
                'title' => 'Spryker Glue API specification',
46
                'description' => '',
47
                'termsOfService' => 'https://support.spryker.com/',
48
                'version' => '1.0.0',
49
                'contact' => [
50
                    'name' => 'Spryker',
51
                    'url' => 'https://support.spryker.com/',
52
                    'email' => '[email protected]',
53
                ],
54
                'license' => [
55
                    'name' => 'MIT',
56
                ],
57
            ],
58
            'paths' => [],
59
        ];
60
        $exampleFilePath = codecept_data_dir() . static::TMP_DIR_NAME . DIRECTORY_SEPARATOR . static::TMP_FILE_NAME;
0 ignored issues
show
The function codecept_data_dir was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

60
        $exampleFilePath = /** @scrutinizer ignore-call */ codecept_data_dir() . static::TMP_DIR_NAME . DIRECTORY_SEPARATOR . static::TMP_FILE_NAME;
Loading history...
61
        $plugin = new DocumentationGeneratorOpenApiContentGeneratorStrategyPlugin();
62
63
        //Act
64
        $content = $plugin->generateContent($formattedData);
65
66
        //Assert
67
        $this->assertEquals(file_get_contents($exampleFilePath), $content);
68
    }
69
70
    /**
71
     * @return void
72
     */
73
    public function testCallGenerateLogicException(): void
74
    {
75
        //Arrange
76
        $formattedData = [
77
            'openapi' => '3.0.1',
78
            'info' => [
79
                'title' => 'Spryker Glue API specification',
80
                'description' => '',
81
                'termsOfService' => 'https://support.spryker.com/',
82
                'version' => '1.0.0',
83
                'contact' => [
84
                    'name' => 'Spryker',
85
                    'url' => 'https://support.spryker.com/',
86
                    'email' => '[email protected]',
87
                ],
88
                'license' => [
89
                    'name' => 'MIT',
90
                ],
91
            ],
92
        ];
93
        $plugin = new DocumentationGeneratorOpenApiContentGeneratorStrategyPlugin();
94
95
        //Assert
96
        $this->expectException(LogicException::class);
97
        $this->expectExceptionMessage('OpenApi is missing required property: paths');
98
99
        //Act
100
        $plugin->generateContent($formattedData);
101
    }
102
}
103