2012-06-24 12:34:57 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
class LegendTest extends PHPUnit_Framework_TestCase
|
|
|
|
{
|
2015-05-17 13:00:02 +00:00
|
|
|
public function testSetPosition()
|
|
|
|
{
|
|
|
|
$positionValues = array(
|
2016-03-22 14:19:00 +00:00
|
|
|
\PHPExcel\Chart\Legend::POSITION_RIGHT,
|
|
|
|
\PHPExcel\Chart\Legend::POSITION_LEFT,
|
|
|
|
\PHPExcel\Chart\Legend::POSITION_TOP,
|
|
|
|
\PHPExcel\Chart\Legend::POSITION_BOTTOM,
|
|
|
|
\PHPExcel\Chart\Legend::POSITION_TOPRIGHT,
|
2015-05-17 13:00:02 +00:00
|
|
|
);
|
|
|
|
|
2016-03-22 14:19:00 +00:00
|
|
|
$testInstance = new \PHPExcel\Chart\Legend;
|
2015-05-17 13:00:02 +00:00
|
|
|
|
|
|
|
foreach ($positionValues as $positionValue) {
|
|
|
|
$result = $testInstance->setPosition($positionValue);
|
|
|
|
$this->assertTrue($result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetInvalidPositionReturnsFalse()
|
|
|
|
{
|
2016-03-22 14:19:00 +00:00
|
|
|
$testInstance = new \PHPExcel\Chart\Legend;
|
2015-05-17 13:00:02 +00:00
|
|
|
|
|
|
|
$result = $testInstance->setPosition('BottomLeft');
|
|
|
|
$this->assertFalse($result);
|
|
|
|
// Ensure that value is unchanged
|
|
|
|
$result = $testInstance->getPosition();
|
2016-03-22 14:19:00 +00:00
|
|
|
$this->assertEquals(\PHPExcel\Chart\Legend::POSITION_RIGHT, $result);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPosition()
|
|
|
|
{
|
2016-03-22 14:19:00 +00:00
|
|
|
$PositionValue = \PHPExcel\Chart\Legend::POSITION_BOTTOM;
|
2015-05-17 13:00:02 +00:00
|
|
|
|
2016-03-22 14:19:00 +00:00
|
|
|
$testInstance = new \PHPExcel\Chart\Legend;
|
2015-05-17 13:00:02 +00:00
|
|
|
$setValue = $testInstance->setPosition($PositionValue);
|
|
|
|
|
|
|
|
$result = $testInstance->getPosition();
|
2015-05-17 16:34:30 +00:00
|
|
|
$this->assertEquals($PositionValue, $result);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetPositionXL()
|
|
|
|
{
|
|
|
|
$positionValues = array(
|
2016-03-22 14:19:00 +00:00
|
|
|
\PHPExcel\Chart\Legend::xlLegendPositionBottom,
|
|
|
|
\PHPExcel\Chart\Legend::xlLegendPositionCorner,
|
|
|
|
\PHPExcel\Chart\Legend::xlLegendPositionCustom,
|
|
|
|
\PHPExcel\Chart\Legend::xlLegendPositionLeft,
|
|
|
|
\PHPExcel\Chart\Legend::xlLegendPositionRight,
|
|
|
|
\PHPExcel\Chart\Legend::xlLegendPositionTop,
|
2015-05-17 13:00:02 +00:00
|
|
|
);
|
|
|
|
|
2016-03-22 14:19:00 +00:00
|
|
|
$testInstance = new \PHPExcel\Chart\Legend;
|
2015-05-17 13:00:02 +00:00
|
|
|
|
|
|
|
foreach ($positionValues as $positionValue) {
|
|
|
|
$result = $testInstance->setPositionXL($positionValue);
|
|
|
|
$this->assertTrue($result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetInvalidXLPositionReturnsFalse()
|
|
|
|
{
|
2016-03-22 14:19:00 +00:00
|
|
|
$testInstance = new \PHPExcel\Chart\Legend;
|
2015-05-17 13:00:02 +00:00
|
|
|
|
|
|
|
$result = $testInstance->setPositionXL(999);
|
|
|
|
$this->assertFalse($result);
|
|
|
|
// Ensure that value is unchanged
|
|
|
|
$result = $testInstance->getPositionXL();
|
2016-03-22 14:19:00 +00:00
|
|
|
$this->assertEquals(\PHPExcel\Chart\Legend::xlLegendPositionRight, $result);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPositionXL()
|
|
|
|
{
|
2016-03-22 14:19:00 +00:00
|
|
|
$PositionValue = \PHPExcel\Chart\Legend::xlLegendPositionCorner;
|
2015-05-17 13:00:02 +00:00
|
|
|
|
2016-03-22 14:19:00 +00:00
|
|
|
$testInstance = new \PHPExcel\Chart\Legend;
|
2015-05-17 13:00:02 +00:00
|
|
|
$setValue = $testInstance->setPositionXL($PositionValue);
|
|
|
|
|
|
|
|
$result = $testInstance->getPositionXL();
|
2015-05-17 16:34:30 +00:00
|
|
|
$this->assertEquals($PositionValue, $result);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetOverlay()
|
|
|
|
{
|
|
|
|
$overlayValues = array(
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
);
|
|
|
|
|
2016-03-22 14:19:00 +00:00
|
|
|
$testInstance = new \PHPExcel\Chart\Legend;
|
2015-05-17 13:00:02 +00:00
|
|
|
|
|
|
|
foreach ($overlayValues as $overlayValue) {
|
|
|
|
$result = $testInstance->setOverlay($overlayValue);
|
|
|
|
$this->assertTrue($result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetInvalidOverlayReturnsFalse()
|
|
|
|
{
|
2016-03-22 14:19:00 +00:00
|
|
|
$testInstance = new \PHPExcel\Chart\Legend;
|
2015-05-17 13:00:02 +00:00
|
|
|
|
|
|
|
$result = $testInstance->setOverlay('INVALID');
|
|
|
|
$this->assertFalse($result);
|
|
|
|
|
|
|
|
$result = $testInstance->getOverlay();
|
|
|
|
$this->assertFalse($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetOverlay()
|
|
|
|
{
|
|
|
|
$OverlayValue = true;
|
|
|
|
|
2016-03-22 14:19:00 +00:00
|
|
|
$testInstance = new \PHPExcel\Chart\Legend;
|
2015-05-17 13:00:02 +00:00
|
|
|
$setValue = $testInstance->setOverlay($OverlayValue);
|
|
|
|
|
|
|
|
$result = $testInstance->getOverlay();
|
2015-05-17 16:34:30 +00:00
|
|
|
$this->assertEquals($OverlayValue, $result);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-06-24 12:34:57 +00:00
|
|
|
}
|