2012-06-24 12:34:57 +00:00
|
|
|
<?php
|
|
|
|
|
2016-08-31 17:18:12 +00:00
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Chart;
|
2012-06-24 12:34:57 +00:00
|
|
|
|
2016-08-31 17:18:12 +00:00
|
|
|
use PhpOffice\PhpSpreadsheet\Chart\Legend;
|
2017-05-17 22:02:17 +00:00
|
|
|
use PHPUnit_Framework_TestCase;
|
2016-08-14 04:08:43 +00:00
|
|
|
|
2017-05-17 22:02:17 +00:00
|
|
|
class LegendTest extends PHPUnit_Framework_TestCase
|
2012-06-24 12:34:57 +00:00
|
|
|
{
|
2015-05-17 13:00:02 +00:00
|
|
|
public function testSetPosition()
|
|
|
|
{
|
2016-08-16 15:33:57 +00:00
|
|
|
$positionValues = [
|
2016-08-14 04:08:43 +00:00
|
|
|
Legend::POSITION_RIGHT,
|
|
|
|
Legend::POSITION_LEFT,
|
|
|
|
Legend::POSITION_TOP,
|
|
|
|
Legend::POSITION_BOTTOM,
|
|
|
|
Legend::POSITION_TOPRIGHT,
|
2016-08-16 15:33:57 +00:00
|
|
|
];
|
2015-05-17 13:00:02 +00:00
|
|
|
|
2016-08-16 15:33:57 +00:00
|
|
|
$testInstance = new Legend();
|
2015-05-17 13:00:02 +00:00
|
|
|
|
|
|
|
foreach ($positionValues as $positionValue) {
|
|
|
|
$result = $testInstance->setPosition($positionValue);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertTrue($result);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetInvalidPositionReturnsFalse()
|
|
|
|
{
|
2016-08-16 15:33:57 +00:00
|
|
|
$testInstance = new Legend();
|
2015-05-17 13:00:02 +00:00
|
|
|
|
|
|
|
$result = $testInstance->setPosition('BottomLeft');
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertFalse($result);
|
2015-05-17 13:00:02 +00:00
|
|
|
// Ensure that value is unchanged
|
|
|
|
$result = $testInstance->getPosition();
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals(Legend::POSITION_RIGHT, $result);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPosition()
|
|
|
|
{
|
2016-08-14 04:08:43 +00:00
|
|
|
$PositionValue = Legend::POSITION_BOTTOM;
|
2015-05-17 13:00:02 +00:00
|
|
|
|
2016-08-16 15:33:57 +00:00
|
|
|
$testInstance = new Legend();
|
2015-05-17 13:00:02 +00:00
|
|
|
$setValue = $testInstance->setPosition($PositionValue);
|
|
|
|
|
|
|
|
$result = $testInstance->getPosition();
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($PositionValue, $result);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetPositionXL()
|
|
|
|
{
|
2016-08-16 15:33:57 +00:00
|
|
|
$positionValues = [
|
2016-08-14 04:08:43 +00:00
|
|
|
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,
|
2016-08-16 15:33:57 +00:00
|
|
|
];
|
2015-05-17 13:00:02 +00:00
|
|
|
|
2016-08-16 15:33:57 +00:00
|
|
|
$testInstance = new Legend();
|
2015-05-17 13:00:02 +00:00
|
|
|
|
|
|
|
foreach ($positionValues as $positionValue) {
|
|
|
|
$result = $testInstance->setPositionXL($positionValue);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertTrue($result);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetInvalidXLPositionReturnsFalse()
|
|
|
|
{
|
2016-08-16 15:33:57 +00:00
|
|
|
$testInstance = new Legend();
|
2015-05-17 13:00:02 +00:00
|
|
|
|
|
|
|
$result = $testInstance->setPositionXL(999);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertFalse($result);
|
2015-05-17 13:00:02 +00:00
|
|
|
// Ensure that value is unchanged
|
|
|
|
$result = $testInstance->getPositionXL();
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals(Legend::XL_LEGEND_POSITION_RIGHT, $result);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPositionXL()
|
|
|
|
{
|
2016-08-14 04:08:43 +00:00
|
|
|
$PositionValue = Legend::XL_LEGEND_POSITION_CORNER;
|
2015-05-17 13:00:02 +00:00
|
|
|
|
2016-08-16 15:33:57 +00:00
|
|
|
$testInstance = new Legend();
|
2015-05-17 13:00:02 +00:00
|
|
|
$setValue = $testInstance->setPositionXL($PositionValue);
|
|
|
|
|
|
|
|
$result = $testInstance->getPositionXL();
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($PositionValue, $result);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetOverlay()
|
|
|
|
{
|
2016-08-16 15:33:57 +00:00
|
|
|
$overlayValues = [
|
2015-05-17 13:00:02 +00:00
|
|
|
true,
|
|
|
|
false,
|
2016-08-16 15:33:57 +00:00
|
|
|
];
|
2015-05-17 13:00:02 +00:00
|
|
|
|
2016-08-16 15:33:57 +00:00
|
|
|
$testInstance = new Legend();
|
2015-05-17 13:00:02 +00:00
|
|
|
|
|
|
|
foreach ($overlayValues as $overlayValue) {
|
|
|
|
$result = $testInstance->setOverlay($overlayValue);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertTrue($result);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetInvalidOverlayReturnsFalse()
|
|
|
|
{
|
2016-08-16 15:33:57 +00:00
|
|
|
$testInstance = new Legend();
|
2015-05-17 13:00:02 +00:00
|
|
|
|
|
|
|
$result = $testInstance->setOverlay('INVALID');
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertFalse($result);
|
2015-05-17 13:00:02 +00:00
|
|
|
|
|
|
|
$result = $testInstance->getOverlay();
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertFalse($result);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetOverlay()
|
|
|
|
{
|
|
|
|
$OverlayValue = true;
|
|
|
|
|
2016-08-16 15:33:57 +00:00
|
|
|
$testInstance = new Legend();
|
2015-05-17 13:00:02 +00:00
|
|
|
$setValue = $testInstance->setOverlay($OverlayValue);
|
|
|
|
|
|
|
|
$result = $testInstance->getOverlay();
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($OverlayValue, $result);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-06-24 12:34:57 +00:00
|
|
|
}
|