1+ <?php
2+
3+ namespace Differ \tests ;
4+
5+ use PHPUnit \Framework \TestCase ;
6+ use PHPUnit \Framework \Attributes \CoversClass ;
7+ use PHPUnit \Framework \Attributes \CoversMethod ;
8+ use Differ \CommandLineParser ;
9+
10+ #[CoversClass(CommandLineParser::class)]
11+ #[CoversMethod(CommandLineParser::class, 'setFileNames ' )]
12+ #[CoversMethod(CommandLineParser::class, 'getFileNames ' )]
13+ class CommandLineParserTest extends TestCase
14+ {
15+ private $ fixturesFileHandler ;
16+ private $ fixturesData ;
17+
18+ protected function setUp (): void
19+ {
20+ $ this ->fixturesFileHandler = fopen (__DIR__ . "/../fixtures/docopt.txt " , "r " );
21+ $ docoptInput = [];
22+ while (($ docoptInput [] = fgets ($ this ->fixturesFileHandler , 4096 )) !== false );
23+ $ this ->fixturesData = implode ("\n" , $ docoptInput );
24+ }
25+
26+ public function testFileNames ()
27+ {
28+ $ cmdLineParser = new CommandLineParser ($ this ->fixturesData );
29+
30+ $ fileNames = [
31+ "FILE1 " => __DIR__ . "/../file1.json " ,
32+ "FILE2 " => __DIR__ . "/../file2.json "
33+ ];
34+
35+ $ this ->assertInstanceOf (CommandLineParser::class, $ cmdLineParser ->setFileNames ($ fileNames ));
36+
37+ $ this ->assertEquals ($ fileNames , $ cmdLineParser ->setFileNames ($ fileNames )
38+ ->getFileNames ());
39+ }
40+
41+ public function testExecute ()
42+ {
43+ $ cmdLineParser = new CommandLineParser ($ this ->fixturesData );
44+
45+ $ stub = $ this ->createStub (CommandLineParser::class);
46+
47+ $ this ->assertInstanceOf (CommandLineParser::class, $ cmdLineParser ->execute ($ stub ));
48+ }
49+
50+ protected function tearDown (): void
51+ {
52+ fclose ($ this ->fixturesFileHandler );
53+ }
54+ }
0 commit comments