Files
PhpSpreadsheet/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueToTextTest.php
T
oleibman dd9a922b02 Minor Coverage Improvements (#3238)
No source code is changed.
2022-12-22 15:11:58 -08:00

43 lines
1.3 KiB
PHP

<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\TextData\Format;
use PhpOffice\PhpSpreadsheet\RichText\RichText;
class ValueToTextTest extends AllSetupTeardown
{
/**
* @dataProvider providerVALUE
*
* @param mixed $expectedResult
* @param mixed $value
* @param mixed $format
*/
public function testVALUETOTEXT($expectedResult, $value, $format): void
{
$sheet = $this->getSheet();
$this->setCell('A1', $value);
$sheet->getCell('B1')->setValue("=VALUETOTEXT(A1, {$format})");
$result = $sheet->getCell('B1')->getCalculatedValue();
self::assertSame($expectedResult, $result);
}
public function providerVALUE(): array
{
return require 'tests/data/Calculation/TextData/VALUETOTEXT.php';
}
// In Spreadsheet context, never see cell value as RichText.
// It will use calculatedValue, which is a string.
// Add an additional test for that condition.
public function testRichText(): void
{
$richText1 = new RichText();
$richText1->createTextRun('Hello');
$richText1->createText(' World');
self::assertSame('Hello World', Format::valueToText($richText1, 0));
}
}