Rename Two Test Files (#2459)
* Rename Two Test Files When I run unit tests only for Reader/Xlsx, phpunit is issuing a deprecation message because the names of 2 files have an extra dot in them and thus don't match the class name in the file. I do not see these warnings when I run the entire test suite. * Remove Phpstan Annotations It was a bit difficult to handle a cast from mixed to string. * Fix Same Phpstan Problem in One Other Test This is the only other test case that tries to cast mixed to string.
This commit is contained in:
parent
f2b2f07ec3
commit
07271c83aa
|
|
@ -8405,16 +8405,6 @@ parameters:
|
||||||
count: 5
|
count: 5
|
||||||
path: tests/PhpSpreadsheetTests/NamedRangeTest.php
|
path: tests/PhpSpreadsheetTests/NamedRangeTest.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Property PhpOffice\\\\PhpSpreadsheetTests\\\\Reader\\\\Csv\\\\CsvContiguousFilter\\:\\:\\$startRow \\(int\\) does not accept mixed\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousFilter.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot cast mixed to string\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousTest.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Part \\$result \\(mixed\\) of encapsed string cannot be cast to string\\.$#"
|
message: "#^Part \\$result \\(mixed\\) of encapsed string cannot be cast to string\\.$#"
|
||||||
count: 2
|
count: 2
|
||||||
|
|
@ -8520,16 +8510,6 @@ parameters:
|
||||||
count: 1
|
count: 1
|
||||||
path: tests/PhpSpreadsheetTests/Reader/Xlsx/ConditionalFormattingDataBarXlsxTest.php
|
path: tests/PhpSpreadsheetTests/Reader/Xlsx/ConditionalFormattingDataBarXlsxTest.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot cast mixed to string\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: tests/PhpSpreadsheetTests/Reader/Xlsx/Namespace.Issue2109bTest.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot cast mixed to string\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: tests/PhpSpreadsheetTests/Reader/Xlsx/Namespace.Openpyxl35Test.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Part \\$result \\(mixed\\) of encapsed string cannot be cast to string\\.$#"
|
message: "#^Part \\$result \\(mixed\\) of encapsed string cannot be cast to string\\.$#"
|
||||||
count: 2
|
count: 2
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,8 @@ class CsvContiguousFilter implements IReadFilter
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the list of rows that we want to read.
|
* Set the list of rows that we want to read.
|
||||||
*
|
|
||||||
* @param mixed $startRow
|
|
||||||
* @param mixed $chunkSize
|
|
||||||
*/
|
*/
|
||||||
public function setRows($startRow, $chunkSize): void
|
public function setRows(int $startRow, int $chunkSize): void
|
||||||
{
|
{
|
||||||
$this->startRow = $startRow;
|
$this->startRow = $startRow;
|
||||||
$this->endRow = $startRow + $chunkSize;
|
$this->endRow = $startRow + $chunkSize;
|
||||||
|
|
|
||||||
|
|
@ -57,11 +57,15 @@ class CsvContiguousTest extends TestCase
|
||||||
private static function getCellValue(Spreadsheet $spreadsheet, string $sheetName, string $cellAddress): string
|
private static function getCellValue(Spreadsheet $spreadsheet, string $sheetName, string $cellAddress): string
|
||||||
{
|
{
|
||||||
$sheet = $spreadsheet->getSheetByName($sheetName);
|
$sheet = $spreadsheet->getSheetByName($sheetName);
|
||||||
if ($sheet === null) {
|
$result = '';
|
||||||
return '';
|
if ($sheet !== null) {
|
||||||
|
$value = $sheet->getCell($cellAddress)->getValue();
|
||||||
|
if (is_scalar($value) || (is_object($value) && method_exists($value, '__toString'))) {
|
||||||
|
$result = (string) $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (string) $sheet->getCell($cellAddress)->getValue();
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testContiguous2(): void
|
public function testContiguous2(): void
|
||||||
|
|
|
||||||
|
|
@ -60,10 +60,13 @@ class NamespaceIssue2109bTest extends \PHPUnit\Framework\TestCase
|
||||||
private static function getCellValue(Worksheet $sheet, string $cell): string
|
private static function getCellValue(Worksheet $sheet, string $cell): string
|
||||||
{
|
{
|
||||||
$result = $sheet->getCell($cell)->getValue();
|
$result = $sheet->getCell($cell)->getValue();
|
||||||
|
if (is_scalar($result) || (is_object($result) && method_exists($result, '__toString'))) {
|
||||||
return (string) $result;
|
return (string) $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
public function testLoadXlsx(): void
|
public function testLoadXlsx(): void
|
||||||
{
|
{
|
||||||
$reader = new Xlsx();
|
$reader = new Xlsx();
|
||||||
|
|
@ -60,10 +60,13 @@ class NamespaceOpenpyxl35Test extends \PHPUnit\Framework\TestCase
|
||||||
private static function getCellValue(Worksheet $sheet, string $cell): string
|
private static function getCellValue(Worksheet $sheet, string $cell): string
|
||||||
{
|
{
|
||||||
$result = $sheet->getCell($cell)->getValue();
|
$result = $sheet->getCell($cell)->getValue();
|
||||||
|
if (is_scalar($result) || (is_object($result) && method_exists($result, '__toString'))) {
|
||||||
return (string) $result;
|
return (string) $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
public function testLoadXlsx(): void
|
public function testLoadXlsx(): void
|
||||||
{
|
{
|
||||||
$reader = new Xlsx();
|
$reader = new Xlsx();
|
||||||
Loading…
Reference in New Issue