mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-20 09:23:35 +00:00
ec4098c8fd
While we might never be able to have 100% of our code strict, we can at the very least do it for all of our tests. This ensures that our tests are using our API with the types as intended by the test author, and not silently be cast to what our API requires.
45 lines
1.6 KiB
PHP
45 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Chart;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Reader\Xlsx as XlsxReader;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class Issue2965Test extends TestCase
|
|
{
|
|
private const DIRECTORY = 'tests' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'Reader' . DIRECTORY_SEPARATOR . 'XLSX' . DIRECTORY_SEPARATOR;
|
|
|
|
public function testPreliminaries(): void
|
|
{
|
|
$file = 'zip://';
|
|
$file .= self::DIRECTORY . 'issue.2965.xlsx';
|
|
$file .= '#xl/charts/chart1.xml';
|
|
$data = file_get_contents($file);
|
|
// confirm that file contains expected namespaced xml tag
|
|
if ($data === false) {
|
|
self::fail('Unable to read file');
|
|
} else {
|
|
self::assertStringContainsString('<c:title><c:tx><c:strRef><c:f>Sheet1!$A$1</c:f><c:strCache><c:ptCount val="1"/><c:pt idx="0"><c:v>NewTitle</c:v></c:pt></c:strCache></c:strRef></c:tx>', $data);
|
|
}
|
|
}
|
|
|
|
public function testChartTitleFormula(): void
|
|
{
|
|
$reader = new XlsxReader();
|
|
$reader->setIncludeCharts(true);
|
|
$spreadsheet = $reader->load(self::DIRECTORY . 'issue.2965.xlsx');
|
|
$worksheet = $spreadsheet->getActiveSheet();
|
|
$charts = $worksheet->getChartCollection();
|
|
self::assertCount(1, $charts);
|
|
$originalChart1 = $charts[0];
|
|
self::assertNotNull($originalChart1);
|
|
$originalTitle1 = $originalChart1->getTitle();
|
|
self::assertNotNull($originalTitle1);
|
|
self::assertSame('NewTitle', $originalTitle1->getCaptionText());
|
|
|
|
$spreadsheet->disconnectWorksheets();
|
|
}
|
|
}
|