mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-22 16:19:19 +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.
44 lines
1.4 KiB
PHP
44 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;
|
|
|
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
|
use PhpOffice\PhpSpreadsheet\Reader\IReader;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class SharedFormulaTest extends TestCase
|
|
{
|
|
/**
|
|
* @var string
|
|
*/
|
|
private static $testbook = 'samples/templates/32readwriteAreaChart1.xlsx';
|
|
|
|
public function testPreliminaries(): void
|
|
{
|
|
$file = 'zip://';
|
|
$file .= self::$testbook;
|
|
$file .= '#xl/worksheets/sheet1.xml';
|
|
$data = file_get_contents($file);
|
|
// confirm that file contains shared formula
|
|
if ($data === false) {
|
|
self::fail('Unable to read file');
|
|
} else {
|
|
self::assertStringContainsString('<c r="D6"><f t="shared" ca="1" si="0"/>', $data);
|
|
self::assertStringContainsString('<c r="E6"><f t="shared" ca="1" si="0"/>', $data);
|
|
}
|
|
}
|
|
|
|
public function testLoadSheetsXlsxChart(): void
|
|
{
|
|
$filename = self::$testbook;
|
|
$reader = IOFactory::createReader('Xlsx');
|
|
$spreadsheet = $reader->load($filename, IReader::LOAD_WITH_CHARTS);
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
self::assertSame('=(RANDBETWEEN(-50,250)+100)*10', $sheet->getCell('D6')->getValue());
|
|
self::assertSame('=(RANDBETWEEN(-50,250)+100)*10', $sheet->getCell('E6')->getValue());
|
|
$spreadsheet->disconnectWorksheets();
|
|
}
|
|
}
|