Skip to content

Commit 56dfbe0

Browse files
committed
add test cases
1 parent 8e6ee23 commit 56dfbe0

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

tests/Action/SchemeTest.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/*
3+
* Fusio - Self-Hosted API Management for Builders.
4+
* For the current version and information visit <https://www.fusio-project.org/>
5+
*
6+
* Copyright (c) Christoph Kappestein <christoph.kappestein@gmail.com>
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
namespace Fusio\Impl\Tests\Action;
22+
23+
use Fusio\Impl\Action\Scheme;
24+
use PHPUnit\Framework\Attributes\DataProvider;
25+
use PHPUnit\Framework\TestCase;
26+
27+
/**
28+
* SchemeTest
29+
*
30+
* @author Christoph Kappestein <christoph.kappestein@gmail.com>
31+
* @license http://www.apache.org/licenses/LICENSE-2.0
32+
* @link https://www.fusio-project.org
33+
*/
34+
class SchemeTest extends TestCase
35+
{
36+
#[DataProvider('schemeProvider')]
37+
public function testSplit(string $action, Scheme $expectScheme, string $expectName, ?string $expectHash): void
38+
{
39+
[$actualScheme, $actualName, $actualHash] = Scheme::split($action);
40+
41+
$this->assertEquals($expectScheme, $actualScheme);
42+
$this->assertEquals($expectName, $actualName);
43+
$this->assertEquals($expectHash, $actualHash);
44+
}
45+
46+
public static function schemeProvider(): array
47+
{
48+
return [
49+
['foo', Scheme::ACTION, 'foo', null],
50+
['action://foo', Scheme::ACTION, 'foo', null],
51+
['action://foo@hash', Scheme::ACTION, 'foo', 'hash'],
52+
['https://api.fusio-project.org', Scheme::HTTPS, 'api.fusio-project.org', null],
53+
];
54+
}
55+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/*
3+
* Fusio - Self-Hosted API Management for Builders.
4+
* For the current version and information visit <https://www.fusio-project.org/>
5+
*
6+
* Copyright (c) Christoph Kappestein <christoph.kappestein@gmail.com>
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
namespace Fusio\Impl\Tests\Framework\Schema;
22+
23+
use Fusio\Impl\Framework\Schema\Scheme;
24+
use PHPUnit\Framework\Attributes\DataProvider;
25+
use PHPUnit\Framework\TestCase;
26+
27+
/**
28+
* SchemeTest
29+
*
30+
* @author Christoph Kappestein <christoph.kappestein@gmail.com>
31+
* @license http://www.apache.org/licenses/LICENSE-2.0
32+
* @link https://www.fusio-project.org
33+
*/
34+
class SchemeTest extends TestCase
35+
{
36+
#[DataProvider('schemeProvider')]
37+
public function testSplit(string $schema, Scheme $expectScheme, string $expectName, ?string $expectHash): void
38+
{
39+
[$actualScheme, $actualName, $actualHash] = Scheme::split($schema);
40+
41+
$this->assertEquals($expectScheme, $actualScheme);
42+
$this->assertEquals($expectName, $actualName);
43+
$this->assertEquals($expectHash, $actualHash);
44+
}
45+
46+
public static function schemeProvider(): array
47+
{
48+
return [
49+
['foo', Scheme::SCHEMA, 'foo', null],
50+
['schema://foo', Scheme::SCHEMA, 'foo', null],
51+
['schema://foo@hash', Scheme::SCHEMA, 'foo', 'hash'],
52+
['https://api.fusio-project.org', Scheme::HTTPS, 'api.fusio-project.org', null],
53+
];
54+
}
55+
}

0 commit comments

Comments
 (0)