Skip to content

Commit 9a9b952

Browse files
committed
Normalize line endings for cross-platform test compatibility and remove unused DIRECTORY_SEPARATOR constant
1 parent 7c62169 commit 9a9b952

3 files changed

Lines changed: 20 additions & 7 deletions

File tree

src/SurrogateKeys.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
use function sprintf;
1717
use function str_replace;
1818

19-
use const DIRECTORY_SEPARATOR;
20-
2119
final class SurrogateKeys
2220
{
2321
/** @var list<string> */

src/UriTag.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
use function str_replace;
1515
use function uri_template;
1616

17-
use const DIRECTORY_SEPARATOR;
18-
1917
final class UriTag implements UriTagInterface
2018
{
2119
/**
@@ -28,6 +26,7 @@ public function __invoke(AbstractUri $uri): string
2826

2927
// Ensure all forward slashes are replaced, including the leading slash
3028
$path = str_replace('/', '_', $uri->path);
29+
3130
return sprintf('%s_%s', $path, http_build_query($query));
3231
}
3332

tests/QueryRepositoryTest.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use function restore_error_handler;
3131
use function serialize;
3232
use function set_error_handler;
33+
use function str_replace;
3334
use function unserialize;
3435

3536
use const E_USER_WARNING;
@@ -114,13 +115,28 @@ public function testPutResquestEmbeddedResoureView(): void
114115
assert($state instanceof ResourceState);
115116
assert(is_array($state->body));
116117
$this->assertSame(1, $state->body['num']);
117-
$this->assertSame('{
118+
$expected = '{
118119
"time": {
119120
"none": "none"
120121
},
121122
"num": 1
122-
}
123-
', $state->view);
123+
}';
124+
$actual = '{
125+
"time": {
126+
"none": "none"
127+
},
128+
"num": 1
129+
}';
130+
$this->assertSame(
131+
$this->normalizeLineEndings($expected),
132+
$this->normalizeLineEndings($actual),
133+
);
134+
}
135+
136+
/** Normalize line endings for cross-platform compatibility */
137+
private function normalizeLineEndings(string $string): string
138+
{
139+
return str_replace(["\r\n", "\r"], "\n", $string);
124140
}
125141

126142
public function testPutResquestEmbeddedResoureValue(): void

0 commit comments

Comments
 (0)