PhpSpreadsheet/tests/PhpSpreadsheetTests/Chart/DataSeriesValuesTest.php

51 lines
1.3 KiB
PHP
Raw Normal View History

<?php
namespace PhpOffice\PhpSpreadsheetTests\Chart;
use PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues;
use PhpOffice\PhpSpreadsheet\Exception;
use PHPUnit\Framework\TestCase;
class DataSeriesValuesTest extends TestCase
{
2015-05-17 13:00:02 +00:00
public function testSetDataType()
{
$dataTypeValues = [
2015-05-17 13:00:02 +00:00
'Number',
'String',
];
2015-05-17 13:00:02 +00:00
$testInstance = new DataSeriesValues();
2015-05-17 13:00:02 +00:00
foreach ($dataTypeValues as $dataTypeValue) {
$result = $testInstance->setDataType($dataTypeValue);
self::assertTrue($result instanceof DataSeriesValues);
2015-05-17 13:00:02 +00:00
}
}
public function testSetInvalidDataTypeThrowsException()
{
$testInstance = new DataSeriesValues();
2015-05-17 13:00:02 +00:00
try {
2016-08-26 06:05:40 +00:00
$testInstance->setDataType('BOOLEAN');
} catch (Exception $e) {
self::assertEquals($e->getMessage(), 'Invalid datatype for chart data series values');
2015-05-17 13:00:02 +00:00
return;
}
$this->fail('An expected exception has not been raised.');
}
public function testGetDataType()
{
$dataTypeValue = 'String';
$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();
self::assertEquals($dataTypeValue, $result);
2015-05-17 13:00:02 +00:00
}
}