PhpSpreadsheet/tests/PhpSpreadsheetTests/Chart/LegendTest.php

128 lines
3.4 KiB
PHP
Raw Normal View History

<?php
namespace PhpOffice\PhpSpreadsheetTests\Chart;
use PhpOffice\PhpSpreadsheet\Chart\Legend;
use PHPUnit_Framework_TestCase;
class LegendTest extends PHPUnit_Framework_TestCase
{
2015-05-17 13:00:02 +00:00
public function testSetPosition()
{
$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
}
}
public function testSetInvalidPositionReturnsFalse()
{
$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
}
public function testGetPosition()
{
$PositionValue = Legend::POSITION_BOTTOM;
2015-05-17 13:00:02 +00:00
$testInstance = new Legend();
2015-05-17 13:00:02 +00:00
$setValue = $testInstance->setPosition($PositionValue);
$result = $testInstance->getPosition();
self::assertEquals($PositionValue, $result);
2015-05-17 13:00:02 +00:00
}
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,
];
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
}
}
public function testSetInvalidXLPositionReturnsFalse()
{
$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
}
public function testGetPositionXL()
{
$PositionValue = Legend::XL_LEGEND_POSITION_CORNER;
2015-05-17 13:00:02 +00:00
$testInstance = new Legend();
2015-05-17 13:00:02 +00:00
$setValue = $testInstance->setPositionXL($PositionValue);
$result = $testInstance->getPositionXL();
self::assertEquals($PositionValue, $result);
2015-05-17 13:00:02 +00:00
}
public function testSetOverlay()
{
$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
}
}
public function testSetInvalidOverlayReturnsFalse()
{
$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
}
public function testGetOverlay()
{
$OverlayValue = true;
$testInstance = new Legend();
2015-05-17 13:00:02 +00:00
$setValue = $testInstance->setOverlay($OverlayValue);
$result = $testInstance->getOverlay();
self::assertEquals($OverlayValue, $result);
2015-05-17 13:00:02 +00:00
}
}