mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-30 20:18:00 +00:00
More Minor Tweaks
This commit is contained in:
@@ -6,24 +6,40 @@ namespace PhpOffice\PhpSpreadsheetTests\Helper;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Helper\Dimension;
|
||||
use PhpOffice\PhpSpreadsheet\Helper\Size;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DimensionTest extends TestCase
|
||||
{
|
||||
#[\PHPUnit\Framework\Attributes\DataProvider('providerCellWidth')]
|
||||
#[DataProvider('providerCellWidth')]
|
||||
public function testCreateDimension(float $expectedResult, string $dimension): void
|
||||
{
|
||||
$result = (new Dimension($dimension))->width();
|
||||
self::assertSame($expectedResult, $result);
|
||||
}
|
||||
|
||||
#[\PHPUnit\Framework\Attributes\DataProvider('providerConvertUoM')]
|
||||
#[DataProvider('providerConvertUoM')]
|
||||
public function testConvertDimension(float $expectedResult, string $dimension, string $unitOfMeasure): void
|
||||
{
|
||||
$result = (new Dimension($dimension))->toUnit($unitOfMeasure);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12);
|
||||
}
|
||||
|
||||
public function testSizeAndUnit(): void
|
||||
{
|
||||
$size = new Size('10px');
|
||||
self::assertTrue($size->valid());
|
||||
self::assertSame('10', $size->size());
|
||||
self::assertSame('px', $size->unit());
|
||||
$size = new Size('9.3');
|
||||
self::assertTrue($size->valid());
|
||||
self::assertSame('9.3', $size->size());
|
||||
self::assertSame('pt', $size->unit());
|
||||
$size = new Size('8whatever');
|
||||
self::assertFalse($size->valid());
|
||||
}
|
||||
|
||||
public function testConvertDimensionInvalidUoM(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
|
||||
@@ -35,4 +35,19 @@ class SampleCoverageTest extends TestCase
|
||||
->willReturn(false);
|
||||
$helper->getFilename('a.xlsx');
|
||||
}
|
||||
|
||||
public function testTitles(): void
|
||||
{
|
||||
$helper = new Sample();
|
||||
ob_start();
|
||||
$helper->titles('Category', 'FunctionName');
|
||||
$output = (string) ob_get_clean();
|
||||
$output = str_replace("\r", '', $output);
|
||||
self::assertStringContainsString("Function: FunctionName()\n", $output);
|
||||
ob_start();
|
||||
$helper->titles('Category', 'FunctionName', 'Description');
|
||||
$output = (string) ob_get_clean();
|
||||
$output = str_replace("\r", '', $output);
|
||||
self::assertStringContainsString("Function: FunctionName() - Description.\n", $output);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,4 +108,13 @@ class FontTest extends TestCase
|
||||
$font2bHash = $font2->getHashCode();
|
||||
self::assertNotEquals($font1->getHashCode(), $font2bHash);
|
||||
}
|
||||
|
||||
public function testAutoColorSupervisor(): void
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$sheet->getStyle('A1')->getFont()->setAutoColor(true);
|
||||
self::assertTrue($sheet->getStyle('A1')->getFont()->getAutoColor());
|
||||
$spreadsheet->disconnectWorksheets();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user