Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "HydePHP" as the application logo when running without ANSI formatting #1288

Merged
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ This serves two purposes:

### Fixed
- Fixed "ReadingTime calculation should never be under one minute" [#1286](https://github.com/hydephp/develop/issues/1286) in [#1285](https://github.com/hydephp/develop/pull/1285)
- Fixed "The HydeCLI list command logo should respect the --no-ansi setting" [#1127](https://github.com/hydephp/develop/issues/1127) in [#1288](https://github.com/hydephp/develop/pull/1288)

### Security
- in case of vulnerabilities.
5 changes: 5 additions & 0 deletions packages/framework/src/Console/ConsoleServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public function register(): void

protected static function logo(): string
{
// Check if no-ansi flag is set
if (isset($_SERVER['argv']) && in_array('--no-ansi', $_SERVER['argv'], true)) {
return 'HydePHP';
}

return <<<ASCII

\033[34m __ __ __ \033[33m ___ __ _____
Expand Down
47 changes: 47 additions & 0 deletions packages/framework/tests/Unit/ConsoleServiceProviderUnitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

declare(strict_types=1);

namespace Hyde\Framework\Testing\Unit;

use Hyde\Console\ConsoleServiceProvider;
use Hyde\Testing\UnitTestCase;

/**
* @covers \Hyde\Console\ConsoleServiceProvider
*/
class ConsoleServiceProviderUnitTest extends UnitTestCase
{
public function testProviderRegistersLogo()
{
$this->assertSame(<<<ASCII

\033[34m __ __ __ \033[33m ___ __ _____
\033[34m / // /_ _____/ /__ \033[33m/ _ \/ // / _ \
\033[34m / _ / // / _ / -_)\033[33m ___/ _ / ___/
\033[34m /_//_/\_, /\_,_/\__/\033[33m_/ /_//_/_/
\033[34m /___/

\033[0m
ASCII, ConsoleServiceProviderTestClass::logo());
}

public function testProviderRegistersNoAnsiLogo()
{
$serverBackup = $_SERVER;

$_SERVER['argv'] = ['--no-ansi'];

$this->assertSame('HydePHP', ConsoleServiceProviderTestClass::logo());

$_SERVER = $serverBackup;
}
}

class ConsoleServiceProviderTestClass extends ConsoleServiceProvider
{
public static function logo(): string
{
return parent::logo();
}
}