mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-22 13:23:41 +00:00
ec4098c8fd
While we might never be able to have 100% of our code strict, we can at the very least do it for all of our tests. This ensures that our tests are using our API with the types as intended by the test author, and not silently be cast to what our API requires.
58 lines
1.8 KiB
PHP
58 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Worksheet;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Helper\Dimension;
|
|
use PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ColumnDimensionTest extends TestCase
|
|
{
|
|
public function testInstantiateColumnDimensionDefault(): void
|
|
{
|
|
$expected = 'A';
|
|
$columnDimension = new ColumnDimension();
|
|
self::assertInstanceOf(ColumnDimension::class, $columnDimension);
|
|
$result = $columnDimension->getColumnIndex();
|
|
self::assertEquals($expected, $result);
|
|
}
|
|
|
|
public function testGetAndSetColumnIndex(): void
|
|
{
|
|
$expected = 'B';
|
|
$columnDimension = new ColumnDimension();
|
|
$columnDimension->setColumnIndex($expected);
|
|
$result = $columnDimension->getColumnIndex();
|
|
self::assertSame($expected, $result);
|
|
}
|
|
|
|
public function testGetAndSetWidth(): void
|
|
{
|
|
$expected = 1.2;
|
|
$columnDimension = new ColumnDimension();
|
|
|
|
$columnDimension->setWidth($expected);
|
|
$result = $columnDimension->getWidth();
|
|
self::assertSame($expected, $result);
|
|
|
|
$expectedPx = 32.0;
|
|
$expectedPt = 24.0;
|
|
$columnDimension->setWidth($expectedPx, Dimension::UOM_PIXELS);
|
|
$resultPx = $columnDimension->getWidth(Dimension::UOM_PIXELS);
|
|
self::assertSame($expectedPx, $resultPx);
|
|
$resultPt = $columnDimension->getWidth(Dimension::UOM_POINTS);
|
|
self::assertSame($expectedPt, $resultPt);
|
|
}
|
|
|
|
public function testGetAndSetAutoSize(): void
|
|
{
|
|
$expected = true;
|
|
$columnDimension = new ColumnDimension();
|
|
$columnDimension->setAutoSize($expected);
|
|
$result = $columnDimension->getAutoSize();
|
|
self::assertTrue($result);
|
|
}
|
|
}
|