mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-09 01:26:51 +00:00
d55978cf93
The setup for unit testing in Github in the "Install dependencies" log reports 11 members as "does not comply with with psr-4 autoloading standard." In each case, it is because the test namespace does not match the directory; in most cases, it was caused by the member being moved from one directory to another without changing the namespace declaration. No harm results from these problems, but there's also no reason to not correct them.
63 lines
1.8 KiB
PHP
63 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
|
|
|
|
class NamespacePurlTest extends \PHPUnit\Framework\TestCase
|
|
{
|
|
/**
|
|
* @var string
|
|
*/
|
|
private static $testbook = 'tests/data/Reader/XLSX/namespacepurl.xlsx';
|
|
|
|
public function testPreliminaries(): void
|
|
{
|
|
$file = 'zip://';
|
|
$file .= self::$testbook;
|
|
$file .= '#xl/workbook.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('http://purl.oclc.org/ooxml/', $data);
|
|
}
|
|
}
|
|
|
|
public function testPurlNamespace(): void
|
|
{
|
|
$filename = self::$testbook;
|
|
$reader = new Xlsx();
|
|
$actual = $reader->canRead($filename);
|
|
self::assertTrue($actual);
|
|
|
|
$sheets = $reader->listWorksheetNames($filename);
|
|
self::assertEquals(['ml_out'], $sheets);
|
|
|
|
$actual = $reader->listWorksheetInfo($filename);
|
|
$expected = [
|
|
[
|
|
'worksheetName' => 'ml_out',
|
|
'lastColumnLetter' => 'R',
|
|
'lastColumnIndex' => 17,
|
|
'totalRows' => '76',
|
|
'totalColumns' => 18,
|
|
],
|
|
];
|
|
|
|
self::assertEquals($expected, $actual);
|
|
}
|
|
|
|
public function testPurlLoad(): void
|
|
{
|
|
$filename = self::$testbook;
|
|
$reader = new Xlsx();
|
|
$spreadsheet = $reader->load($filename);
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
self::assertSame('ml_out', $sheet->getTitle());
|
|
self::assertSame('Item', $sheet->getCell('A1')->getValue());
|
|
self::assertEquals(97.91, $sheet->getCell('G3')->getValue());
|
|
}
|
|
}
|