Files
PhpSpreadsheet/tests/PhpSpreadsheetTests/RichTextTest.php
T
oleibman b5f70de61d More Scrutinizer Catch Up (#3050)
* More Scrutinizer Catch Up

Continue the work of PR #3043 by attending to the 12 remaining 'new' issues.

* Php 8.1 Problem

One new null-instead-of-string problem.
2022-09-09 07:56:11 -07:00

41 lines
1.4 KiB
PHP

<?php
namespace PhpOffice\PhpSpreadsheetTests;
use PhpOffice\PhpSpreadsheet\RichText\RichText;
use PhpOffice\PhpSpreadsheet\RichText\TextElement;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PHPUnit\Framework\TestCase;
class RichTextTest extends TestCase
{
public function testConstructorSpecifyingCell(): void
{
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$cell = $sheet->getCell('A1');
$cell->setValue(2);
self::assertSame(2, $cell->getCalculatedValue());
$cell->getStyle()->getFont()->setName('whatever');
$richText = new RichText($cell);
self::assertSame('whatever', $sheet->getCell('A1')->getStyle()->getFont()->getName());
self::assertEquals($richText, $cell->getValue());
self::assertSame('2', $cell->getCalculatedValue());
$spreadsheet->disconnectWorksheets();
}
public function testTextElements(): void
{
$element1 = new TextElement('A');
$element2 = new TextElement('B');
$element3 = new TextElement('C');
$richText = new RichText();
$richText->setRichTextElements([$element1, $element2, $element3]);
self::assertSame('ABC', $richText->getPlainText());
$cloneText = clone $richText;
self::assertEquals($richText, $cloneText);
self::assertNotSame($richText, $cloneText);
}
}