Skip to content

Commit a54a510

Browse files
committed
improved maintainability
1 parent 2b2b203 commit a54a510

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

tests/CommandFactoryTest.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,31 @@
2020
#[CoversClass(FileReader::class)]
2121
class CommandFactoryTest extends TestCase
2222
{
23-
#[CoversFunction(CommandFactory::class, 'getCommand')]
24-
public function testGetCommand()
23+
private $commandFactory;
24+
25+
public function setUp(): void
2526
{
26-
$commandFactory = new CommandFactory(
27+
$this->commandFactory = new CommandFactory(
2728
new DocoptDouble(),
2829
new FileReader()
2930
);
31+
}
32+
33+
#[CoversFunction(CommandFactory::class, 'getCommand')]
34+
public function testGetCommand()
35+
{
36+
3037

3138
// Test for CommandLineParser
32-
$this->assertInstanceOf(CommandLineParser::class, $commandFactory->getCommand('parse'));
39+
$this->assertInstanceOf(CommandLineParser::class, $this->commandFactory->getCommand('parse'));
3340

3441
// Test for FilesDiffCommand
35-
$this->assertInstanceOf(FilesDiffCommand::class, $commandFactory->getCommand('difference'));
42+
$this->assertInstanceOf(FilesDiffCommand::class, $this->commandFactory->getCommand('difference'));
3643

3744
// Test for DisplayCommand
38-
$this->assertInstanceOf(DisplayCommand::class, $commandFactory->getCommand('show'));
45+
$this->assertInstanceOf(DisplayCommand::class, $this->commandFactory->getCommand('show'));
3946

4047
// Test for undefined command
41-
$this->assertNull($commandFactory->getCommand('undefined'));
48+
$this->assertNull($this->commandFactory->getCommand('undefined'));
4249
}
4350
}

0 commit comments

Comments
 (0)