mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-19 01:50:34 +00:00
5d1ab39def
Replace mock tests with real ones when possible. The original tests are all still present; they just take place in a more representative scenario. After this, there will be 4 remaining uses of mocking. Of these, 3 are needed for scenarios which are otherwise hard to test - WebServiceTest, CellsTest, and SampleCoverageTest. For the other one, AutoFilterTest, I just can't figure out what it's trying to accomplish, so have left it alone. This change is almost entirely restricted to tests. There is a one-line change in src. When the first argument passed to OFFSET is null or nullstring, the returned value is currently 0. However, according to the documentation for Excel, it should be `#VALUE!`. The code is changed accordingly.
38 lines
989 B
PHP
38 lines
989 B
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\LookupRef;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\Formula;
|
|
|
|
/**
|
|
* Class FormulaTextTest.
|
|
*/
|
|
class FormulaTextTest extends AllSetupTeardown
|
|
{
|
|
/**
|
|
* @param mixed $value
|
|
* @dataProvider providerFormulaText
|
|
*/
|
|
public function testFormulaText(string $expectedResult, $value): void
|
|
{
|
|
$sheet = $this->getSheet();
|
|
$reference = 'A1';
|
|
if ($value !== null) {
|
|
$sheet->getCell($reference)->setValue($value);
|
|
}
|
|
$sheet->getCell('D1')->setValue("=FORMULATEXT($reference)");
|
|
$result = $sheet->getCell('D1')->getCalculatedValue();
|
|
self::assertSame($expectedResult, $result);
|
|
}
|
|
|
|
public function providerFormulaText(): array
|
|
{
|
|
return require 'tests/data/Calculation/LookupRef/FORMULATEXT.php';
|
|
}
|
|
|
|
public function testNoCell(): void
|
|
{
|
|
self::assertSame('#REF!', Formula::text('B5'));
|
|
}
|
|
}
|