SchemaStorageTest::testStoresSchemas()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 15
rs 9.9666
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gorynych\Tests\Util;
6
7
use DG\BypassFinals;
8
use Gorynych\Util\OAReader;
9
use Gorynych\Util\SchemaStorage;
10
use OpenApi\Annotations\Components;
11
use OpenApi\Annotations\OpenApi;
12
use OpenApi\Annotations\Schema;
13
use PHPUnit\Framework\TestCase;
14
15
class SchemaStorageTest extends TestCase
16
{
17
    public function testStoresSchemas(): void
18
    {
19
        $components = new Components([]);
20
        $components->schemas = [new Schema([])];
21
        $openApi = new OpenApi([]);
22
        $openApi->components = $components;
23
24
        BypassFinals::enable();
25
26
        $oaReaderMock = $this->createMock(OAReader::class);
27
        $oaReaderMock->expects($this->once())->method('read')->willReturn($openApi);
28
29
        $schemas = (new SchemaStorage($oaReaderMock))->getSchemas();
30
31
        $this->assertInstanceOf(Schema::class, $schemas->first());
32
    }
33
}
34