Skip to content

Commit aabe3af

Browse files
committed
added test for DisplayCommand
1 parent a005c4d commit aabe3af

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

tests/DisplayCommandTest.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
namespace Differ;
4+
5+
use PHPUnit\Framework\TestCase;
6+
use PHPUnit\Framework\Attributes\CoversClass;
7+
use Differ\DisplayCommand;
8+
use Fixtures\CommandLineParsersStub;
9+
10+
#[CoversClass(DisplayCommand::class)]
11+
class DisplayCommandTest extends TestCase
12+
{
13+
public $displayCmd;
14+
private $file1Content;
15+
private $file2Content;
16+
17+
protected function setUp(): void
18+
{
19+
$this->displayCmd = new DisplayCommand();
20+
21+
$this->file1Content =
22+
[
23+
"id" => "none",
24+
"host" => "hexlet.io",
25+
"timeout" => 50
26+
];
27+
$this->file2Content =
28+
[
29+
"timeout" => 20,
30+
"verbose" => 1,
31+
"host" => "hexlet.io"
32+
];
33+
}
34+
35+
public function testInstance()
36+
{
37+
$this->assertInstanceOf(DisplayCommand::class, $this->displayCmd);
38+
}
39+
40+
public function testExecute()
41+
{
42+
$filesDiffCmd = $this->createConfiguredStub(
43+
FilesDiffCommand::class,
44+
[
45+
'getFilesContent' =>
46+
[
47+
"FILE1" => $this->file1Content,
48+
"FILE2" => $this->file2Content
49+
]
50+
]
51+
);
52+
53+
$this->assertInstanceOf(DisplayCommand::class, $this->displayCmd
54+
->execute($filesDiffCmd));
55+
}
56+
57+
public function testGetDiffs()
58+
{
59+
$this->assertEquals("{\n}\n", $this->displayCmd->getDiffs());
60+
}
61+
}

0 commit comments

Comments
 (0)