Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ concurrency:

jobs:
tests:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
php:
- '7.4'
- '8.0'
Expand Down
13 changes: 11 additions & 2 deletions tests/TicketSwapErrorFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public function formatErrors(AnalysisResult $analysisResult, Output $output): in
);
}

private static function isWindows() : bool
{
return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
}

/**
* @return iterable<array{TicketSwapErrorFormatter::LINK_FORMAT_*, array<string, string>}>
*/
Expand Down Expand Up @@ -83,7 +88,9 @@ public function testGetLinkFormatFromEnv(string $expected, array $environmentVar
public static function provideLinkFormats() : iterable
{
yield [
"↳ <href=phpstorm://open?file=/www/project/src/Core/Admin/Controller/Dashboard/User/AddUserController.php&line=20>src/Core/Admin/.../User/AddUserController.php:20</>\n",
self::isWindows()
? "↳ <href=phpstorm://open?file=/www/project/src/Core/Admin/Controller/Dashboard/User/AddUserController.php&line=20>src/Core/Admin/Controller/Dashboard/User/AddUserController.php:20</>\n"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Windows, these paths don't make any sense. They should be using backslashes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This on IDE link works even on Windows, the data provider test may need change to use relative path that doesn't use root drive path as directory separator use / on relative path

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But when the formatter presents errors, on windows, you would like to see windows paths, right?

Why would you want to see linux paths there?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link should test show relative path, which formatter doesn't use DIRECTORY_SEPARATOR, it uses /.

The different is on windows, /.../ converted to parent directory, as this ternary use, I will check if it is possible to use relative path instead of include root drive

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ruudk I've updated the test to show example of DIRECTORY_SEPARATOR based on operating system 👍

should be ok now 👍

: "↳ <href=phpstorm://open?file=/www/project/src/Core/Admin/Controller/Dashboard/User/AddUserController.php&line=20>src/Core/Admin/.../User/AddUserController.php:20</>\n",
TicketSwapErrorFormatter::LINK_FORMAT_DEFAULT,
20,
'/www/project/src/Core/Admin/Controller/Dashboard/User/AddUserController.php',
Expand Down Expand Up @@ -433,7 +440,9 @@ public function testFormatErrorsWithErrorsPrintsMessagesLinksSummaryAndReturnsOn

self::assertSame(1, $result);

$expectedLink = "↳ <href=phpstorm://open?file=/www/project/src/Foo/Bar.php&line=12>/www/project/.../Foo/Bar.php:12</>\n";
$expectedLink = self::isWindows()
? "↳ <href=phpstorm://open?file=/www/project/src/Foo/Bar.php&line=12>/www/project/src/Foo/Bar.php:12</>\n"
: "↳ <href=phpstorm://open?file=/www/project/src/Foo/Bar.php&line=12>/www/project/.../Foo/Bar.php:12</>\n";
$expectedSummary = '<bg=red;options=bold>Found 1 error</>';

$writes = $output->getWrites();
Expand Down