Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Coverage/CoverageMergeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ private function appendGithubStepSummary(array $results, ?string $githubSummaryP
* caller decides what to do with the return value (only `strict=true`
* misses propagate to a non-zero exit).
*
* @param array<string, array<string, mixed>> $results
* @param array<string, CoverageResult> $results
*/
private function evaluateThresholdGate(
array $results,
Expand All @@ -517,7 +517,6 @@ private function evaluateThresholdGate(
return false;
}

/** @var array<string, array{endpoints: list<mixed>, endpointTotal: int, endpointFullyCovered: int, endpointPartial: int, endpointUncovered: int, endpointRequestOnly: int, responseTotal: int, responseCovered: int, responseSkipped: int, responseUncovered: int}> $results */
$evaluation = CoverageThresholdEvaluator::evaluate($results, $minEndpointPct, $minResponsePct, $strict);

if ($evaluation['passed']) {
Expand Down Expand Up @@ -654,7 +653,7 @@ private function reportThresholdProblem(bool $strict, string $detail): array
/**
* @param list<string> $specs
*
* @return array<string, array<string, mixed>>
* @return array<string, CoverageResult>
*/
private function computeResults(array $specs, OpenApiCoverageTracker $tracker): array
{
Expand Down
6 changes: 5 additions & 1 deletion tests/Unit/Coverage/CoverageThresholdEvaluatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Studio\OpenApiContractTesting\Coverage\CoverageThresholdEvaluator;
use Studio\OpenApiContractTesting\Coverage\OpenApiCoverageTracker;

use function explode;
use function str_repeat;
use function substr;
use function trim;

/**
* @phpstan-import-type CoverageResult from OpenApiCoverageTracker
*/
class CoverageThresholdEvaluatorTest extends TestCase
{
#[Test]
Expand Down Expand Up @@ -240,7 +244,7 @@ public function aligns_second_message_line_to_label_indent(): void
* defaults match the empty/zero shape so a typo can't accidentally inflate
* a metric.
*
* @return array<string, mixed>
* @return CoverageResult
*/
private static function counts(
int $endpointFullyCovered,
Expand Down
6 changes: 5 additions & 1 deletion tests/Unit/Coverage/HtmlCoverageRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use PHPUnit\Framework\TestCase;
use Studio\OpenApiContractTesting\Coverage\EndpointCoverageState;
use Studio\OpenApiContractTesting\Coverage\HtmlCoverageRenderer;
use Studio\OpenApiContractTesting\Coverage\OpenApiCoverageTracker;
use Studio\OpenApiContractTesting\Coverage\ResponseCoverageState;

use function array_unique;
Expand All @@ -16,6 +17,9 @@
use function sort;
use function substr_count;

/**
* @phpstan-import-type EndpointSummary from OpenApiCoverageTracker
*/
class HtmlCoverageRendererTest extends TestCase
{
#[Test]
Expand Down Expand Up @@ -560,7 +564,7 @@ private static function row(
}

/**
* @param array<string, mixed> $endpoint
* @param EndpointSummary $endpoint
*/
private function renderOne(
string $specName,
Expand Down
6 changes: 5 additions & 1 deletion tests/Unit/Coverage/JUnitCoverageRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
use SimpleXMLElement;
use Studio\OpenApiContractTesting\Coverage\EndpointCoverageState;
use Studio\OpenApiContractTesting\Coverage\JUnitCoverageRenderer;
use Studio\OpenApiContractTesting\Coverage\OpenApiCoverageTracker;
use Studio\OpenApiContractTesting\Coverage\ResponseCoverageState;

use function explode;
use function simplexml_load_string;

/**
* @phpstan-import-type EndpointSummary from OpenApiCoverageTracker
*/
class JUnitCoverageRendererTest extends TestCase
{
#[Test]
Expand Down Expand Up @@ -388,7 +392,7 @@ private static function row(
/**
* Convenience: render a single-endpoint coverage result for a single spec.
*
* @param array<string, mixed> $endpoint
* @param EndpointSummary $endpoint
*/
private function renderOne(
string $specName,
Expand Down
6 changes: 5 additions & 1 deletion tests/Unit/Coverage/JsonCoverageRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@
use PHPUnit\Framework\TestCase;
use Studio\OpenApiContractTesting\Coverage\EndpointCoverageState;
use Studio\OpenApiContractTesting\Coverage\JsonCoverageRenderer;
use Studio\OpenApiContractTesting\Coverage\OpenApiCoverageTracker;
use Studio\OpenApiContractTesting\Coverage\ResponseCoverageState;

use function array_keys;
use function explode;
use function is_array;
use function json_decode;

/**
* @phpstan-import-type CoverageResult from OpenApiCoverageTracker
*/
class JsonCoverageRendererTest extends TestCase
{
private const FIXED_TIMESTAMP = '2026-05-11T12:34:56+00:00';
Expand Down Expand Up @@ -442,7 +446,7 @@ private function renderOneValidated(): string
}

/**
* @return array<string, array<string, mixed>>
* @return array<string, CoverageResult>
*/
private function oneSpecResults(): array
{
Expand Down
13 changes: 9 additions & 4 deletions tests/Unit/Coverage/MarkdownCoverageRendererLintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use PHPUnit\Framework\TestCase;
use Studio\OpenApiContractTesting\Coverage\EndpointCoverageState;
use Studio\OpenApiContractTesting\Coverage\MarkdownCoverageRenderer;
use Studio\OpenApiContractTesting\Coverage\OpenApiCoverageTracker;
use Studio\OpenApiContractTesting\Coverage\ResponseCoverageState;

use function dirname;
Expand All @@ -23,6 +24,10 @@
use function tempnam;
use function unlink;

/**
* @phpstan-import-type CoverageResult from OpenApiCoverageTracker
* @phpstan-import-type EndpointSummary from OpenApiCoverageTracker
*/
final class MarkdownCoverageRendererLintTest extends TestCase
{
#[Test]
Expand All @@ -38,7 +43,7 @@ public function edge_cases_rendered_markdown_passes_markdownlint(): void
}

/**
* @return array<string, array<string, mixed>>
* @return array<string, CoverageResult>
*/
private static function standardFixture(): array
{
Expand Down Expand Up @@ -88,7 +93,7 @@ private static function standardFixture(): array
}

/**
* @return array<string, array<string, mixed>>
* @return array<string, CoverageResult>
*/
private static function edgeCasesFixture(): array
{
Expand Down Expand Up @@ -137,7 +142,7 @@ private static function edgeCasesFixture(): array
* @param list<array{statusKey: string, contentTypeKey: string, state: ResponseCoverageState, hits: int, skipReason: ?string}> $responses
* @param list<array{statusKey: string, contentTypeKey: string}> $unexpectedObservations
*
* @return array<string, mixed>
* @return EndpointSummary
*/
private static function endpoint(
string $endpoint,
Expand Down Expand Up @@ -187,7 +192,7 @@ private static function row(
}

/**
* @param array<string, array<string, mixed>> $results
* @param array<string, CoverageResult> $results
*/
private function assertRenderedMarkdownPassesLint(array $results): void
{
Expand Down
Loading