PhpSpreadsheet/tests/PhpSpreadsheetTests/Chart/LegendTest.php

128 lines
3.4 KiB
PHP
Raw Permalink Normal View History

<?php
namespace PhpOffice\PhpSpreadsheetTests\Chart;
use PhpOffice\PhpSpreadsheet\Chart\Legend;
use PHPUnit\Framework\TestCase;
class LegendTest extends TestCase
{
2020-05-18 04:49:57 +00:00
public function testSetPosition(): void
2015-05-17 13:00:02 +00:00
{
$positionValues = [
Legend::POSITION_RIGHT,
Legend::POSITION_LEFT,
Legend::POSITION_TOP,
Legend::POSITION_BOTTOM,
Legend::POSITION_TOPRIGHT,
];
2015-05-17 13:00:02 +00:00
$testInstance = new Legend();
2015-05-17 13:00:02 +00:00
foreach ($positionValues as $positionValue) {
$result = $testInstance->setPosition($positionValue);
self::assertTrue($result);
2015-05-17 13:00:02 +00:00
}
}
2020-05-18 04:49:57 +00:00
public function testSetInvalidPositionReturnsFalse(): void
2015-05-17 13:00:02 +00:00
{
$testInstance = new Legend();
2015-05-17 13:00:02 +00:00
$result = $testInstance->setPosition('BottomLeft');
self::assertFalse($result);
2015-05-17 13:00:02 +00:00
// Ensure that value is unchanged
$result = $testInstance->getPosition();
self::assertEquals(Legend::POSITION_RIGHT, $result);
2015-05-17 13:00:02 +00:00
}
2020-05-18 04:49:57 +00:00
public function testGetPosition(): void
2015-05-17 13:00:02 +00:00
{
$PositionValue = Legend::POSITION_BOTTOM;
2015-05-17 13:00:02 +00:00
$testInstance = new Legend();
2017-10-29 05:09:38 +00:00
$testInstance->setPosition($PositionValue);
2015-05-17 13:00:02 +00:00
$result = $testInstance->getPosition();
self::assertEquals($PositionValue, $result);
2015-05-17 13:00:02 +00:00
}
2020-05-18 04:49:57 +00:00
public function testSetPositionXL(): void
2015-05-17 13:00:02 +00:00
{
$positionValues = [
Legend::XL_LEGEND_POSITION_BOTTOM,
Legend::XL_LEGEND_POSITION_CORNER,
Legend::XL_LEGEND_POSITION_CUSTOM,
Legend::XL_LEGEND_POSITION_LEFT,
Legend::XL_LEGEND_POSITION_RIGHT,
Legend::XL_LEGEND_POSITION_TOP,
];
2015-05-17 13:00:02 +00:00
$testInstance = new Legend();
2015-05-17 13:00:02 +00:00
foreach ($positionValues as $positionValue) {
$result = $testInstance->setPositionXL($positionValue);
self::assertTrue($result);
2015-05-17 13:00:02 +00:00
}
}
2020-05-18 04:49:57 +00:00
public function testSetInvalidXLPositionReturnsFalse(): void
2015-05-17 13:00:02 +00:00
{
$testInstance = new Legend();
2015-05-17 13:00:02 +00:00
$result = $testInstance->setPositionXL(999);
self::assertFalse($result);
2015-05-17 13:00:02 +00:00
// Ensure that value is unchanged
$result = $testInstance->getPositionXL();
self::assertEquals(Legend::XL_LEGEND_POSITION_RIGHT, $result);
2015-05-17 13:00:02 +00:00
}
2020-05-18 04:49:57 +00:00
public function testGetPositionXL(): void
2015-05-17 13:00:02 +00:00
{
$PositionValue = Legend::XL_LEGEND_POSITION_CORNER;
2015-05-17 13:00:02 +00:00
$testInstance = new Legend();
2017-10-29 05:09:38 +00:00
$testInstance->setPositionXL($PositionValue);
2015-05-17 13:00:02 +00:00
$result = $testInstance->getPositionXL();
self::assertEquals($PositionValue, $result);
2015-05-17 13:00:02 +00:00
}
2020-05-18 04:49:57 +00:00
public function testSetOverlay(): void
2015-05-17 13:00:02 +00:00
{
$overlayValues = [
2015-05-17 13:00:02 +00:00
true,
false,
];
2015-05-17 13:00:02 +00:00
$testInstance = new Legend();
2015-05-17 13:00:02 +00:00
foreach ($overlayValues as $overlayValue) {
$result = $testInstance->setOverlay($overlayValue);
self::assertTrue($result);
2015-05-17 13:00:02 +00:00
}
}
2020-05-18 04:49:57 +00:00
public function testSetInvalidOverlayReturnsFalse(): void
2015-05-17 13:00:02 +00:00
{
$testInstance = new Legend();
2015-05-17 13:00:02 +00:00
$result = $testInstance->setOverlay('INVALID');
self::assertFalse($result);
2015-05-17 13:00:02 +00:00
$result = $testInstance->getOverlay();
self::assertFalse($result);
2015-05-17 13:00:02 +00:00
}
2020-05-18 04:49:57 +00:00
public function testGetOverlay(): void
2015-05-17 13:00:02 +00:00
{
$OverlayValue = true;
$testInstance = new Legend();
2017-10-29 05:09:38 +00:00
$testInstance->setOverlay($OverlayValue);
2015-05-17 13:00:02 +00:00
$result = $testInstance->getOverlay();
self::assertEquals($OverlayValue, $result);
2015-05-17 13:00:02 +00:00
}
}