Skip to content

Commit 08c96d4

Browse files
committed
Added missing tests.
1 parent 01dc954 commit 08c96d4

24 files changed

+1058
-833
lines changed

composer.lock

Lines changed: 10 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Command/ProcessStep/UploadStep.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,7 @@
2121
*/
2222
class UploadStep implements ProcessStepInterface
2323
{
24-
/**
25-
* The console.
26-
* @var Console
27-
*/
28-
protected $console;
29-
24+
protected Console $console;
3025
protected ExportDataService $exportDataService;
3126

3227
/**
@@ -47,13 +42,6 @@ class UploadStep implements ProcessStepInterface
4742
*/
4843
protected $ftpPassword;
4944

50-
/**
51-
* Initializes the step.
52-
* @param Console $console
53-
* @param string $uploadFtpHost
54-
* @param string $uploadFtpUsername
55-
* @param string $uploadFtpPassword
56-
*/
5745
public function __construct(
5846
Console $console,
5947
ExportDataService $exportDataService,

src/Mapper/MachineMapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function map(object $source, object $destination): void
5050
* @param float $energyUsage
5151
* @return array{float, string}
5252
*/
53-
protected function convertEnergyUsage(float $energyUsage): array
53+
private function convertEnergyUsage(float $energyUsage): array
5454
{
5555
$unit = EnergyUsageUnit::WATT;
5656
foreach (EnergyUsageUnit::ORDERED_UNITS as $currentUnit) {

src/Mapper/RecipeProductMapper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ public function map(object $source, object $destination): void
3838
$destination->name = $source->name;
3939
$destination->amountMin = $source->amountMin;
4040
$destination->amountMax = $source->amountMax;
41+
$destination->probability = $source->probability;
4142
}
4243
}

src/Parser/IconParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class IconParser implements ParserInterface
3131
/** @var array<string,array<string,ExportIcon>> */
3232
protected array $parsedIcons = [];
3333
/** @var array<string,ExportIcon> */
34-
protected $usedIcons = [];
34+
protected array $usedIcons = [];
3535

3636
public function __construct(HashCalculator $hashCalculator, MapperManagerInterface $mapperManager)
3737
{

src/Parser/TranslationParser.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use BluePsyduck\FactorioTranslator\Translator;
99
use FactorioItemBrowser\Export\Entity\Dump\Dump;
1010
use FactorioItemBrowser\Export\Mod\ModFileManager;
11-
use FactorioItemBrowser\ExportData\Collection\Translations;
11+
use FactorioItemBrowser\ExportData\Collection\DictionaryInterface;
1212
use FactorioItemBrowser\ExportData\ExportData;
1313

1414
/**
@@ -49,12 +49,15 @@ public function validate(ExportData $exportData): void
4949
}
5050

5151
/**
52-
* @param Translations $translations
52+
* @param DictionaryInterface $translations
5353
* @param mixed $localisedString
5454
* @param mixed|null $fallbackLocalisedString
5555
*/
56-
public function translate(Translations $translations, $localisedString, $fallbackLocalisedString = null): void
57-
{
56+
public function translate(
57+
DictionaryInterface $translations,
58+
$localisedString,
59+
$fallbackLocalisedString = null
60+
): void {
5861
foreach ($this->translator->getAllLocales() as $locale) {
5962
$value = $this->translator->translate($locale, $localisedString);
6063
if ($value === '' && $fallbackLocalisedString !== null) {

test/src/Command/ProcessStep/ParserStepTest.php

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use FactorioItemBrowser\Export\Entity\ProcessStepData;
1212
use FactorioItemBrowser\Export\Exception\ExportException;
1313
use FactorioItemBrowser\Export\Parser\ParserInterface;
14-
use FactorioItemBrowser\ExportData\Entity\Combination;
1514
use FactorioItemBrowser\ExportData\ExportData;
1615
use FactorioItemBrowser\ExportQueue\Client\Constant\JobStatus;
1716
use PHPUnit\Framework\MockObject\MockObject;
@@ -29,24 +28,15 @@ class ParserStepTest extends TestCase
2928
{
3029
use ReflectionTrait;
3130

32-
/**
33-
* The mocked console.
34-
* @var Console&MockObject
35-
*/
36-
protected $console;
31+
/** @var Console&MockObject */
32+
private $console;
3733

38-
/**
39-
* Sets up the test case.
40-
*/
4134
protected function setUp(): void
4235
{
43-
parent::setUp();
44-
4536
$this->console = $this->createMock(Console::class);
4637
}
4738

4839
/**
49-
* Tests the constructing.
5040
* @throws ReflectionException
5141
* @covers ::__construct
5242
*/
@@ -64,7 +54,6 @@ public function testConstruct(): void
6454
}
6555

6656
/**
67-
* Tests the getLabel method.
6857
* @covers ::getLabel
6958
*/
7059
public function testGetLabel(): void
@@ -77,7 +66,6 @@ public function testGetLabel(): void
7766
}
7867

7968
/**
80-
* Tests the getExportJobStatus method.
8169
* @covers ::getExportJobStatus
8270
*/
8371
public function testGetExportJobStatus(): void
@@ -90,50 +78,39 @@ public function testGetExportJobStatus(): void
9078
}
9179

9280
/**
93-
* Tests the run method.
9481
* @throws ExportException
9582
* @covers ::run
9683
*/
9784
public function testRun(): void
9885
{
99-
/* @var Dump&MockObject $dump */
10086
$dump = $this->createMock(Dump::class);
101-
/* @var Combination&MockObject $combination */
102-
$combination = $this->createMock(Combination::class);
103-
104-
/* @var ExportData&MockObject $exportData */
10587
$exportData = $this->createMock(ExportData::class);
106-
$exportData->expects($this->any())
107-
->method('getCombination')
108-
->willReturn($combination);
10988

11089
$data = new ProcessStepData();
11190
$data->setDump($dump)
11291
->setExportData($exportData);
11392

114-
/* @var ParserInterface&MockObject $parser1 */
11593
$parser1 = $this->createMock(ParserInterface::class);
11694
$parser1->expects($this->once())
11795
->method('prepare')
11896
->with($this->identicalTo($dump));
11997
$parser1->expects($this->once())
12098
->method('parse')
121-
->with($this->identicalTo($dump), $this->identicalTo($combination));
99+
->with($this->identicalTo($dump), $this->identicalTo($exportData));
122100
$parser1->expects($this->once())
123101
->method('validate')
124-
->with($this->identicalTo($combination));
102+
->with($this->identicalTo($exportData));
125103

126-
/* @var ParserInterface&MockObject $parser2 */
127104
$parser2 = $this->createMock(ParserInterface::class);
128105
$parser2->expects($this->once())
129106
->method('prepare')
130107
->with($this->identicalTo($dump));
131108
$parser2->expects($this->once())
132109
->method('parse')
133-
->with($this->identicalTo($dump), $this->identicalTo($combination));
110+
->with($this->identicalTo($dump), $this->identicalTo($exportData));
134111
$parser2->expects($this->once())
135112
->method('validate')
136-
->with($this->identicalTo($combination));
113+
->with($this->identicalTo($exportData));
137114

138115
$parsers = [$parser1, $parser2];
139116

0 commit comments

Comments
 (0)