File tree Expand file tree Collapse file tree
tests/php/Controller/Backend Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222 <env name =" CORS_ALLOW_ORIGIN" value =" ^https?://localhost(:[0-9]+)?$" />
2323 <!-- ###- nelmio/cors-bundle ### -->
2424 <!-- ###+ symfony/mailer ### -->
25- <!-- MAILER_DSN=smtp ://localhost -- >
25+ <env name = " MAILER_DSN" value = " null ://null " / >
2626 <!-- ###- symfony/mailer ### -->
2727 </php >
2828 <testsuites >
Original file line number Diff line number Diff line change @@ -58,6 +58,16 @@ public function setRequest(?Request $request = null): void
5858
5959 $ requestUrl = parse_url ($ this ->request ->getSchemeAndHttpHost ());
6060
61+ // Handle test environment or malformed URLs
62+ if ($ requestUrl === false || !isset ($ requestUrl ['scheme ' ])) {
63+ $ this ->setScheme ('http ' );
64+ $ this ->setHost ('localhost ' );
65+ $ this ->setPort (null );
66+ $ _SERVER ['CANONICAL_HOST ' ] = 'localhost ' ;
67+ $ _SERVER ['CANONICAL_SCHEME ' ] = 'http ' ;
68+ return ;
69+ }
70+
6171 $ configCanonical = (string ) $ this ->config ->get ('general/canonical ' , $ this ->getRequest ()->getSchemeAndHttpHost ());
6272
6373 if (mb_strpos ($ configCanonical , 'http ' ) !== 0 ) {
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Bolt \Tests \Controller \Backend ;
6+
7+ use Bolt \Tests \DbAwareTestCase ;
8+
9+ /**
10+ * Simple smoke test to verify password reset page loads successfully.
11+ *
12+ * This test was created after fixing a bug where navigating to the reset password
13+ * page caused a TypeError due to strict_types=1 enforcement when config->get()
14+ * returned DeepCollection instead of array
15+ *
16+ * The bug was in Canonical::setRequest() which didn't handle test environment properly,
17+ * causing parse_url() to return false/incomplete array, leading to TypeError when
18+ * trying to access array keys.
19+ */
20+ class ResetPasswordControllerTest extends DbAwareTestCase
21+ {
22+ /**
23+ * Test that the reset password page loads successfully.
24+ * This is the main regression test - the bug prevented this page from loading.
25+ */
26+ public function testResetPasswordPageLoads (): void
27+ {
28+ // Navigate directly to reset password page (this is what the "Forgotten password" link does)
29+ $ crawler = $ this ->client ->request ('GET ' , '/bolt/reset-password ' );
30+
31+ // Verify page loads successfully (this would fail with TypeError before the fix)
32+ $ this ->assertResponseIsSuccessful ();
33+ $ this ->assertRouteSame ('bolt_forgot_password_request ' );
34+
35+ // Verify the form exists with email input
36+ $ this ->assertSelectorExists ('form ' );
37+ $ this ->assertSelectorExists ('input[name="reset_password_request_form[email]"] ' );
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments