Unit test for RichText object
This commit is contained in:
parent
883115a079
commit
8cea3a94df
|
|
@ -86,12 +86,9 @@ class StringValueBinder implements IValueBinder
|
|||
if ($value instanceof DateTimeInterface) {
|
||||
$value = $value->format('Y-m-d H:i:s');
|
||||
} elseif ($value instanceof RichText) {
|
||||
$cell->setValueExplicit((string) $value, DataType::TYPE_INLINE);
|
||||
$cell->setValueExplicit((string)$value, DataType::TYPE_INLINE);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
// Attempt to cast any unexpected objects to string
|
||||
$value = (string) $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@ use DateTime;
|
|||
use DateTimeZone;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Cell;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\StringValueBinder;
|
||||
use PhpOffice\PhpSpreadsheet\RichText\RichText;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Style;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
|
@ -245,4 +247,16 @@ class StringValueBinderTest extends TestCase
|
|||
[1.23e-24, 1.23E-24, DataType::TYPE_NUMERIC],
|
||||
];
|
||||
}
|
||||
|
||||
public function testStringValueBinderForRichTextObject(): void
|
||||
{
|
||||
$objRichText = new RichText();
|
||||
$objRichText->createText('Hello World');
|
||||
|
||||
$cellStub = $this->createCellStub($objRichText, DataType::TYPE_INLINE);
|
||||
|
||||
$binder = new StringValueBinder();
|
||||
$binder->setConversionForAllValueTypes(false);
|
||||
$binder->bindValue($cellStub, $objRichText);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue