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\DataSeriesValues;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Exception;
|
2016-08-14 04:08:43 +00:00
|
|
|
|
2016-03-22 14:35:50 +00:00
|
|
|
class DataSeriesValuesTest extends \PHPUnit_Framework_TestCase
|
2012-06-24 12:34:57 +00:00
|
|
|
{
|
2015-05-17 13:00:02 +00:00
|
|
|
public function testSetDataType()
|
|
|
|
{
|
2016-08-16 15:33:57 +00:00
|
|
|
$dataTypeValues = [
|
2015-05-17 13:00:02 +00:00
|
|
|
'Number',
|
2016-08-16 15:33:57 +00:00
|
|
|
'String',
|
|
|
|
];
|
2015-05-17 13:00:02 +00:00
|
|
|
|
2016-08-16 15:33:57 +00:00
|
|
|
$testInstance = new DataSeriesValues();
|
2015-05-17 13:00:02 +00:00
|
|
|
|
|
|
|
foreach ($dataTypeValues as $dataTypeValue) {
|
|
|
|
$result = $testInstance->setDataType($dataTypeValue);
|
2016-08-14 04:08:43 +00:00
|
|
|
$this->assertTrue($result instanceof DataSeriesValues);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetInvalidDataTypeThrowsException()
|
|
|
|
{
|
2016-08-16 15:33:57 +00:00
|
|
|
$testInstance = new DataSeriesValues();
|
2015-05-17 13:00:02 +00:00
|
|
|
|
|
|
|
try {
|
2016-08-26 06:05:40 +00:00
|
|
|
$testInstance->setDataType('BOOLEAN');
|
2016-08-14 04:08:43 +00:00
|
|
|
} catch (Exception $e) {
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($e->getMessage(), 'Invalid datatype for chart data series values');
|
2016-08-16 15:33:57 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$this->fail('An expected exception has not been raised.');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetDataType()
|
|
|
|
{
|
|
|
|
$dataTypeValue = 'String';
|
|
|
|
|
2016-08-16 15:33:57 +00:00
|
|
|
$testInstance = new DataSeriesValues();
|
2016-08-26 06:05:40 +00:00
|
|
|
$testInstance->setDataType($dataTypeValue);
|
2015-05-17 13:00:02 +00:00
|
|
|
|
|
|
|
$result = $testInstance->getDataType();
|
2015-05-17 16:34:30 +00:00
|
|
|
$this->assertEquals($dataTypeValue, $result);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-06-24 12:34:57 +00:00
|
|
|
}
|