Resolve Deprecated setMethods() call when Mocking for tests (#1925)
Resolve Deprecated `setMethods()` calls when Mocking for tests, using `onlyMethods()` and `addMethods()` instead
This commit is contained in:
parent
ae2468426f
commit
09022256f4
|
|
@ -34,7 +34,7 @@ class ColumnTest extends TestCase
|
||||||
public function testCOLUMNwithNull(): void
|
public function testCOLUMNwithNull(): void
|
||||||
{
|
{
|
||||||
$cell = $this->getMockBuilder(Cell::class)
|
$cell = $this->getMockBuilder(Cell::class)
|
||||||
->setMethods(['getColumn'])
|
->onlyMethods(['getColumn'])
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$cell->method('getColumn')
|
$cell->method('getColumn')
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class RowTest extends TestCase
|
||||||
public function testROWwithNull(): void
|
public function testROWwithNull(): void
|
||||||
{
|
{
|
||||||
$cell = $this->getMockBuilder(Cell::class)
|
$cell = $this->getMockBuilder(Cell::class)
|
||||||
->setMethods(['getRow'])
|
->onlyMethods(['getRow'])
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$cell->method('getRow')
|
$cell->method('getRow')
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ class SubTotalTest extends TestCase
|
||||||
public function testSUBTOTAL($expectedResult, ...$args): void
|
public function testSUBTOTAL($expectedResult, ...$args): void
|
||||||
{
|
{
|
||||||
$cell = $this->getMockBuilder(Cell::class)
|
$cell = $this->getMockBuilder(Cell::class)
|
||||||
->setMethods(['getValue', 'isFormula'])
|
->onlyMethods(['getValue', 'isFormula'])
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$cell->method('getValue')
|
$cell->method('getValue')
|
||||||
|
|
@ -33,7 +33,7 @@ class SubTotalTest extends TestCase
|
||||||
$cell->method('getValue')
|
$cell->method('getValue')
|
||||||
->willReturn(false);
|
->willReturn(false);
|
||||||
$worksheet = $this->getMockBuilder(Worksheet::class)
|
$worksheet = $this->getMockBuilder(Worksheet::class)
|
||||||
->setMethods(['cellExists', 'getCell'])
|
->onlyMethods(['cellExists', 'getCell'])
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$worksheet->method('cellExists')
|
$worksheet->method('cellExists')
|
||||||
|
|
@ -41,7 +41,7 @@ class SubTotalTest extends TestCase
|
||||||
$worksheet->method('getCell')
|
$worksheet->method('getCell')
|
||||||
->willReturn($cell);
|
->willReturn($cell);
|
||||||
$cellReference = $this->getMockBuilder(Cell::class)
|
$cellReference = $this->getMockBuilder(Cell::class)
|
||||||
->setMethods(['getWorksheet'])
|
->onlyMethods(['getWorksheet'])
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$cellReference->method('getWorksheet')
|
$cellReference->method('getWorksheet')
|
||||||
|
|
@ -75,7 +75,7 @@ class SubTotalTest extends TestCase
|
||||||
$visibilityGenerator = $this->rowVisibility($hiddenRows);
|
$visibilityGenerator = $this->rowVisibility($hiddenRows);
|
||||||
|
|
||||||
$rowDimension = $this->getMockBuilder(RowDimension::class)
|
$rowDimension = $this->getMockBuilder(RowDimension::class)
|
||||||
->setMethods(['getVisible'])
|
->onlyMethods(['getVisible'])
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$rowDimension->method('getVisible')
|
$rowDimension->method('getVisible')
|
||||||
|
|
@ -86,13 +86,13 @@ class SubTotalTest extends TestCase
|
||||||
return $result;
|
return $result;
|
||||||
});
|
});
|
||||||
$columnDimension = $this->getMockBuilder(ColumnDimension::class)
|
$columnDimension = $this->getMockBuilder(ColumnDimension::class)
|
||||||
->setMethods(['getVisible'])
|
->onlyMethods(['getVisible'])
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$columnDimension->method('getVisible')
|
$columnDimension->method('getVisible')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
$cell = $this->getMockBuilder(Cell::class)
|
$cell = $this->getMockBuilder(Cell::class)
|
||||||
->setMethods(['getValue', 'isFormula'])
|
->onlyMethods(['getValue', 'isFormula'])
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$cell->method('getValue')
|
$cell->method('getValue')
|
||||||
|
|
@ -100,7 +100,7 @@ class SubTotalTest extends TestCase
|
||||||
$cell->method('getValue')
|
$cell->method('getValue')
|
||||||
->willReturn(false);
|
->willReturn(false);
|
||||||
$worksheet = $this->getMockBuilder(Worksheet::class)
|
$worksheet = $this->getMockBuilder(Worksheet::class)
|
||||||
->setMethods(['cellExists', 'getCell', 'getRowDimension', 'getColumnDimension'])
|
->onlyMethods(['cellExists', 'getCell', 'getRowDimension', 'getColumnDimension'])
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$worksheet->method('cellExists')
|
$worksheet->method('cellExists')
|
||||||
|
|
@ -112,7 +112,7 @@ class SubTotalTest extends TestCase
|
||||||
$worksheet->method('getColumnDimension')
|
$worksheet->method('getColumnDimension')
|
||||||
->willReturn($columnDimension);
|
->willReturn($columnDimension);
|
||||||
$cellReference = $this->getMockBuilder(Cell::class)
|
$cellReference = $this->getMockBuilder(Cell::class)
|
||||||
->setMethods(['getWorksheet'])
|
->onlyMethods(['getWorksheet'])
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$cellReference->method('getWorksheet')
|
$cellReference->method('getWorksheet')
|
||||||
|
|
@ -153,7 +153,7 @@ class SubTotalTest extends TestCase
|
||||||
$cellIsFormulaGenerator = $this->cellIsFormula(Functions::flattenArray(array_slice($args, 1)));
|
$cellIsFormulaGenerator = $this->cellIsFormula(Functions::flattenArray(array_slice($args, 1)));
|
||||||
|
|
||||||
$cell = $this->getMockBuilder(Cell::class)
|
$cell = $this->getMockBuilder(Cell::class)
|
||||||
->setMethods(['getValue', 'isFormula'])
|
->onlyMethods(['getValue', 'isFormula'])
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$cell->method('getValue')
|
$cell->method('getValue')
|
||||||
|
|
@ -171,7 +171,7 @@ class SubTotalTest extends TestCase
|
||||||
return $result;
|
return $result;
|
||||||
});
|
});
|
||||||
$worksheet = $this->getMockBuilder(Worksheet::class)
|
$worksheet = $this->getMockBuilder(Worksheet::class)
|
||||||
->setMethods(['cellExists', 'getCell'])
|
->onlyMethods(['cellExists', 'getCell'])
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$worksheet->method('cellExists')
|
$worksheet->method('cellExists')
|
||||||
|
|
@ -179,7 +179,7 @@ class SubTotalTest extends TestCase
|
||||||
$worksheet->method('getCell')
|
$worksheet->method('getCell')
|
||||||
->willReturn($cell);
|
->willReturn($cell);
|
||||||
$cellReference = $this->getMockBuilder(Cell::class)
|
$cellReference = $this->getMockBuilder(Cell::class)
|
||||||
->setMethods(['getWorksheet'])
|
->onlyMethods(['getWorksheet'])
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$cellReference->method('getWorksheet')
|
$cellReference->method('getWorksheet')
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,8 @@ class AdvancedValueBinderTest extends TestCase
|
||||||
public function testCurrency($value, $valueBinded, $format, $thousandsSeparator, $decimalSeparator, $currencyCode): void
|
public function testCurrency($value, $valueBinded, $format, $thousandsSeparator, $decimalSeparator, $currencyCode): void
|
||||||
{
|
{
|
||||||
$sheet = $this->getMockBuilder(Worksheet::class)
|
$sheet = $this->getMockBuilder(Worksheet::class)
|
||||||
->setMethods(['getStyle', 'getNumberFormat', 'setFormatCode', 'getCellCollection'])
|
->onlyMethods(['getStyle', 'getCellCollection'])
|
||||||
|
->addMethods(['getNumberFormat', 'setFormatCode'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$cellCollection = $this->getMockBuilder(Cells::class)
|
$cellCollection = $this->getMockBuilder(Cells::class)
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
|
|
@ -106,7 +107,8 @@ class AdvancedValueBinderTest extends TestCase
|
||||||
public function testFractions($value, $valueBinded, $format): void
|
public function testFractions($value, $valueBinded, $format): void
|
||||||
{
|
{
|
||||||
$sheet = $this->getMockBuilder(Worksheet::class)
|
$sheet = $this->getMockBuilder(Worksheet::class)
|
||||||
->setMethods(['getStyle', 'getNumberFormat', 'setFormatCode', 'getCellCollection'])
|
->onlyMethods(['getStyle', 'getCellCollection'])
|
||||||
|
->addMethods(['getNumberFormat', 'setFormatCode'])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$cellCollection = $this->getMockBuilder(Cells::class)
|
$cellCollection = $this->getMockBuilder(Cells::class)
|
||||||
|
|
@ -164,7 +166,8 @@ class AdvancedValueBinderTest extends TestCase
|
||||||
public function testPercentages($value, $valueBinded, $format): void
|
public function testPercentages($value, $valueBinded, $format): void
|
||||||
{
|
{
|
||||||
$sheet = $this->getMockBuilder(Worksheet::class)
|
$sheet = $this->getMockBuilder(Worksheet::class)
|
||||||
->setMethods(['getStyle', 'getNumberFormat', 'setFormatCode', 'getCellCollection'])
|
->onlyMethods(['getStyle', 'getCellCollection'])
|
||||||
|
->addMethods(['getNumberFormat', 'setFormatCode'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$cellCollection = $this->getMockBuilder(Cells::class)
|
$cellCollection = $this->getMockBuilder(Cells::class)
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
|
|
@ -214,7 +217,8 @@ class AdvancedValueBinderTest extends TestCase
|
||||||
public function testTimes($value, $valueBinded, $format): void
|
public function testTimes($value, $valueBinded, $format): void
|
||||||
{
|
{
|
||||||
$sheet = $this->getMockBuilder(Worksheet::class)
|
$sheet = $this->getMockBuilder(Worksheet::class)
|
||||||
->setMethods(['getStyle', 'getNumberFormat', 'setFormatCode', 'getCellCollection'])
|
->onlyMethods(['getStyle', 'getCellCollection'])
|
||||||
|
->addMethods(['getNumberFormat', 'setFormatCode'])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$cellCollection = $this->getMockBuilder(Cells::class)
|
$cellCollection = $this->getMockBuilder(Cells::class)
|
||||||
|
|
@ -265,7 +269,8 @@ class AdvancedValueBinderTest extends TestCase
|
||||||
public function testStringWrapping(string $value, bool $wrapped): void
|
public function testStringWrapping(string $value, bool $wrapped): void
|
||||||
{
|
{
|
||||||
$sheet = $this->getMockBuilder(Worksheet::class)
|
$sheet = $this->getMockBuilder(Worksheet::class)
|
||||||
->setMethods(['getStyle', 'getAlignment', 'setWrapText', 'getCellCollection'])
|
->onlyMethods(['getStyle', 'getCellCollection'])
|
||||||
|
->addMethods(['getAlignment', 'setWrapText'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$cellCollection = $this->getMockBuilder(Cells::class)
|
$cellCollection = $this->getMockBuilder(Cells::class)
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ class CellsTest extends TestCase
|
||||||
|
|
||||||
$collection = $this->getMockBuilder(Cells::class)
|
$collection = $this->getMockBuilder(Cells::class)
|
||||||
->setConstructorArgs([new Worksheet(), new Memory()])
|
->setConstructorArgs([new Worksheet(), new Memory()])
|
||||||
->setMethods(['has'])
|
->onlyMethods(['has'])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$collection->method('has')
|
$collection->method('has')
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ class SampleTest extends TestCase
|
||||||
$skipped = [
|
$skipped = [
|
||||||
'Chart/32_Chart_read_write_PDF.php', // Unfortunately JpGraph is not up to date for latest PHP and raise many warnings
|
'Chart/32_Chart_read_write_PDF.php', // Unfortunately JpGraph is not up to date for latest PHP and raise many warnings
|
||||||
'Chart/32_Chart_read_write_HTML.php', // idem
|
'Chart/32_Chart_read_write_HTML.php', // idem
|
||||||
'Chart/35_Chart_render.php', // idem
|
|
||||||
];
|
];
|
||||||
// TCPDF and DomPDF libraries don't support PHP8 yet
|
// TCPDF and DomPDF libraries don't support PHP8 yet
|
||||||
if (\PHP_VERSION_ID >= 80000) {
|
if (\PHP_VERSION_ID >= 80000) {
|
||||||
|
|
@ -39,6 +38,7 @@ class SampleTest extends TestCase
|
||||||
[
|
[
|
||||||
'Pdf/21_Pdf_Domdf.php',
|
'Pdf/21_Pdf_Domdf.php',
|
||||||
'Pdf/21_Pdf_TCPDF.php',
|
'Pdf/21_Pdf_TCPDF.php',
|
||||||
|
'Chart/35_Chart_render.php', // idem
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue