Skip to content

Commit 3020f6d

Browse files
author
Иван Сабиров
committed
Подготовлен релиз версии 1.4 с внесенными правками
1 parent 0873e87 commit 3020f6d

11 files changed

Lines changed: 21 additions & 97 deletions

File tree

src/Formatters/Json.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@
44

55
function runJsonRender($ast)
66
{
7-
$decodeJson = json_encode($ast, JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK);
8-
$result = "{" . trim($decodeJson, "[]") . "}";
9-
return $result;
7+
return json_encode($ast, JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK);
108
}

src/Runner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function run()
2121
DOC;
2222

2323
try {
24-
$args = \Docopt::handle($doc, array("version" => "GenDiff 1.3.2"));
24+
$args = \Docopt::handle($doc, array("version" => "GenDiff 1.4"));
2525
$diff = render($args["<firstFile>"], $args["<secondFile>"], $args["--format"]);
2626
print_r($diff);
2727
} catch (\Exception $e) {

tests/GenDiffTest.php

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,55 +8,30 @@
88

99
class GenDiffTests extends TestCase
1010
{
11+
public function setUp(): void
12+
{
13+
$this->path1 = "tests/fixtures/nestedBefore.json";
14+
$this->path2 = "tests/fixtures/nestedAfter.json";
15+
$this->path3 = "tests/fixtures/nestedBefore.yaml";
16+
$this->path4 = "tests/fixtures/nestedAfter.yaml";
17+
}
18+
1119
public function testPrettyResult()
1220
{
13-
$path1 = "tests/fixtures/flatBefore.json";
14-
$path2 = "tests/fixtures/flatAfter.json";
15-
$path3 = "tests/fixtures/flatBefore.yaml";
16-
$path4 = "tests/fixtures/flatAfter.yaml";
17-
$path5 = "tests/fixtures/nestedBefore.json";
18-
$path6 = "tests/fixtures/nestedAfter.json";
19-
$path7 = "tests/fixtures/nestedBefore.yaml";
20-
$path8 = "tests/fixtures/nestedAfter.yaml";
21-
$expected1 = file_get_contents("tests/fixtures/expected/prettyFlatResult.txt");
22-
$expected2 = file_get_contents("tests/fixtures/expected/prettyNestedResult.txt");
23-
$this->assertEquals($expected1, render($path1, $path2, "pretty"));
24-
$this->assertEquals($expected1, render($path3, $path4, "pretty"));
25-
$this->assertEquals($expected2, render($path5, $path6, "pretty"));
26-
$this->assertEquals($expected2, render($path7, $path8, "pretty"));
21+
$expected = file_get_contents("tests/fixtures/expected/prettyNestedResult.txt");
22+
$this->assertEquals($expected, render($this->path1, $this->path2, "pretty"));
23+
$this->assertEquals($expected, render($this->path3, $this->path4, "pretty"));
2724
}
2825
public function testPlainResult()
2926
{
30-
$path1 = "tests/fixtures/flatBefore.json";
31-
$path2 = "tests/fixtures/flatAfter.json";
32-
$path3 = "tests/fixtures/flatBefore.yaml";
33-
$path4 = "tests/fixtures/flatAfter.yaml";
34-
$path5 = "tests/fixtures/nestedBefore.json";
35-
$path6 = "tests/fixtures/nestedAfter.json";
36-
$path7 = "tests/fixtures/nestedBefore.yaml";
37-
$path8 = "tests/fixtures/nestedAfter.yaml";
38-
$expected1 = file_get_contents("tests/fixtures/expected/plainFlatResult.txt");
39-
$expected2 = file_get_contents("tests/fixtures/expected/plainNestedResult.txt");
40-
$this->assertEquals($expected1, render($path1, $path2, "plain"));
41-
$this->assertEquals($expected1, render($path3, $path4, "plain"));
42-
$this->assertEquals($expected2, render($path5, $path6, "plain"));
43-
$this->assertEquals($expected2, render($path7, $path8, "plain"));
27+
$expected = file_get_contents("tests/fixtures/expected/plainNestedResult.txt");
28+
$this->assertEquals($expected, render($this->path1, $this->path2, "plain"));
29+
$this->assertEquals($expected, render($this->path3, $this->path4, "plain"));
4430
}
4531
public function testJsonResult()
4632
{
47-
$path1 = "tests/fixtures/flatBefore.json";
48-
$path2 = "tests/fixtures/flatAfter.json";
49-
$path3 = "tests/fixtures/flatBefore.yaml";
50-
$path4 = "tests/fixtures/flatAfter.yaml";
51-
$path5 = "tests/fixtures/nestedBefore.json";
52-
$path6 = "tests/fixtures/nestedAfter.json";
53-
$path7 = "tests/fixtures/nestedBefore.yaml";
54-
$path8 = "tests/fixtures/nestedAfter.yaml";
55-
$expected1 = file_get_contents("tests/fixtures/expected/jsonFlatResult.txt");
56-
$expected2 = file_get_contents("tests/fixtures/expected/jsonNestedResult.txt");
57-
$this->assertEquals($expected1, render($path1, $path2, "json"));
58-
$this->assertEquals($expected1, render($path3, $path4, "json"));
59-
$this->assertEquals($expected2, render($path5, $path6, "json"));
60-
$this->assertEquals($expected2, render($path7, $path8, "json"));
33+
$expected = file_get_contents("tests/fixtures/expected/jsonNestedResult.txt");
34+
$this->assertEquals($expected, render($this->path1, $this->path2, "json"));
35+
$this->assertEquals($expected, render($this->path3, $this->path4, "json"));
6136
}
6237
}

tests/fixtures/expected/jsonFlatResult.txt

Lines changed: 0 additions & 23 deletions
This file was deleted.

tests/fixtures/expected/jsonNestedResult.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
[
22
{
33
"type": "parent",
44
"key": "common",
@@ -70,4 +70,4 @@
7070
"fee": 100500
7171
}
7272
}
73-
}
73+
]

tests/fixtures/expected/plainFlatResult.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/fixtures/expected/prettyFlatResult.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/fixtures/flatAfter.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/fixtures/flatAfter.yaml

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/fixtures/flatBefore.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)