Skip to content

Commit

Permalink
clearer looking DocumentationTest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubKermes committed Jul 10, 2024
1 parent 72f0854 commit c7dad78
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions tests/DocumentationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ public function testIfDocumentationContainsAllPublicFunctions(): void
$fileName = Str::kebab(end($trait)) . ".html";
$filePath = "docs/elements/$fileName";

if (!file_exists($filePath)) {
if (str_ends_with($filePath, "http-request.html")) {
$filePath = str_replace("http-request.html", "http.html", $filePath);
} elseif (str_ends_with($filePath, "http-response.html")) {
$filePath = str_replace("http-response.html", "http.html", $filePath);
$replacements = [
"http-request.html" => "http.html",
"http-response.html" => "http.html",
];

foreach ($replacements as $search => $replacement) {
if (str_contains( $filePath, $search)) {
$filePath = str_replace($search, $replacement, $filePath);
}
}

if (!file_exists($filePath)) {
$this->fail("Documentation file $filePath does not exist.");
}
if (!file_exists($filePath)) {
$this->fail("Documentation file $filePath does not exist.");
}

$fileContent = file_get_contents($filePath);
Expand All @@ -35,7 +38,7 @@ public function testIfDocumentationContainsAllPublicFunctions(): void
}

foreach ($methods as $method) {
$containsFunction = strpos($fileContent, $method) !== false;
$containsFunction = str_contains($fileContent, $method) !== false;
$this->assertTrue($containsFunction, "Function $method is not documented in $filePath.");
}
}
Expand Down

0 comments on commit c7dad78

Please sign in to comment.