Skip to content

Commit 33b6aae

Browse files
committed
status check 3
1 parent 9637849 commit 33b6aae

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

src/Differ.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ function buildDiff(object $data1, object $data2): array
4040
$keys1 = array_keys(get_object_vars($data1));
4141
$keys2 = array_keys(get_object_vars($data2));
4242
$allKeys = array_unique(array_merge($keys1, $keys2));
43-
$sortedKeys = sortKeys($allKeys);
43+
$sortedKeys = sort($allKeys, function($a, $b) {
44+
return strcmp($a, $b);
45+
});
4446

4547
return array_map(function ($key) use ($data1, $data2) {
4648
return buildNode($key, $data1, $data2);
@@ -130,9 +132,3 @@ function isObject(mixed $value): bool
130132
return is_object($value);
131133
}
132134

133-
function sortKeys(array $keys): array
134-
{
135-
return sort($keys, function ($a, $b) {
136-
return strcmp($a, $b);
137-
});
138-
}

src/Formatters.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use function Differ\Formatters\Plain\format as formatPlain;
77
use function Differ\Formatters\Json\format as formatJson;
88

9-
function render(array $diff, string $formatName = 'stylish'): string
9+
function render(array $diff, string $formatName): string
1010
{
1111
switch ($formatName) {
1212
case 'stylish':

tests/DifferTest.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ function getFixturePath(string $filename): string
1212
return __DIR__ . '/fixtures/' . $filename;
1313
}
1414

15-
function getFixtureContent(string $filename): string
16-
{
17-
$path = getFixturePath($filename);
18-
return file_get_contents($path);
19-
}
20-
2115
class DifferTest extends TestCase
2216
{
2317
public static function fileFormatsProvider(): array
@@ -31,19 +25,19 @@ public static function fileFormatsProvider(): array
3125
#[DataProvider('fileFormatsProvider')]
3226
public function testRecursiveComparisonJsonStylishFormat(string $format): void
3327
{
34-
$expected = file_get_contents(getFixturePath('expected_nested.txt'));
28+
$expected = getFixturePath('expected_nested.txt');
3529

3630
$actual = genDiff(getFixturePath("file1.{$format}"), getFixturePath("file2.{$format}"));
37-
$this->assertNotEquals($expected, $actual);
31+
$this->assertStringNotEqualsFile($expected, $actual);
3832
}
3933

4034
#[DataProvider('fileFormatsProvider')]
4135
public function testPlainFormatOutput(string $format): void
4236
{
43-
$expected = file_get_contents(getFixturePath('expected_plain.txt'));
37+
$expected = getFixturePath('expected_plain.txt');
4438

4539
$actual = genDiff(getFixturePath("file1.{$format}"), getFixturePath("file2.{$format}"), 'plain');
46-
$this->assertEquals($expected, $actual);
40+
$this->assertStringEqualsFile($expected, $actual);
4741
}
4842

4943
#[DataProvider('fileFormatsProvider')]

0 commit comments

Comments
 (0)