From 2f496911e3936a2ccb278c71285cf55aec2a047c Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Tue, 3 Nov 2026 13:12:02 +0400 Subject: [PATCH 1/2] [#542] Add a GitHub star message to the DemoWeb About page Co-Authored-By: Claude Sonnet 5.5 --- CHANGELOG.md | 1 + .../DemoWeb/src/Views/pages/about.php.tpl | 6 ++ .../Module/Templates/AboutTemplateTest.php | 61 +++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 tests/Unit/Module/Templates/AboutTemplateTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 520d5b8a9..0235d45b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on Keep a Changelog. ### Added - Added `Response::back()` and the `back()` helper, which redirect to the referrer and fall back to `base_url()` when the request has none, or when the referrer is not on the application origin (same scheme, host and port), which is compared with `base_url()`: behind a proxy that terminates TLS, or where the `Host` header is not pinned, set `app.base_url`. They take the old input to keep for the next request, read with `old()` as after `redirectWith()`, and an optional status code (`back($data, $code)`) (#540) +- The `DemoWeb` About page asks visitors to star Quantum on GitHub, at the top of the page: a button that links to `https://github.com/quantum-php/framework`, with the current star count from a shields.io badge, which the browser loads from the internet. Modules generated before keep their page (#542) ### Changed - **BREAKING:** Converted the constant classes `ReservedKeys`, `AuthKeys`, `Pagination` and the database `Type`, `Key` and `Relation` to PHP enums, and moved the table actions of `Table` into the new `TableAction` enum (#612). An enum case is not its value, so code that needs the text or number reads `->value`, and text that comes from outside is turned into a case with `::from()` or `::tryFrom()`: diff --git a/src/Module/Templates/DemoWeb/src/Views/pages/about.php.tpl b/src/Module/Templates/DemoWeb/src/Views/pages/about.php.tpl index 4570abaec..83d23409a 100644 --- a/src/Module/Templates/DemoWeb/src/Views/pages/about.php.tpl +++ b/src/Module/Templates/DemoWeb/src/Views/pages/about.php.tpl @@ -4,6 +4,12 @@
+
+
Would you like to show some love by starring Quantum on GitHub?
+ Star on GitHub + GitHub stars +
+

diff --git a/tests/Unit/Module/Templates/AboutTemplateTest.php b/tests/Unit/Module/Templates/AboutTemplateTest.php new file mode 100644 index 000000000..731a7821d --- /dev/null +++ b/tests/Unit/Module/Templates/AboutTemplateTest.php @@ -0,0 +1,61 @@ +template = (string) file_get_contents( + dirname(__DIR__, 4) . '/src/Module/Templates/DemoWeb/src/Views/pages/about.php.tpl' + ); + } + + public function testAboutPageAsksForAStarOnGitHub(): void + { + $this->assertStringContainsString('starring Quantum on GitHub', $this->template); + } + + public function testAboutPageLinksToTheFrameworkRepository(): void + { + $this->assertMatchesRegularExpression( + '#]*href="https://github\.com/quantum-php/framework"[^>]*>#', + $this->template + ); + } + + public function testStarLinkOpensInANewTabSafely(): void + { + $this->assertMatchesRegularExpression( + '#]*href="https://github\.com/quantum-php/framework"[^>]*target="_blank"[^>]*rel="noopener noreferrer"[^>]*>#', + $this->template + ); + } + + public function testAboutPageShowsTheStarCountBadge(): void + { + $this->assertMatchesRegularExpression( + '#]*src="https://img\.shields\.io/github/stars/quantum-php/framework[^"]*"[^>]*alt="GitHub stars"[^>]*>#', + $this->template + ); + } + + public function testStarMessageComesBeforeTheCliCommands(): void + { + $star = strpos($this->template, 'starring Quantum on GitHub'); + $commands = strpos($this->template, 'common.cli_commands'); + + $this->assertNotFalse($star); + $this->assertNotFalse($commands); + $this->assertLessThan($commands, $star); + } + + public function testAboutPageDoesNotUseTheOldRepositoryName(): void + { + $this->assertStringNotContainsString('softberg', $this->template); + } +} From b6626fe9e97eff32d63c8e69bf8b069b6cfa20bb Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Tue, 3 Nov 2026 13:37:54 +0400 Subject: [PATCH 2/2] [#542] Translate the star message on the DemoWeb About page Co-Authored-By: Claude Sonnet 5.5 --- CHANGELOG.md | 2 +- .../DemoWeb/src/Views/pages/about.php.tpl | 6 +++--- .../Unit/Module/Templates/AboutTemplateTest.php | 17 +++++++++++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0235d45b7..b798bb369 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ The format is based on Keep a Changelog. ### Added - Added `Response::back()` and the `back()` helper, which redirect to the referrer and fall back to `base_url()` when the request has none, or when the referrer is not on the application origin (same scheme, host and port), which is compared with `base_url()`: behind a proxy that terminates TLS, or where the `Host` header is not pinned, set `app.base_url`. They take the old input to keep for the next request, read with `old()` as after `redirectWith()`, and an optional status code (`back($data, $code)`) (#540) -- The `DemoWeb` About page asks visitors to star Quantum on GitHub, at the top of the page: a button that links to `https://github.com/quantum-php/framework`, with the current star count from a shields.io badge, which the browser loads from the internet. Modules generated before keep their page (#542) +- The `DemoWeb` About page asks visitors to star Quantum on GitHub, at the top of the page: a button that links to `https://github.com/quantum-php/framework`, with the current star count from a shields.io badge, which the browser loads from the internet. The texts are translation keys, `common.star.message`, `common.star.button` and `common.star.badge_alt`, which the starter project adds to its `common` lang files in English and Spanish; until a project has them the page shows the key names. Modules generated before keep their page (#542) ### Changed - **BREAKING:** Converted the constant classes `ReservedKeys`, `AuthKeys`, `Pagination` and the database `Type`, `Key` and `Relation` to PHP enums, and moved the table actions of `Table` into the new `TableAction` enum (#612). An enum case is not its value, so code that needs the text or number reads `->value`, and text that comes from outside is turned into a case with `::from()` or `::tryFrom()`: diff --git a/src/Module/Templates/DemoWeb/src/Views/pages/about.php.tpl b/src/Module/Templates/DemoWeb/src/Views/pages/about.php.tpl index 83d23409a..d22ac626f 100644 --- a/src/Module/Templates/DemoWeb/src/Views/pages/about.php.tpl +++ b/src/Module/Templates/DemoWeb/src/Views/pages/about.php.tpl @@ -5,9 +5,9 @@
diff --git a/tests/Unit/Module/Templates/AboutTemplateTest.php b/tests/Unit/Module/Templates/AboutTemplateTest.php index 731a7821d..8bb29dd9a 100644 --- a/tests/Unit/Module/Templates/AboutTemplateTest.php +++ b/tests/Unit/Module/Templates/AboutTemplateTest.php @@ -15,9 +15,18 @@ public function setUp(): void ); } - public function testAboutPageAsksForAStarOnGitHub(): void + public function testStarTextsAreTranslated(): void { - $this->assertStringContainsString('starring Quantum on GitHub', $this->template); + $this->assertStringContainsString("_t('common.star.message')", $this->template); + $this->assertStringContainsString("_t('common.star.button')", $this->template); + $this->assertStringContainsString("_t('common.star.badge_alt')", $this->template); + } + + public function testAboutPageHasNoHardCodedStarText(): void + { + $this->assertStringNotContainsString('starring Quantum', $this->template); + $this->assertStringNotContainsString('Star on GitHub', $this->template); + $this->assertStringNotContainsString('alt="GitHub stars"', $this->template); } public function testAboutPageLinksToTheFrameworkRepository(): void @@ -39,14 +48,14 @@ public function testStarLinkOpensInANewTabSafely(): void public function testAboutPageShowsTheStarCountBadge(): void { $this->assertMatchesRegularExpression( - '#]*src="https://img\.shields\.io/github/stars/quantum-php/framework[^"]*"[^>]*alt="GitHub stars"[^>]*>#', + '#]*src="https://img\.shields\.io/github/stars/quantum-php/framework[^"]*"[^>]*alt="<\?php _t\(\'common\.star\.badge_alt\'\); \?>"[^>]*>#', $this->template ); } public function testStarMessageComesBeforeTheCliCommands(): void { - $star = strpos($this->template, 'starring Quantum on GitHub'); + $star = strpos($this->template, "_t('common.star.message')"); $commands = strpos($this->template, 'common.cli_commands'); $this->assertNotFalse($star);