-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turns file paths seen in `Saved Source Files` into links that open those files right inside your browser Enable the `Zenstruck\Browser\Test\BrowserExtension` extension Configure the file link format with the environment variable `BROWSER_FILE_LINK_FORMAT`, the default value is `file://%f#L%l` Can be overloaded in the `phpunit.xml.dist` for example ``` <server name="BROWSER_FILE_LINK_FORMAT" value="'file://%f#L%l"/> ``` iUseful when running your app in a container or in a virtual machine, see Symfony doc https://symfony.com/doc/current/reference/configuration/framework.html#ide
- Loading branch information
LDA
committed
Feb 13, 2025
1 parent
28b7e1a
commit 910a290
Showing
2 changed files
with
15 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,15 @@ | |
|
||
namespace Zenstruck\Browser\Test; | ||
|
||
use Symfony\Component\ErrorHandler\ErrorRenderer\FileLinkFormatter; | ||
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter as LegacyFileLinkFormatter; | ||
use Zenstruck\Browser; | ||
|
||
if (!class_exists(FileLinkFormatter::class) && class_exists(LegacyFileLinkFormatter::class)) { | ||
class_alias(LegacyFileLinkFormatter::class, FileLinkFormatter::class); | ||
} | ||
|
||
|
||
/** | ||
* @author Kevin Bond <[email protected]> | ||
*/ | ||
|
@@ -24,6 +31,12 @@ class LegacyExtension | |
|
||
/** @var array<string,array<string,string[]>> */ | ||
private array $savedArtifacts = []; | ||
private FileLinkFormatter $fileLinkFormatter; | ||
|
||
public function __construct(FileLinkFormatter|null $fileLinkFormatter = null) | ||
{ | ||
$this->fileLinkFormatter = $fileLinkFormatter ?? new FileLinkFormatter($_ENV['BROWSER_FILE_LINK_FORMAT'] ?? $_SERVER['BROWSER_FILE_LINK_FORMAT'] ?? ''); | ||
} | ||
|
||
/** | ||
* @internal | ||
|
@@ -77,7 +90,7 @@ public function executeAfterLastTest(): void | |
echo "\n {$category}:"; | ||
|
||
foreach ($artifacts as $artifact) { | ||
echo "\n * {$artifact}:"; | ||
echo "\n * \033]8;;{$this->fileLinkFormatter->format(realpath($artifact) ?: '', 1)}\033\\$artifact\033]8;;\033\\"; | ||
} | ||
} | ||
} | ||
|