File tree Expand file tree Collapse file tree 3 files changed +38
-11
lines changed Expand file tree Collapse file tree 3 files changed +38
-11
lines changed Original file line number Diff line number Diff line change 22
33namespace Differ \Differ ;
44
5+ use Differ \CommandFactory ;
56use Differ \CommandLineParser ;
67use Differ \FilesDiffCommand ;
78use Differ \FileReader ;
89use Differ \DisplayCommand ;
910
1011function genDiff (string $ pathToFile1 , string $ pathToFile2 )
1112{
12- $ parserCommand = new CommandLineParser ();
13+ $ commandFactory = new CommandFactory ();
14+ $ parserCommand = $ commandFactory ->getCommand ('parse ' );
1315 $ fileNames = [
1416 "FILE1 " => $ pathToFile1 ,
1517 "FILE2 " => $ pathToFile2
1618 ];
1719 $ nextCommand = $ parserCommand ->setFileNames ($ fileNames );
1820
19- $ currentCommand = new FilesDiffCommand ();
20- $ nextCommand = $ currentCommand ->setFileNames ($ nextCommand )
21- ->setFileReader (new FileReader ())
22- ->execute ();
21+ $ currentCommand = $ commandFactory ->getCommand ('difference ' );
22+ $ nextCommand = $ currentCommand ->setFileReader (new FileReader ())
23+ ->execute ($ nextCommand );
2324
24- $ currentCommand = new DisplayCommand ();
25- return $ currentCommand ->execute ($ nextCommand )
26- ->getDiffs ();
25+ $ currentCommand = $ commandFactory ->getCommand ('show ' );
26+ return $ currentCommand ->execute ($ nextCommand );
2727}
Original file line number Diff line number Diff line change 22
33namespace Differ ;
44
5- //require_once __DIR__ . '/../vendor/autoload.php';
6-
75use PHPUnit \Framework \TestCase ;
8- use PHPUnit \Framework \Attributes \CoversFunction ;
96use PHPUnit \Framework \Attributes \CoversNothing ;
107use function Differ \runGendiff ;
118
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Differ ;
4+
5+ use PHPUnit \Framework \TestCase ;
6+ use PHPUnit \Framework \Attributes \CoversNothing ;
7+ use function Differ \Differ \genDiff as genDiff ;
8+ use Differ \CommandLineParser ;
9+ use Differ \FilesDiffCommand ;
10+ use Differ \FileReader ;
11+ use Differ \DisplayCommand ;
12+
13+ #[CoversNothing]
14+ class genDiffUserTest extends TestCase
15+ {
16+ function testFilesDiffer ()
17+ {
18+ $ outputString = "{ \n" .
19+ " hexlet.io \n" .
20+ " - 50 \n" .
21+ " + 20 \n" .
22+ " - 123.234.53.22 \n" .
23+ " - \n" .
24+ "} \n" ;
25+
26+ $ this ->expectOutputString ($ outputString );
27+
28+ genDiff (__DIR__ . "/../file1.json " , __DIR__ . "/../file2.json " );
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments