Skip to content

Commit ed2afa1

Browse files
committed
updated docopt double
1 parent 5e5f1bb commit ed2afa1

File tree

6 files changed

+37
-21
lines changed

6 files changed

+37
-21
lines changed

tests/Fixtures/DocoptDouble.php renamed to src/Parsers/DocoptDouble.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Differ\Tests\Fixtures;
3+
namespace Differ\Parsers;
44

55
use Differ\Interfaces\DocoptDoubleInterface;
66

@@ -11,14 +11,17 @@ class DocoptDouble implements DocoptDoubleInterface
1111
*/
1212
public array $args;
1313

14-
public function __construct(string $format = "stylish")
15-
{
14+
public function __construct(
15+
string $file1Path = "",
16+
string $file2Path = "",
17+
string $format = "stylish"
18+
) {
1619
$this->args = [
1720
"--help" => "",
1821
"--version" => "",
1922
"--format" => $format,
20-
"FILE1" => $_ENV["FIXTURES_PATH"] . "/file1.json",
21-
"FILE2" => $_ENV["FIXTURES_PATH"] . "/file2.json"
23+
"FILE1" => $file1Path,
24+
"FILE2" => $file2Path
2225
];
2326
}
2427

tests/Unit/CommandFactoryTest.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,30 @@
55
use PHPUnit\Framework\TestCase;
66
use PHPUnit\Framework\Attributes\CoversClass;
77
use PHPUnit\Framework\Attributes\CoversMethod;
8-
use Differ\Tests\Fixtures\DocoptDouble;
8+
use Differ\Parsers\DocoptDouble;
9+
use Differ\Parsers\CommandLineParser;
10+
use Differ\Parsers\FileParser;
911
use Differ\Factories\CommandFactory;
1012
use Differ\Factories\Formatters;
1113
use Differ\Displays\DisplayCommand;
1214
use Differ\Differs\FilesDiffCommand;
1315
use Differ\Readers\FileReader;
1416
use Differ\Exceptions\DifferException;
17+
use Differ\Formatters\StylishCommand;
18+
use Differ\Formatters\PlainCommand;
19+
use Differ\Formatters\JSONCommand;
1520

1621
#[CoversClass(CommandFactory::class)]
17-
#[CoversClass(\Differ\Parsers\CommandLineParser::class)]
18-
#[CoversClass(\Differ\Parsers\FileParser::class)]
22+
#[CoversClass(CommandLineParser::class)]
23+
#[CoversClass(FileParser::class)]
1924
#[CoversClass(FilesDiffCommand::class)]
2025
#[CoversClass(DisplayCommand::class)]
2126
#[CoversClass(FileReader::class)]
2227
#[CoversClass(DifferException::class)]
23-
#[CoversClass(\Differ\Formatters\StylishCommand::class)]
24-
#[CoversClass(\Differ\Formatters\PlainCommand::class)]
25-
#[CoversClass(\Differ\Formatters\JSONCommand::class)]
28+
#[CoversClass(DocoptDouble::class)]
29+
#[CoversClass(StylishCommand::class)]
30+
#[CoversClass(PlainCommand::class)]
31+
#[CoversClass(JSONCommand::class)]
2632
#[CoversMethod(CommandFactory::class, 'createCommand')]
2733
#[CoversClass(Formatters::class)]
2834
class CommandFactoryTest extends TestCase
@@ -40,17 +46,17 @@ public function setUp(): void
4046

4147
public function testCreateCommand()
4248
{
43-
$this->assertInstanceOf(\Differ\Parsers\CommandLineParser::class, $this->commandFactory->createCommand('parseCMDLine'));
49+
$this->assertInstanceOf(CommandLineParser::class, $this->commandFactory->createCommand('parseCMDLine'));
4450

45-
$this->assertInstanceOf(\Differ\Parsers\FileParser::class, $this->commandFactory->createCommand("parseFile"));
51+
$this->assertInstanceOf(FileParser::class, $this->commandFactory->createCommand("parseFile"));
4652

4753
$this->assertInstanceOf(FilesDiffCommand::class, $this->commandFactory->createCommand('difference'));
4854

49-
$this->assertInstanceOf(\Differ\Formatters\StylishCommand::class, $this->commandFactory->createCommand('stylish'));
55+
$this->assertInstanceOf(StylishCommand::class, $this->commandFactory->createCommand('stylish'));
5056

51-
$this->assertInstanceOf(\Differ\Formatters\PlainCommand::class, $this->commandFactory->createCommand('plain'));
57+
$this->assertInstanceOf(PlainCommand::class, $this->commandFactory->createCommand('plain'));
5258

53-
$this->assertInstanceOf(\Differ\Formatters\JSONCommand::class, $this->commandFactory->createCommand('json'));
59+
$this->assertInstanceOf(JSONCommand::class, $this->commandFactory->createCommand('json'));
5460

5561
$this->assertInstanceOf(DisplayCommand::class, $this->commandFactory->createCommand('show'));
5662

tests/Unit/CommandLineParserTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
use PHPUnit\Framework\Attributes\CoversClass;
77
use PHPUnit\Framework\Attributes\CoversMethod;
88
use PHPUnit\Framework\Attributes\DataProvider;
9-
use Differ\Tests\Fixtures\DocoptDouble;
9+
use Differ\Parsers\DocoptDouble;
1010

1111
#[CoversClass(\Differ\Parsers\CommandLineParser::class)]
1212
#[CoversMethod(\Differ\Parsers\CommandLineParser::class, 'setFileNames')]
1313
#[CoversMethod(\Differ\Parsers\CommandLineParser::class, 'getFileNames')]
14+
#[CoversClass(DocoptDouble::class)]
1415
class CommandLineParserTest extends TestCase
1516
{
1617
public static function getFiles(): array

tests/Unit/DisplayCommandTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use PHPUnit\Framework\TestCase;
66
use PHPUnit\Framework\Attributes\CoversClass;
77
use PHPUnit\Framework\Attributes\CoversMethod;
8-
use Differ\Tests\Fixtures\DocoptDouble;
8+
use Differ\Parsers\DocoptDouble;
99
use Differ\Factories\CommandFactory;
1010
use Differ\Factories\Formatters;
1111
use Differ\Displays\DisplayCommand;
@@ -15,6 +15,7 @@
1515
#[CoversClass(DisplayCommand::class)]
1616
#[CoversMethod(DisplayCommand::class, 'execute')]
1717
#[CoversClass(DifferException::class)]
18+
#[CoversClass(DocoptDouble::class)]
1819
#[CoversClass(CommandFactory::class)]
1920
#[CoversClass(FileReader::class)]
2021
class DisplayCommandTest extends TestCase

tests/Unit/FormattersTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use PHPUnit\Framework\Attributes\CoversClass;
77
use PHPUnit\Framework\Attributes\CoversMethod;
88
use PHPUnit\Framework\Attributes\DataProvider;
9-
use Differ\Tests\Fixtures\DocoptDouble;
9+
use Differ\Parsers\DocoptDouble;
1010
use Differ\Factories\CommandFactory;
1111
use Differ\Factories\Formatters;
1212
use Differ\Displays\DisplayCommand;
@@ -19,6 +19,7 @@
1919
#[CoversClass(\Differ\Parsers\FileParser::class)]
2020
#[CoversClass(Formatters::class)]
2121
#[CoversClass(FilesDiffCommand::class)]
22+
#[CoversClass(DocoptDouble::class)]
2223
#[CoversClass(FileReader::class)]
2324
#[CoversMethod(FilesDiffCommand::class, 'execute')]
2425
#[CoversClass(DifferException::class)]

tests/Unit/GendiffConsoleTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use PHPUnit\Framework\Attributes\CoversClass;
77
use PHPUnit\Framework\Attributes\CoversMethod;
88
use PHPUnit\Framework\Attributes\DataProvider;
9-
use Differ\Tests\Fixtures\DocoptDouble;
9+
use Differ\Parsers\DocoptDouble;
1010
use Differ\Parsers\FileParser;
1111
use Differ\Parsers\CommandLineParser;
1212
use Differ\Readers\FileReader;
@@ -21,6 +21,7 @@
2121

2222
#[CoversClass(CommandFactory::class)]
2323
#[CoversClass(Formatters::class)]
24+
#[CoversClass(DocoptDouble::class)]
2425
#[CoversClass(FileParser::class)]
2526
#[CoversClass(CommandLineParser::class)]
2627
#[CoversClass(FileReader::class)]
@@ -59,7 +60,10 @@ public static function getTestData(): array
5960
#[DataProvider('getTestData')]
6061
public function testConsoleDiffer($formatter, $filePath)
6162
{
62-
$commandLineParser = is_null($formatter) ? new DocoptDouble() : new DocoptDouble($formatter);
63+
$commandLineParser = is_null($formatter) ?
64+
new DocoptDouble($_ENV["FIXTURES_PATH"] . "/file1.json", $_ENV["FIXTURES_PATH"] . "/file2.json")
65+
:
66+
new DocoptDouble($_ENV["FIXTURES_PATH"] . "/file1.json", $_ENV["FIXTURES_PATH"] . "/file2.json", $formatter);
6367
$commandFactory = new CommandFactory(
6468
$commandLineParser,
6569
new FileReader(),

0 commit comments

Comments
 (0)