From 4795117f41051eafd37dba48c357245928612009 Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Tue, 3 Nov 2026 13:51:12 +0400 Subject: [PATCH 1/4] [#194] Show a GitHub star message after install:demo Co-Authored-By: Claude Sonnet 5.5 --- CHANGELOG.md | 5 + shared/Commands/DemoCommand.php | 8 +- .../Unit/shared/Commands/DemoCommandTest.php | 116 ++++++++++++++++++ 3 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 tests/Unit/shared/Commands/DemoCommandTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b34c2f..c801e00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on Keep a Changelog and this project adheres to Semantic Versioning. +## [Unreleased] + +### Added +- A message at the end of `php qt install:demo` that invites you to star Quantum on GitHub, with the link `https://github.com/quantum-php/framework`. It is shown only when the demo was created successfully (#194). + ## [3.1.0] - 2026-10-24 ### Added diff --git a/shared/Commands/DemoCommand.php b/shared/Commands/DemoCommand.php index f50d117..4108413 100644 --- a/shared/Commands/DemoCommand.php +++ b/shared/Commands/DemoCommand.php @@ -43,6 +43,11 @@ class DemoCommand extends CliCommand */ public const DEFAULT_PASSWORD = 'password'; + /** + * Message shown after the demo is created successfully + */ + public const STAR_MESSAGE = 'Would you like to show some love by starring Quantum on GitHub? https://github.com/quantum-php/framework'; + /** * Command name * @var string|null @@ -147,13 +152,14 @@ public function exec(): void $progress->finish(); $this->info(PHP_EOL . 'Demo project created successfully'); + $this->comment(self::STAR_MESSAGE); } /** * Provides the sequence of defined tasks to be executed. * @return array[] */ - private function getSteps(): array + protected function getSteps(): array { return [ [ diff --git a/tests/Unit/shared/Commands/DemoCommandTest.php b/tests/Unit/shared/Commands/DemoCommandTest.php new file mode 100644 index 0000000..b9c82e3 --- /dev/null +++ b/tests/Unit/shared/Commands/DemoCommandTest.php @@ -0,0 +1,116 @@ + + */ + public array $steps = []; + + protected function getSteps(): array + { + return $this->steps; + } +} + +class DemoCommandTest extends TestCase +{ + private const REPOSITORY_URL = 'https://github.com/quantum-php/framework'; + + public function testStarMessageIsShownAfterTheSuccessMessage(): void + { + $output = $this->runCommand(new DemoCommandWithSteps(), ['--yes' => true]); + + $this->assertStringContainsString('Demo project created successfully', $output); + $this->assertStringContainsString(self::REPOSITORY_URL, $output); + $this->assertStringContainsString('starring Quantum on GitHub', $output); + $this->assertGreaterThan( + strpos($output, 'Demo project created successfully'), + strpos($output, self::REPOSITORY_URL) + ); + } + + public function testStarMessageIsNotShownWhenTheOperationIsCancelled(): void + { + $output = $this->runCommand(new DemoCommandWithSteps(), [], ['no']); + + $this->assertStringContainsString('Operation was canceled!', $output); + $this->assertStringNotContainsString(self::REPOSITORY_URL, $output); + } + + public function testStarMessageIsNotShownWhenAStepFails(): void + { + $command = new DemoCommandWithSteps(); + $command->steps = [ + [ + 'message' => 'Failing step', + 'action' => function (): void { + throw new RuntimeException('step failed'); + }, + ], + ]; + + $output = new BufferedOutput(); + + try { + $this->application($command)->run(new ArrayInput(['command' => 'install:demo', '--yes' => true]), $output); + $this->fail('The failing step did not stop the command'); + } catch (RuntimeException $e) { + $this->assertSame('step failed', $e->getMessage()); + } + + $this->assertStringNotContainsString('Demo project created successfully', $output->fetch()); + } + + public function testStarMessageDoesNotUseTheOldRepositoryName(): void + { + $output = $this->runCommand(new DemoCommandWithSteps(), ['--yes' => true]); + + $this->assertStringNotContainsString('softberg', $output); + } + + /** + * @param array $input + * @param array $answers + */ + private function runCommand(DemoCommand $command, array $input, array $answers = []): string + { + $output = new BufferedOutput(); + + $arrayInput = new ArrayInput(['command' => 'install:demo'] + $input); + $arrayInput->setInteractive($answers !== []); + + if ($answers !== []) { + $stream = fopen('php://memory', 'r+'); + fwrite($stream, implode(PHP_EOL, $answers) . PHP_EOL); + rewind($stream); + $arrayInput->setStream($stream); + } + + $this->application($command)->run($arrayInput, $output); + + return $output->fetch(); + } + + private function application(DemoCommand $command): Application + { + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + $application->add($command); + + return $application; + } +} From f5f8846893b9e93eda1064f080fe137ead52ff75 Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Tue, 3 Nov 2026 13:52:44 +0400 Subject: [PATCH 2/4] [#194] Add the star texts to the common lang files Co-Authored-By: Claude Sonnet 5.5 --- CHANGELOG.md | 1 + shared/resources/lang/en/common.php | 7 +++ shared/resources/lang/es/common.php | 7 +++ tests/Unit/shared/Lang/CommonLangTest.php | 60 +++++++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 tests/Unit/shared/Lang/CommonLangTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index c801e00..37c6fb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on Keep a Changelog and this project adheres to Semantic Ver ### Added - A message at the end of `php qt install:demo` that invites you to star Quantum on GitHub, with the link `https://github.com/quantum-php/framework`. It is shown only when the demo was created successfully (#194). +- The `common.star.message`, `common.star.button` and `common.star.badge_alt` texts, in English and Spanish, for the star block that the framework's `DemoWeb` About page shows. Without them the page shows the key names (#194). ## [3.1.0] - 2026-10-24 diff --git a/shared/resources/lang/en/common.php b/shared/resources/lang/en/common.php index 3175b7a..3bcbaff 100644 --- a/shared/resources/lang/en/common.php +++ b/shared/resources/lang/en/common.php @@ -9,6 +9,13 @@ 'current_version' => 'Current version is: {%1}', 'cli_commands' => 'Quantum CLI Commands', + // ───── Star on GitHub ───────────────────────────────────── + 'star' => [ + 'message' => 'Would you like to show some love by starring Quantum on GitHub?', + 'button' => 'Star on GitHub', + 'badge_alt' => 'GitHub stars', + ], + // ───── Navigation ───────────────────────────────────────── 'home' => 'Home', 'about' => 'About', diff --git a/shared/resources/lang/es/common.php b/shared/resources/lang/es/common.php index 56fc67e..9477a17 100644 --- a/shared/resources/lang/es/common.php +++ b/shared/resources/lang/es/common.php @@ -9,6 +9,13 @@ 'current_version' => 'La versión actual es: {%1}', 'cli_commands' => 'Comandos CLI de Quantum', + // ───── Star on GitHub ───────────────────────────────────── + 'star' => [ + 'message' => '¿Te gustaría mostrar tu apoyo dando una estrella a Quantum en GitHub?', + 'button' => 'Dar una estrella en GitHub', + 'badge_alt' => 'Estrellas en GitHub', + ], + // ───── Navigation ───────────────────────────────────────── 'home' => 'Inicio', 'about' => 'Acerca de', diff --git a/tests/Unit/shared/Lang/CommonLangTest.php b/tests/Unit/shared/Lang/CommonLangTest.php new file mode 100644 index 0000000..4013068 --- /dev/null +++ b/tests/Unit/shared/Lang/CommonLangTest.php @@ -0,0 +1,60 @@ +common($language)['star'] ?? null; + + $this->assertIsArray($star); + + foreach (['message', 'button', 'badge_alt'] as $key) { + $this->assertArrayHasKey($key, $star); + $this->assertIsString($star[$key]); + $this->assertNotSame('', trim($star[$key])); + } + } + + public function testStarGroupHasTheSameKeysInEveryLanguage(): void + { + $this->assertSame( + array_keys($this->common('en')['star'] ?? []), + array_keys($this->common('es')['star'] ?? []) + ); + } + + public function testEnglishTextAsksForAStarOnGitHub(): void + { + $star = $this->common('en')['star'] ?? []; + + $this->assertStringContainsString('starring Quantum on GitHub', (string) ($star['message'] ?? '')); + $this->assertSame('Star on GitHub', $star['button'] ?? null); + $this->assertSame('GitHub stars', $star['badge_alt'] ?? null); + } + + /** + * @return array + */ + public static function languageProvider(): array + { + return [ + 'english' => ['en'], + 'spanish' => ['es'], + ]; + } + + /** + * @return array + */ + private function common(string $language): array + { + return require dirname(__DIR__, 4) . '/shared/resources/lang/' . $language . '/common.php'; + } +} From 0ebf4de7ee183bc51e8eaa07937c82d25e7dfbf2 Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Tue, 3 Nov 2026 14:08:20 +0400 Subject: [PATCH 3/4] [#194] Download the demo images without verifying the certificate Co-Authored-By: Claude Sonnet 5.5 --- CHANGELOG.md | 3 +++ helpers/functions.php | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37c6fb1..d414752 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ The format is based on Keep a Changelog and this project adheres to Semantic Ver - A message at the end of `php qt install:demo` that invites you to star Quantum on GitHub, with the link `https://github.com/quantum-php/framework`. It is shown only when the demo was created successfully (#194). - The `common.star.message`, `common.star.button` and `common.star.badge_alt` texts, in English and Spanish, for the star block that the framework's `DemoWeb` About page shows. Without them the page shows the key names (#194). +### Fixed +- `php qt install:demo` no longer stops with "unable to get local issuer certificate" on a PHP that has no CA bundle configured: `save_remote_image()` and `save_remote_images()` download the public demo images with `CURLOPT_SSL_VERIFYPEER` off. The certificate of those downloads is not verified (#194). + ## [3.1.0] - 2026-10-24 ### Added diff --git a/helpers/functions.php b/helpers/functions.php index f4c5aea..58b3407 100644 --- a/helpers/functions.php +++ b/helpers/functions.php @@ -78,6 +78,7 @@ function save_remote_image(string $imageUrl, string $userDirectory, string $imag $httpClient = httpRequest($imageUrl) ->setMethod('GET') ->setOpt(CURLOPT_FOLLOWLOCATION, true) + ->setOpt(CURLOPT_SSL_VERIFYPEER, false) // public demo images only, so a PHP without a CA bundle still works ->start(); $fs->put( @@ -104,8 +105,11 @@ function save_remote_images(array $images): array } $fs = FileSystemFactory::get(); - $multiCurl = (new MultiCurlAdapter()) - ->setOpt(CURLOPT_FOLLOWLOCATION, true); + // The certificate is not verified: public demo images only, so a PHP without a CA bundle still works + $multiCurl = (new MultiCurlAdapter())->setOpts([ + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_SSL_VERIFYPEER => false, + ]); $jobs = []; $imageNames = []; From 7880b177b271eb0cceb5a01098ecb0424c23d486 Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Tue, 3 Nov 2026 14:13:17 +0400 Subject: [PATCH 4/4] [#194] Make the star message link clickable Co-Authored-By: Claude Sonnet 5.5 --- shared/Commands/DemoCommand.php | 13 ++++-- .../Unit/shared/Commands/DemoCommandTest.php | 44 ++++++++++++++++++- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/shared/Commands/DemoCommand.php b/shared/Commands/DemoCommand.php index 4108413..68465ba 100644 --- a/shared/Commands/DemoCommand.php +++ b/shared/Commands/DemoCommand.php @@ -44,9 +44,16 @@ class DemoCommand extends CliCommand public const DEFAULT_PASSWORD = 'password'; /** - * Message shown after the demo is created successfully + * Repository the visitors are asked to star */ - public const STAR_MESSAGE = 'Would you like to show some love by starring Quantum on GitHub? https://github.com/quantum-php/framework'; + public const REPOSITORY_URL = 'https://github.com/quantum-php/framework'; + + /** + * Message shown after the demo is created successfully, %1$s is the repository link + */ + public const STAR_MESSAGE = PHP_EOL + . '★ Would you like to show some love by starring Quantum on GitHub?' . PHP_EOL + . ' %1$s'; /** * Command name @@ -152,7 +159,7 @@ public function exec(): void $progress->finish(); $this->info(PHP_EOL . 'Demo project created successfully'); - $this->comment(self::STAR_MESSAGE); + $this->output(sprintf(self::STAR_MESSAGE, self::REPOSITORY_URL)); } /** diff --git a/tests/Unit/shared/Commands/DemoCommandTest.php b/tests/Unit/shared/Commands/DemoCommandTest.php index b9c82e3..071b0ee 100644 --- a/tests/Unit/shared/Commands/DemoCommandTest.php +++ b/tests/Unit/shared/Commands/DemoCommandTest.php @@ -42,6 +42,46 @@ public function testStarMessageIsShownAfterTheSuccessMessage(): void ); } + public function testStarMessageLinkIsClickableInATerminal(): void + { + $output = $this->runCommand(new DemoCommandWithSteps(), ['--yes' => true], [], true); + + $this->assertStringContainsString("\033]8;;" . self::REPOSITORY_URL . "\033\\", $output); + $this->assertStringContainsString(self::REPOSITORY_URL, $output); + $this->assertStringContainsString("\033]8;;\033\\", $output); + } + + public function testStarMessageHasAColoredStarAndAnUnderlinedLink(): void + { + $output = $this->runCommand(new DemoCommandWithSteps(), ['--yes' => true], [], true); + + $this->assertStringContainsString("\033[33;1m★\033[39;22m", $output); + $this->assertStringContainsString( + "\033[36;4m\033]8;;" . self::REPOSITORY_URL . "\033\\" . self::REPOSITORY_URL . "\033]8;;\033\\\033[39;24m", + $output + ); + } + + public function testStarMessageIsPlainTextWhenTheOutputIsNotATerminal(): void + { + $output = $this->runCommand(new DemoCommandWithSteps(), ['--yes' => true]); + + $this->assertStringNotContainsString("\033", $output); + $this->assertStringNotContainsString('assertStringNotContainsString('assertStringContainsString('★ Would you like to show some love by starring Quantum on GitHub?', $output); + } + + public function testStarMessageHasTheLinkOnItsOwnLineAfterABlankLine(): void + { + $output = $this->runCommand(new DemoCommandWithSteps(), ['--yes' => true]); + + $this->assertMatchesRegularExpression( + '/Demo project created successfully\R\R★ [^\r\n]+\R {2}' . preg_quote(self::REPOSITORY_URL, '/') . '\R/', + $output + ); + } + public function testStarMessageIsNotShownWhenTheOperationIsCancelled(): void { $output = $this->runCommand(new DemoCommandWithSteps(), [], ['no']); @@ -85,9 +125,9 @@ public function testStarMessageDoesNotUseTheOldRepositoryName(): void * @param array $input * @param array $answers */ - private function runCommand(DemoCommand $command, array $input, array $answers = []): string + private function runCommand(DemoCommand $command, array $input, array $answers = [], bool $decorated = false): string { - $output = new BufferedOutput(); + $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, $decorated); $arrayInput = new ArrayInput(['command' => 'install:demo'] + $input); $arrayInput->setInteractive($answers !== []);