-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adding defaults to paths that can't be reflected on * moving phpstan to dist file
- Loading branch information
Showing
11 changed files
with
315 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
includes: | ||
- ../tools/vendor/phpstan/phpstan-phpunit/extension.neon | ||
- ../tools/vendor/phpstan/phpstan-phpunit/rules.neon | ||
- ../tools/vendor/phpstan/phpstan-strict-rules/rules.neon | ||
parameters: | ||
ignoreErrors: | ||
- '#^Parameter \#3 \$subject of function preg_replace expects array\|string, array\|string\|null given\.$#' | ||
- '#^Parameter \#3 \$subject of function preg_replace expects array\|string, string\|null given\.$#' | ||
- '#^Access to an undefined property De\\Idrinth\\PhalconRoutes2OpenApi\\Implementations\\Controller::\$(router|request|di|response)\.$#' | ||
- '#^Parameter \#4 ...\$sets of method De\\Idrinth\\PhalconRoutes2OpenApi\\Implementations\\NoValueConversionMerger::mergeAll\(\) expects array, string given\.$#' | ||
includes: | ||
- ../tools/vendor/phpstan/phpstan-phpunit/extension.neon | ||
- ../tools/vendor/phpstan/phpstan-phpunit/rules.neon | ||
- ../tools/vendor/phpstan/phpstan-strict-rules/rules.neon | ||
- '#^Parameter \#4 \.\.\.\$sets of method De\\Idrinth\\PhalconRoutes2OpenApi\\Implementations\\NoValueConversionMerger::mergeAll\(\) expects array, string given\.$#' | ||
- '#^Parameter \#1 \$sets \(array<int, array>\) of method De\\Idrinth\\PhalconRoutes2OpenApi\\Implementations\\NoValueConversionMerger::mergeAll\(\) should be contravariant with parameter \$sets \(array<int, mixed>\) of method De\\Idrinth\\PhalconRoutes2OpenApi\\Interfaces\\RecursiveMerger::mergeAll\(\)$#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" | ||
> | ||
<testsuites> | ||
<testsuite name="default"> | ||
<directory>test</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist processUncoveredFilesFromWhitelist="true"> | ||
<directory>src</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace De\Idrinth\PhalconRoutes2OpenApi\Implementations; | ||
|
||
use stdClass; | ||
|
||
class DefaultResponse | ||
{ | ||
/** | ||
* @param array $route | ||
* @return array | ||
*/ | ||
public static function add(array $route): array | ||
{ | ||
if (!isset($route['responses']) || count($route['responses']) === 0) { | ||
$route['responses'] = [ | ||
'200' => [ | ||
"description" => 'unknown return', | ||
'content' => [ | ||
'*/*' => [ | ||
'schema' => new stdClass() | ||
] | ||
] | ||
] | ||
]; | ||
} | ||
$route['summary'] = $route['summary'] ?? ''; | ||
$route['description'] = $route['description'] ?? ''; | ||
return $route; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace De\Idrinth\Test\PhalconRoutes2OpenApi; | ||
|
||
use De\Idrinth\PhalconRoutes2OpenApi\Implementations\DefaultResponse; | ||
use PHPUnit\Framework\TestCase; | ||
use stdClass; | ||
|
||
class DefaultResponseTest extends TestCase | ||
{ | ||
/** | ||
* @return array | ||
*/ | ||
public function provideAdd(): array | ||
{ | ||
$default = [ | ||
'summary' => '', | ||
'description' => '', | ||
'responses' => [ | ||
'200' => ['description' => 'unknown return','content' => ['*/*' => ['schema' => new stdClass()]]] | ||
] | ||
]; | ||
return [ | ||
'empty' => [[], $default], | ||
'existing summary' => [['summary' => 'a'], array_merge($default, ['summary' => 'a'])], | ||
'existing description' => [['description' => 'b'], array_merge($default, ['description' => 'b'])], | ||
'existing response' => [ | ||
['responses' => ['200' => []]], | ||
array_merge($default, ['responses' => ['200' => []]]) | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider provideAdd | ||
* @param array $route | ||
* @param array $expectation | ||
* @return void | ||
*/ | ||
public function testAdd(array $route, array $expectation) | ||
{ | ||
self::assertEquals($expectation, DefaultResponse::add($route)); | ||
} | ||
} |
Oops, something went wrong.