Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3582d68

Browse files
Merge branch '5.4' into 6.2
* 5.4: [Cache] Removing null coalescing assignment operator on 5.4 [Cache] Fix storing binary keys when using pgsql [FrameworkBundle] Add missing monolog channel tag for messenger services [FrameworkBundle] Improve documentation about translation:extract --sort option [VarDumper] Disable links for IntelliJ platform [Notifier] Add bridge documentation [HttpClient] Add hint about `timeout` and `max_duration` options [HttpFoundation] Use separate caches for IpUtils checkIp4 and checkIp6 [FrameworkBundle] Fix wiring session.handler when handler_id is null [FrameworkBundle] Workflow - Fix LogicException about a wrong configuration of "enabled" node
2 parents 85e2e03 + 3cd51fd commit 3582d68

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

Formatter/OutputFormatterStyle.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public function setOptions(array $options)
8383
public function apply(string $text): string
8484
{
8585
$this->handlesHrefGracefully ??= 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR')
86-
&& (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100);
86+
&& (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100)
87+
&& !isset($_SERVER['IDEA_INITIAL_DIRECTORY']);
8788

8889
if (null !== $this->href && $this->handlesHrefGracefully) {
8990
$text = "\033]8;;$this->href\033\\$text\033]8;;\033\\";

Tests/Formatter/OutputFormatterTest.php

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,10 @@ public function testFormatterHasStyles()
244244
/**
245245
* @dataProvider provideDecoratedAndNonDecoratedOutput
246246
*/
247-
public function testNotDecoratedFormatter(string $input, string $expectedNonDecoratedOutput, string $expectedDecoratedOutput, string $terminalEmulator = 'foo')
247+
public function testNotDecoratedFormatterOnJediTermEmulator(string $input, string $expectedNonDecoratedOutput, string $expectedDecoratedOutput, bool $shouldBeJediTerm = false)
248248
{
249+
$terminalEmulator = $shouldBeJediTerm ? 'JetBrains-JediTerm' : 'Unknown';
250+
249251
$prevTerminalEmulator = getenv('TERMINAL_EMULATOR');
250252
putenv('TERMINAL_EMULATOR='.$terminalEmulator);
251253

@@ -257,6 +259,35 @@ public function testNotDecoratedFormatter(string $input, string $expectedNonDeco
257259
}
258260
}
259261

262+
/**
263+
* @dataProvider provideDecoratedAndNonDecoratedOutput
264+
*/
265+
public function testNotDecoratedFormatterOnIDEALikeEnvironment(string $input, string $expectedNonDecoratedOutput, string $expectedDecoratedOutput, bool $expectsIDEALikeTerminal = false)
266+
{
267+
// Backup previous env variable
268+
$previousValue = $_SERVER['IDEA_INITIAL_DIRECTORY'] ?? null;
269+
$hasPreviousValue = \array_key_exists('IDEA_INITIAL_DIRECTORY', $_SERVER);
270+
271+
if ($expectsIDEALikeTerminal) {
272+
$_SERVER['IDEA_INITIAL_DIRECTORY'] = __DIR__;
273+
} elseif ($hasPreviousValue) {
274+
// Forcibly remove the variable because the test runner may contain it
275+
unset($_SERVER['IDEA_INITIAL_DIRECTORY']);
276+
}
277+
278+
try {
279+
$this->assertEquals($expectedDecoratedOutput, (new OutputFormatter(true))->format($input));
280+
$this->assertEquals($expectedNonDecoratedOutput, (new OutputFormatter(false))->format($input));
281+
} finally {
282+
// Rollback previous env state
283+
if ($hasPreviousValue) {
284+
$_SERVER['IDEA_INITIAL_DIRECTORY'] = $previousValue;
285+
} else {
286+
unset($_SERVER['IDEA_INITIAL_DIRECTORY']);
287+
}
288+
}
289+
}
290+
260291
public static function provideDecoratedAndNonDecoratedOutput()
261292
{
262293
return [
@@ -267,7 +298,7 @@ public static function provideDecoratedAndNonDecoratedOutput()
267298
['<fg=red>some text with inline style</>', 'some text with inline style', "\033[31msome text with inline style\033[39m"],
268299
['<href=idea://open/?file=/path/SomeFile.php&line=12>some URL</>', 'some URL', "\033]8;;idea://open/?file=/path/SomeFile.php&line=12\033\\some URL\033]8;;\033\\"],
269300
['<href=https://example.com/\<woohoo\>>some URL with \<woohoo\></>', 'some URL with <woohoo>', "\033]8;;https://example.com/<woohoo>\033\\some URL with <woohoo>\033]8;;\033\\"],
270-
['<href=idea://open/?file=/path/SomeFile.php&line=12>some URL</>', 'some URL', 'some URL', 'JetBrains-JediTerm'],
301+
['<href=idea://open/?file=/path/SomeFile.php&line=12>some URL</>', 'some URL', 'some URL', true],
271302
];
272303
}
273304

0 commit comments

Comments
 (0)