Skip to content

Commit bff262f

Browse files
committed
add failing test
1 parent 93595cf commit bff262f

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

tests/system/Test/FeatureTestTraitTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use CodeIgniter\Config\Factories;
1717
use CodeIgniter\Events\Events;
1818
use CodeIgniter\Exceptions\PageNotFoundException;
19+
use CodeIgniter\Exceptions\RuntimeException;
1920
use CodeIgniter\HTTP\Method;
2021
use CodeIgniter\HTTP\Response;
2122
use CodeIgniter\Test\Mock\MockCodeIgniter;
@@ -689,4 +690,33 @@ public function testForceGlobalSecureRequests(): void
689690
// Do not redirect.
690691
$response->assertStatus(200);
691692
}
693+
694+
#[DataProvider('provideWithRoutesWithInvalidMethod')]
695+
public function testWithRoutesWithInvalidMethod(string $method): void
696+
{
697+
$this->expectException(RuntimeException::class);
698+
$this->expectExceptionMessage(sprintf('Invalid HTTP method "%s" provided for route "home".', $method));
699+
700+
$this->withRoutes([
701+
[
702+
$method,
703+
'home',
704+
static fn (): string => 'Hello World',
705+
],
706+
]);
707+
}
708+
709+
/**
710+
* @return iterable<string, array{0: string}>
711+
*/
712+
public static function provideWithRoutesWithInvalidMethod(): iterable
713+
{
714+
foreach (['ADD', 'CLI', ...Method::all()] as $method) {
715+
yield "wrong {$method}" => [$method . 'S'];
716+
}
717+
718+
yield 'route collection addRedirect' => ['addRedirect'];
719+
720+
yield 'route collection setHTTPVerb' => ['setHTTPVerb'];
721+
}
692722
}

0 commit comments

Comments
 (0)