|
20 | 20 | #[CoversClass(FileReader::class)] |
21 | 21 | class CommandFactoryTest extends TestCase |
22 | 22 | { |
23 | | - #[CoversFunction(CommandFactory::class, 'getCommand')] |
24 | | - public function testGetCommand() |
| 23 | + private $commandFactory; |
| 24 | + |
| 25 | + public function setUp(): void |
25 | 26 | { |
26 | | - $commandFactory = new CommandFactory( |
| 27 | + $this->commandFactory = new CommandFactory( |
27 | 28 | new DocoptDouble(), |
28 | 29 | new FileReader() |
29 | 30 | ); |
| 31 | + } |
| 32 | + |
| 33 | + #[CoversFunction(CommandFactory::class, 'getCommand')] |
| 34 | + public function testGetCommand() |
| 35 | + { |
| 36 | + |
30 | 37 |
|
31 | 38 | // Test for CommandLineParser |
32 | | - $this->assertInstanceOf(CommandLineParser::class, $commandFactory->getCommand('parse')); |
| 39 | + $this->assertInstanceOf(CommandLineParser::class, $this->commandFactory->getCommand('parse')); |
33 | 40 |
|
34 | 41 | // Test for FilesDiffCommand |
35 | | - $this->assertInstanceOf(FilesDiffCommand::class, $commandFactory->getCommand('difference')); |
| 42 | + $this->assertInstanceOf(FilesDiffCommand::class, $this->commandFactory->getCommand('difference')); |
36 | 43 |
|
37 | 44 | // Test for DisplayCommand |
38 | | - $this->assertInstanceOf(DisplayCommand::class, $commandFactory->getCommand('show')); |
| 45 | + $this->assertInstanceOf(DisplayCommand::class, $this->commandFactory->getCommand('show')); |
39 | 46 |
|
40 | 47 | // Test for undefined command |
41 | | - $this->assertNull($commandFactory->getCommand('undefined')); |
| 48 | + $this->assertNull($this->commandFactory->getCommand('undefined')); |
42 | 49 | } |
43 | 50 | } |
0 commit comments