1+ <?php
2+
3+ namespace Differ ;
4+
5+ //require_once __DIR__ . '/../vendor/autoload.php';
6+
7+ use PHPUnit \Framework \TestCase ;
8+ use PHPUnit \Framework \Attributes \CoversFunction ;
9+ use PHPUnit \Framework \Attributes \CoversNothing ;
10+ use function Differ \runGendiff ;
11+
12+ #[CoversNothing]
13+ class GendiffTest extends TestCase
14+ {
15+ public function testRunGendiff ()
16+ {
17+ $ outputString = "{ \n" .
18+ " hexlet.io \n" .
19+ " - 50 \n" .
20+ " + 20 \n" .
21+ " - 123.234.53.22 \n" .
22+ " - \n" .
23+ "} \n" ;
24+
25+ $ commandLineParserStubToGetContent = $ this ->createConfiguredStub (
26+ CommandLineParser::class,
27+ [
28+ 'getFileNames ' => [
29+ 'FILE1 ' => __DIR__ . "/../file1.json " ,
30+ 'FILE2 ' => __DIR__ . "/../file2.json "
31+ ]
32+ ]
33+ );
34+ $ cmdLineParserStub = $ this ->createConfiguredStub (
35+ CommandLineParser::class,
36+ [
37+ 'execute ' => $ commandLineParserStubToGetContent
38+ ]
39+ );
40+
41+ $ filesDiffCommand = new FilesDiffCommand ();
42+ $ displayCommand = new DisplayCommand ();
43+
44+ $ commandFactoryMock = $ this ->createMock (CommandFactory::class);
45+ $ commandFactoryMock ->expects ($ this ->exactly (3 ))
46+ ->method ('getCommand ' )
47+ ->willReturnMap ([
48+ ['parse ' , $ cmdLineParserStub ],
49+ ['difference ' , $ filesDiffCommand ],
50+ ['show ' , $ displayCommand ]
51+ ]);
52+
53+ $ this ->expectOutputString (
54+ $ outputString );
55+
56+ runGendiff ($ commandFactoryMock );
57+ }
58+ }
0 commit comments