Skip to content

Commit

Permalink
Additional Coverage For Xml Reader
Browse files Browse the repository at this point in the history
No source code changes.
  • Loading branch information
oleibman committed Dec 30, 2024
1 parent 04b15c0 commit 38c4ce4
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/PhpSpreadsheetTests/Reader/Xml/DataValidationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class DataValidationsTest extends AbstractFunctional
{
private string $filename = 'tests/data/Reader/Xml/datavalidations.xml';

private string $filename2 = 'tests/data/Reader/Xml/datavalidations.wholerow.xml';

public function testValidation(): void
{
$reader = new Xml();
Expand All @@ -34,6 +36,27 @@ public function testValidation(): void
$spreadsheet->disconnectWorksheets();
}

public function testValidationWholeRow(): void
{
$reader = new Xml();
$spreadsheet = $reader->load($this->filename2);
$sheet = $spreadsheet->getActiveSheet();
$collection = $sheet->getDataValidationCollection();
self::assertSame(['A1', 'A1:XFD1'], array_keys($collection));
$dv = $collection['A1'];
self::assertSame('"Item A,Item B,Item D"', $dv->getFormula1());
self::assertSame('warn', $dv->getErrorStyle());
self::assertFalse($dv->getShowDropDown());
self::assertFalse($dv->getShowErrorMessage());

$dv = $collection['A1:XFD1'];
self::assertSame('"Item A,Item B,Item C"', $dv->getFormula1());
self::assertSame('stop', $dv->getErrorStyle());
self::assertTrue($dv->getShowDropDown());
self::assertTrue($dv->getShowErrorMessage());
$spreadsheet->disconnectWorksheets();
}

public function testValidationXlsx(): void
{
$reader = new Xml();
Expand Down
83 changes: 83 additions & 0 deletions tests/data/Reader/Xml/datavalidations.wholerow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Title>Untitled Spreadsheet</Title>
<Author>Unknown Creator</Author>
<LastAuthor>Owen Leibman</LastAuthor>
<Created>2024-12-30T08:21:15Z</Created>
<LastSaved>2024-12-30T08:21:15Z</LastSaved>
<Version>16.00</Version>
</DocumentProperties>
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
<AllowPNG/>
</OfficeDocumentSettings>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>6510</WindowHeight>
<WindowWidth>19200</WindowWidth>
<WindowTopX>32767</WindowTopX>
<WindowTopY>32767</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font ss:FontName="Calibri" ss:Size="11" ss:Color="#000000"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
</Styles>
<Worksheet ss:Name="Worksheet">
<Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1"
x:FullRows="1" ss:DefaultRowHeight="14.5">
<Row ss:AutoFitHeight="0"/>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Unsynced/>
<Print>
<ValidPrinterInfo/>
<NoOrientation/>
<HorizontalResolution>600</HorizontalResolution>
<VerticalResolution>600</VerticalResolution>
</Print>
<Selected/>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
<DataValidation xmlns="urn:schemas-microsoft-com:office:excel">
<Range>R1</Range>
<Type>List</Type>
<UseBlank/>
<CellRangeList/>
<Value>&quot;Item A,Item B,Item C&quot;</Value>
<InputHide/>
<ErrorMessage>Value is not a member of allowed list</ErrorMessage>
<ErrorTitle>Input Error</ErrorTitle>
</DataValidation>
<DataValidation xmlns="urn:schemas-microsoft-com:office:excel">
<Range>R1C1</Range>
<Type>List</Type>
<UseBlank/>
<CellRangeList/>
<Value>&quot;Item A,Item B,Item D&quot;</Value>
<InputHide/>
<ComboHide/>
<ErrorHide/>
<ErrorStyle>Warn</ErrorStyle>
<ErrorMessage>Value is not a member of allowed list</ErrorMessage>
<ErrorTitle>Input Error</ErrorTitle>
</DataValidation>
</Worksheet>
</Workbook>

0 comments on commit 38c4ce4

Please sign in to comment.