PhpSpreadsheet/tests/PhpSpreadsheetTests/Chart/LegendTest.php

127 lines
3.4 KiB
PHP
Raw Normal View History

<?php
namespace PhpOffice\PhpSpreadsheetTests\Chart;
use PhpOffice\PhpSpreadsheet\Chart\Legend;
2016-03-22 14:35:50 +00:00
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);
$this->assertTrue($result);
}
}
public function testSetInvalidPositionReturnsFalse()
{
$testInstance = new Legend();
2015-05-17 13:00:02 +00:00
$result = $testInstance->setPosition('BottomLeft');
$this->assertFalse($result);
// Ensure that value is unchanged
$result = $testInstance->getPosition();
$this->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();
2015-05-17 16:34:30 +00:00
$this->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);
$this->assertTrue($result);
}
}
public function testSetInvalidXLPositionReturnsFalse()
{
$testInstance = new Legend();
2015-05-17 13:00:02 +00:00
$result = $testInstance->setPositionXL(999);
$this->assertFalse($result);
// Ensure that value is unchanged
$result = $testInstance->getPositionXL();
$this->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();
2015-05-17 16:34:30 +00:00
$this->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);
$this->assertTrue($result);
}
}
public function testSetInvalidOverlayReturnsFalse()
{
$testInstance = new 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;
$testInstance = new 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
}
}