Files
oleibman 29c0162e2a Let Phpstan Run on Samples (#3808)
* Let Phpstan Run on Samples

Phpstan currently analyzes all source and test members. We already run phpcs and php-cs-fixer on samples as well. I would expect that samples are often used as templates for code in userland; it behooves us to be at least as careful with those members as for the others which are already being analyzed.  Aside from 1300+ messages `Variable $helper might not be defined.`, which will be suppressed in phpstan.neon.dist, there are really only a few changes needed for sample members, so that part of the code base was already in good shape, and is now even better. No annotations were needed.

* Scrutinizer 2 out of 3

1 false positive, now suppressed; fix other 2.

* Remove Dead Code

* Very Minor Changes

* Add infra
2023-12-06 09:40:27 -08:00

49 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpOffice\PhpSpreadsheetTests\Chart;
use PhpOffice\PhpSpreadsheet\Chart\Chart;
use PhpOffice\PhpSpreadsheet\Chart\DataSeries;
use PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues;
use PhpOffice\PhpSpreadsheet\Chart\Exception as ChartException;
use PhpOffice\PhpSpreadsheet\Chart\PlotArea;
use PHPUnit\Framework\TestCase;
class PlotAreaTest extends TestCase
{
public function testPlotArea(): void
{
$dataSeriesValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, null, null, 4, [1, 2, 3, 4]),
];
// Build the dataseries
$series = new DataSeries(
plotType: DataSeries::TYPE_AREACHART,
plotGrouping: DataSeries::GROUPING_PERCENT_STACKED,
plotOrder: range(0, count($dataSeriesValues) - 1),
plotValues: $dataSeriesValues
);
// Set the series in the plot area
$plotArea = new PlotArea(null, [$series]);
// Create the chart
$chart = new Chart(
'chart1', // name
plotArea: $plotArea,
);
self::assertNotNull($chart->getPlotAreaOrThrow());
}
public function testNoPlotArea(): void
{
$chart = new Chart('chart1');
$this->expectException(ChartException::class);
$this->expectExceptionMessage('Chart has no PlotArea');
$chart->getPlotAreaOrThrow();
}
}