Skip to content

Commit 936178e

Browse files
committed
test: fix tests after refactoring
1 parent 0df644d commit 936178e

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/Path/DynamicPath.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ public function get(?string $key = null, bool $extra = false):?string {
3636
}
3737

3838
if($this->matchesKey($f, $key)) {
39-
return $this->getMatchedKey(
39+
$matchedKey = $this->getMatchedKey(
4040
$requestPathParts,
4141
$i,
4242
);
43+
if(!$matchedKey) {
44+
continue;
45+
}
46+
return $matchedKey;
4347
}
4448
}
4549
}
@@ -88,7 +92,11 @@ private function getMatchedKey(
8892
array $requestPathParts,
8993
int $index,
9094
):?string {
91-
return $requestPathParts[$index] ?? null;
95+
$matchedKey = $requestPathParts[$index] ?? null;
96+
if(!$matchedKey) {
97+
return null;
98+
}
99+
return $matchedKey;
92100
}
93101

94102
public function getUrl(string $viewBasePath):string {

src/Redirects.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function __construct(SplFileObject|string $file) {
1818
$this->redirectData = [];
1919

2020
while(!$file->eof()) {
21-
$row = $file->fgetcsv();
21+
$row = $file->fgetcsv(escape: "\\");
2222
if(!isset($row[1])) {
2323
continue;
2424
}

test/phpunit/RedirectsTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ public function testIterate_empty():void {
1717

1818
public function testIterate():void {
1919
$file = new SplFileObject("php://memory", "w");
20-
$file->fputcsv(["from1", "to1"]);
21-
$file->fputcsv(["from2", "to2"]);
22-
$file->fputcsv(["from3", "to3"]);
20+
$file->fputcsv(["from1", "to1"], escape: "\\");
21+
$file->fputcsv(["from2", "to2"], escape: "\\");
22+
$file->fputcsv(["from3", "to3"], escape: "\\");
2323

2424
$sut = new Redirects($file);
2525
$i = 0;

0 commit comments

Comments
 (0)