mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-24 23:18:17 +00:00
ec4098c8fd
While we might never be able to have 100% of our code strict, we can at the very least do it for all of our tests. This ensures that our tests are using our API with the types as intended by the test author, and not silently be cast to what our API requires.
53 lines
1.5 KiB
PHP
53 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
|
|
|
class TTest extends AllSetupTeardown
|
|
{
|
|
/**
|
|
* @dataProvider providerT
|
|
*/
|
|
public function testT(mixed $expectedResult, mixed $value = 'no arguments'): void
|
|
{
|
|
$this->mightHaveException($expectedResult);
|
|
if ($value === 'no arguments') {
|
|
$this->setCell('H1', '=T()');
|
|
} else {
|
|
$this->setCell('A1', $value);
|
|
$this->setCell('H1', '=T(A1)');
|
|
}
|
|
$result = $this->getSheet()->getCell('H1')->getCalculatedValue();
|
|
self::assertSame($expectedResult, $result);
|
|
}
|
|
|
|
public static function providerT(): array
|
|
{
|
|
return require 'tests/data/Calculation/TextData/T.php';
|
|
}
|
|
|
|
/**
|
|
* @dataProvider providerTArray
|
|
*/
|
|
public function testTArray(array $expectedResult, string $argument): void
|
|
{
|
|
$calculation = Calculation::getInstance();
|
|
|
|
$formula = "=T({$argument})";
|
|
$result = $calculation->_calculateFormulaValue($formula);
|
|
self::assertSame($expectedResult, $result);
|
|
}
|
|
|
|
public static function providerTArray(): array
|
|
{
|
|
return [
|
|
'row vector #1' => [[['PHP', '', 'PHP8']], '{"PHP", 99, "PHP8"}'],
|
|
'column vector #1' => [[[''], ['PHP'], ['']], '{12; "PHP"; 1.2}'],
|
|
'matrix #1' => [[['TRUE', 'FALSE'], ['', '']], '{"TRUE", "FALSE"; TRUE, FALSE}'],
|
|
];
|
|
}
|
|
}
|