Skip to content

Commit 38c4ce4

Browse files
committed
Additional Coverage For Xml Reader
No source code changes.
1 parent 04b15c0 commit 38c4ce4

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed

tests/PhpSpreadsheetTests/Reader/Xml/DataValidationsTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class DataValidationsTest extends AbstractFunctional
1313
{
1414
private string $filename = 'tests/data/Reader/Xml/datavalidations.xml';
1515

16+
private string $filename2 = 'tests/data/Reader/Xml/datavalidations.wholerow.xml';
17+
1618
public function testValidation(): void
1719
{
1820
$reader = new Xml();
@@ -34,6 +36,27 @@ public function testValidation(): void
3436
$spreadsheet->disconnectWorksheets();
3537
}
3638

39+
public function testValidationWholeRow(): void
40+
{
41+
$reader = new Xml();
42+
$spreadsheet = $reader->load($this->filename2);
43+
$sheet = $spreadsheet->getActiveSheet();
44+
$collection = $sheet->getDataValidationCollection();
45+
self::assertSame(['A1', 'A1:XFD1'], array_keys($collection));
46+
$dv = $collection['A1'];
47+
self::assertSame('"Item A,Item B,Item D"', $dv->getFormula1());
48+
self::assertSame('warn', $dv->getErrorStyle());
49+
self::assertFalse($dv->getShowDropDown());
50+
self::assertFalse($dv->getShowErrorMessage());
51+
52+
$dv = $collection['A1:XFD1'];
53+
self::assertSame('"Item A,Item B,Item C"', $dv->getFormula1());
54+
self::assertSame('stop', $dv->getErrorStyle());
55+
self::assertTrue($dv->getShowDropDown());
56+
self::assertTrue($dv->getShowErrorMessage());
57+
$spreadsheet->disconnectWorksheets();
58+
}
59+
3760
public function testValidationXlsx(): void
3861
{
3962
$reader = new Xml();
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version="1.0"?>
2+
<?mso-application progid="Excel.Sheet"?>
3+
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
4+
xmlns:o="urn:schemas-microsoft-com:office:office"
5+
xmlns:x="urn:schemas-microsoft-com:office:excel"
6+
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
7+
xmlns:html="http://www.w3.org/TR/REC-html40">
8+
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
9+
<Title>Untitled Spreadsheet</Title>
10+
<Author>Unknown Creator</Author>
11+
<LastAuthor>Owen Leibman</LastAuthor>
12+
<Created>2024-12-30T08:21:15Z</Created>
13+
<LastSaved>2024-12-30T08:21:15Z</LastSaved>
14+
<Version>16.00</Version>
15+
</DocumentProperties>
16+
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
17+
<AllowPNG/>
18+
</OfficeDocumentSettings>
19+
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
20+
<WindowHeight>6510</WindowHeight>
21+
<WindowWidth>19200</WindowWidth>
22+
<WindowTopX>32767</WindowTopX>
23+
<WindowTopY>32767</WindowTopY>
24+
<ProtectStructure>False</ProtectStructure>
25+
<ProtectWindows>False</ProtectWindows>
26+
</ExcelWorkbook>
27+
<Styles>
28+
<Style ss:ID="Default" ss:Name="Normal">
29+
<Alignment ss:Vertical="Bottom"/>
30+
<Borders/>
31+
<Font ss:FontName="Calibri" ss:Size="11" ss:Color="#000000"/>
32+
<Interior/>
33+
<NumberFormat/>
34+
<Protection/>
35+
</Style>
36+
</Styles>
37+
<Worksheet ss:Name="Worksheet">
38+
<Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1"
39+
x:FullRows="1" ss:DefaultRowHeight="14.5">
40+
<Row ss:AutoFitHeight="0"/>
41+
</Table>
42+
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
43+
<PageSetup>
44+
<Header x:Margin="0.3"/>
45+
<Footer x:Margin="0.3"/>
46+
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
47+
</PageSetup>
48+
<Unsynced/>
49+
<Print>
50+
<ValidPrinterInfo/>
51+
<NoOrientation/>
52+
<HorizontalResolution>600</HorizontalResolution>
53+
<VerticalResolution>600</VerticalResolution>
54+
</Print>
55+
<Selected/>
56+
<ProtectObjects>False</ProtectObjects>
57+
<ProtectScenarios>False</ProtectScenarios>
58+
</WorksheetOptions>
59+
<DataValidation xmlns="urn:schemas-microsoft-com:office:excel">
60+
<Range>R1</Range>
61+
<Type>List</Type>
62+
<UseBlank/>
63+
<CellRangeList/>
64+
<Value>&quot;Item A,Item B,Item C&quot;</Value>
65+
<InputHide/>
66+
<ErrorMessage>Value is not a member of allowed list</ErrorMessage>
67+
<ErrorTitle>Input Error</ErrorTitle>
68+
</DataValidation>
69+
<DataValidation xmlns="urn:schemas-microsoft-com:office:excel">
70+
<Range>R1C1</Range>
71+
<Type>List</Type>
72+
<UseBlank/>
73+
<CellRangeList/>
74+
<Value>&quot;Item A,Item B,Item D&quot;</Value>
75+
<InputHide/>
76+
<ComboHide/>
77+
<ErrorHide/>
78+
<ErrorStyle>Warn</ErrorStyle>
79+
<ErrorMessage>Value is not a member of allowed list</ErrorMessage>
80+
<ErrorTitle>Input Error</ErrorTitle>
81+
</DataValidation>
82+
</Worksheet>
83+
</Workbook>

0 commit comments

Comments
 (0)