aef4d711f5
Because even if it doesn't make a difference in practice, it is technically more correct to call static methods statically. It also better advertise that those methods can be used from any context.
128 lines
3.4 KiB
PHP
128 lines
3.4 KiB
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Chart;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Chart\Legend;
|
|
use PHPUnit_Framework_TestCase;
|
|
|
|
class LegendTest extends PHPUnit_Framework_TestCase
|
|
{
|
|
public function testSetPosition()
|
|
{
|
|
$positionValues = [
|
|
Legend::POSITION_RIGHT,
|
|
Legend::POSITION_LEFT,
|
|
Legend::POSITION_TOP,
|
|
Legend::POSITION_BOTTOM,
|
|
Legend::POSITION_TOPRIGHT,
|
|
];
|
|
|
|
$testInstance = new Legend();
|
|
|
|
foreach ($positionValues as $positionValue) {
|
|
$result = $testInstance->setPosition($positionValue);
|
|
self::assertTrue($result);
|
|
}
|
|
}
|
|
|
|
public function testSetInvalidPositionReturnsFalse()
|
|
{
|
|
$testInstance = new Legend();
|
|
|
|
$result = $testInstance->setPosition('BottomLeft');
|
|
self::assertFalse($result);
|
|
// Ensure that value is unchanged
|
|
$result = $testInstance->getPosition();
|
|
self::assertEquals(Legend::POSITION_RIGHT, $result);
|
|
}
|
|
|
|
public function testGetPosition()
|
|
{
|
|
$PositionValue = Legend::POSITION_BOTTOM;
|
|
|
|
$testInstance = new Legend();
|
|
$setValue = $testInstance->setPosition($PositionValue);
|
|
|
|
$result = $testInstance->getPosition();
|
|
self::assertEquals($PositionValue, $result);
|
|
}
|
|
|
|
public function testSetPositionXL()
|
|
{
|
|
$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,
|
|
];
|
|
|
|
$testInstance = new Legend();
|
|
|
|
foreach ($positionValues as $positionValue) {
|
|
$result = $testInstance->setPositionXL($positionValue);
|
|
self::assertTrue($result);
|
|
}
|
|
}
|
|
|
|
public function testSetInvalidXLPositionReturnsFalse()
|
|
{
|
|
$testInstance = new Legend();
|
|
|
|
$result = $testInstance->setPositionXL(999);
|
|
self::assertFalse($result);
|
|
// Ensure that value is unchanged
|
|
$result = $testInstance->getPositionXL();
|
|
self::assertEquals(Legend::XL_LEGEND_POSITION_RIGHT, $result);
|
|
}
|
|
|
|
public function testGetPositionXL()
|
|
{
|
|
$PositionValue = Legend::XL_LEGEND_POSITION_CORNER;
|
|
|
|
$testInstance = new Legend();
|
|
$setValue = $testInstance->setPositionXL($PositionValue);
|
|
|
|
$result = $testInstance->getPositionXL();
|
|
self::assertEquals($PositionValue, $result);
|
|
}
|
|
|
|
public function testSetOverlay()
|
|
{
|
|
$overlayValues = [
|
|
true,
|
|
false,
|
|
];
|
|
|
|
$testInstance = new Legend();
|
|
|
|
foreach ($overlayValues as $overlayValue) {
|
|
$result = $testInstance->setOverlay($overlayValue);
|
|
self::assertTrue($result);
|
|
}
|
|
}
|
|
|
|
public function testSetInvalidOverlayReturnsFalse()
|
|
{
|
|
$testInstance = new Legend();
|
|
|
|
$result = $testInstance->setOverlay('INVALID');
|
|
self::assertFalse($result);
|
|
|
|
$result = $testInstance->getOverlay();
|
|
self::assertFalse($result);
|
|
}
|
|
|
|
public function testGetOverlay()
|
|
{
|
|
$OverlayValue = true;
|
|
|
|
$testInstance = new Legend();
|
|
$setValue = $testInstance->setOverlay($OverlayValue);
|
|
|
|
$result = $testInstance->getOverlay();
|
|
self::assertEquals($OverlayValue, $result);
|
|
}
|
|
}
|