Skip to content

Commit

Permalink
Fix tests and static analysis issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hoogi91 committed May 20, 2024
1 parent 434471a commit 9c808e7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 18 deletions.
5 changes: 3 additions & 2 deletions Classes/Service/CellService.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ private function formatString(mixed $value, Cell $cell): string
setlocale(LC_NUMERIC, $currentLocale);
}

return (string)$value;
return $value;
}

return (string)NumberFormat::toFormattedString($value, NumberFormat::FORMAT_GENERAL);
/** @var null|bool|float|int|RichText|string $value */

Check failure on line 132 in Classes/Service/CellService.php

View workflow job for this annotation

GitHub Actions / Check Coding Standards (locked, 8.2, ubuntu-latest)

Null type hint should be on last position in "null|bool|float|int|RichText|string".

Check failure on line 132 in Classes/Service/CellService.php

View workflow job for this annotation

GitHub Actions / Check Coding Standards (locked, 8.2, ubuntu-latest)

Null type hint should be on last position in "null|bool|float|int|RichText|string".
return NumberFormat::toFormattedString($value, NumberFormat::FORMAT_GENERAL);
}
}
2 changes: 1 addition & 1 deletion Classes/Service/SpanService.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function getMergedCells(Worksheet $worksheet): array
}

/**
* @param array<array<int>|CellAddress|string> $references
* @param array<array{0: int, 1: int}|CellAddress|string> $references
* @return array<int>
*/
private function getCellStyleIndexesFromReferences(Worksheet $worksheet, array $references): array
Expand Down
6 changes: 3 additions & 3 deletions Tests/Unit/DataProcessing/SpreadsheetProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public static function processingDataProvider(): array
'firstColumnIsHeader' => false,
],
],
'alternativeExpectation' => self::validInputExpectationsOnlyWithBody(...),
'alternativeExpectations' => self::validInputExpectationsOnlyWithBody(...),
],
'left head data is set because we do not have extracted head data' => [
'processConfig' => ['value' => 'file:123|2!A1:B2'],
Expand All @@ -173,7 +173,7 @@ public static function processingDataProvider(): array
'firstColumnIsHeader' => true,
],
],
'alternativeExpectation' => self::validInputExpectationsOnlyWithBody(...),
'alternativeExpectations' => self::validInputExpectationsOnlyWithBody(...),
],
'head and foot data are not filled incorrectly when no data is given' => [
'processConfig' => ['value' => 'file:123|2!A1:B2'],
Expand All @@ -187,7 +187,7 @@ public static function processingDataProvider(): array
'firstColumnIsHeader' => false,
],
],
'alternativeExpectation' => self::validInputExpectationsWithEmptyBody(...),
'alternativeExpectations' => self::validInputExpectationsWithEmptyBody(...),
],
];
}
Expand Down
12 changes: 3 additions & 9 deletions Tests/Unit/DataProcessing/TabsProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,7 @@ protected function getDataProcessor(): AbstractProcessor
protected function validInputExpectations(MockObject $spreadsheetMock): void
{
// mock worksheet will be returned
$worksheetMock = $this->createConfiguredMock(
Worksheet::class,
[
'getTitle' => 'Worksheet #1',
'getHashCode' => '263df821f3760dc1ec4e',
]
);
$worksheetMock = new Worksheet(null, 'Worksheet #1');
$spreadsheetMock->expects(self::once())->method('getAllSheets')->willReturn([$worksheetMock]);

// check if extract gets called
Expand Down Expand Up @@ -80,7 +74,7 @@ public static function processingDataProvider(): array
'expectedResult' => [
'someOtherVar' => [
// key is file uid and hash code
'123263df821f3760dc1ec4e' => [
'123b8367b83d9b7fa3124b32922f50ad2fc' => [
'sheetTitle' => 'Worksheet #1',
'bodyData' => ['body-data-mocked'],
'headData' => ['head-data-mocked'],
Expand All @@ -97,7 +91,7 @@ public static function processingDataProvider(): array
'expectedResult' => [
'spreadsheets' => [
// key is file uid and hash code
'123263df821f3760dc1ec4e' => [
'123b8367b83d9b7fa3124b32922f50ad2fc' => [
'sheetTitle' => 'Worksheet #1',
'bodyData' => ['body-data-mocked'],
'headData' => ['head-data-mocked'],
Expand Down
4 changes: 1 addition & 3 deletions Tests/Unit/Service/CellServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ public function testCatchingOfCalculatedCellValues(): void
$mockedCell->method('getValue')->willReturn('MockValue');

// build chain for style index search
$worksheetMock = $this->getMockBuilder(Worksheet::class)->disableOriginalConstructor()->getMock();
$worksheetMock->method('getParent')->willReturn($this->spreadsheet);

$worksheetMock = new Worksheet($this->spreadsheet, 'Worksheet');
$mockedCell->method('getWorksheet')->willReturn($worksheetMock);

self::assertEquals('MockValue', $this->cellService->getFormattedValue($mockedCell));
Expand Down

0 comments on commit 9c808e7

Please sign in to comment.