ef997a0c8e
If font style Superscript is set to true, Subscript is set to false. Likewise, setting Subscript to true sets Superscript to false. Both of these are working as they should. However, setting Superscript to false causes Subscript to be set to true, and setting Subscript to false causes Superscript to be set to true. I believe that is an error in both cases. This change fixes it. There seem to be no existing tests for Font styles. I added the tests necessary to validate this change. I will put adding more on my to-do list.
43 lines
1.7 KiB
PHP
43 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Style;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class FontTest extends TestCase
|
|
{
|
|
public function testSuperSubScript(): void
|
|
{
|
|
$spreadsheet = new Spreadsheet();
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
$cell = $sheet->getCell('A1');
|
|
$cell->setValue('Cell A1');
|
|
$font = $cell->getStyle()->getFont();
|
|
$font->setSuperscript(true);
|
|
$font->setSubscript(true);
|
|
self::assertFalse($font->getSuperscript(), 'Earlier set true loses');
|
|
self::assertTrue($font->getSubscript(), 'Last set true wins');
|
|
$font->setSubscript(true);
|
|
$font->setSuperscript(true);
|
|
self::assertTrue($font->getSuperscript(), 'Last set true wins');
|
|
self::assertFalse($font->getSubscript(), 'Earlier set true loses');
|
|
$font->setSuperscript(false);
|
|
$font->setSubscript(false);
|
|
self::assertFalse($font->getSuperscript(), 'False remains unchanged');
|
|
self::assertFalse($font->getSubscript(), 'False remains unchanged');
|
|
$font->setSubscript(false);
|
|
$font->setSuperscript(false);
|
|
self::assertFalse($font->getSuperscript(), 'False remains unchanged');
|
|
self::assertFalse($font->getSubscript(), 'False remains unchanged');
|
|
$font->setSubscript(true);
|
|
$font->setSuperscript(false);
|
|
self::assertFalse($font->getSuperscript(), 'False remains unchanged');
|
|
self::assertTrue($font->getSubscript(), 'True remains unchanged');
|
|
$font->setSubscript(false);
|
|
$font->setSuperscript(true);
|
|
self::assertTrue($font->getSuperscript());
|
|
self::assertFalse($font->getSubscript(), 'False remains unchanged');
|
|
}
|
|
}
|