mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-24 06:38:27 +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.
40 lines
1.3 KiB
PHP
40 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\LookupRef;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\LookupRef;
|
|
|
|
class ColumnTest extends AllSetupTeardown
|
|
{
|
|
/**
|
|
* @dataProvider providerCOLUMN
|
|
*
|
|
* @param mixed $expectedResult
|
|
* @param null|array|string $cellReference
|
|
*/
|
|
public function testCOLUMN($expectedResult, $cellReference = null): void
|
|
{
|
|
$result = LookupRef\RowColumnInformation::COLUMN($cellReference);
|
|
self::assertSame($expectedResult, $result);
|
|
}
|
|
|
|
public function providerCOLUMN(): array
|
|
{
|
|
return require 'tests/data/Calculation/LookupRef/COLUMN.php';
|
|
}
|
|
|
|
public function testCOLUMNwithNull(): void
|
|
{
|
|
$sheet = $this->getSheet();
|
|
$sheet->getCell('D1')->setValue('=COLUMN()');
|
|
self::assertSame(4, $sheet->getCell('D1')->getCalculatedValue());
|
|
$sheet->getCell('D2')->setValue('=COLUMN(C13)');
|
|
self::assertSame(3, $sheet->getCell('D2')->getCalculatedValue());
|
|
// Sheetnames don't have to exist
|
|
$sheet->getCell('D3')->setValue('=COLUMN(Sheet17!E15)');
|
|
self::assertSame(5, $sheet->getCell('D3')->getCalculatedValue());
|
|
$sheet->getCell('D4')->setValue("=COLUMN('Worksheet #5'!X500)");
|
|
self::assertSame(24, $sheet->getCell('D4')->getCalculatedValue());
|
|
}
|
|
}
|