@@ -34,8 +34,68 @@ public function doTearDown()
34
34
parent ::doTearDown ();
35
35
}
36
36
37
- public function testIt ()
37
+ /**
38
+ * Test that _substituteCellref handles regex with dollar signs correctly
39
+ */
40
+ public function testSubstituteCellrefWithDollarSigns ()
38
41
{
39
- $ this ->assertInstanceOf ('Spreadsheet_Excel_Writer_Worksheet ' , $ this ->worksheet );
42
+ $ method = new \ReflectionMethod ($ this ->worksheet , '_substituteCellref ' );
43
+ $ method ->setAccessible (true );
44
+
45
+ // Test absolute cell reference
46
+ $ result = $ method ->invoke ($ this ->worksheet , '$A$1 ' );
47
+ $ this ->assertEquals (array (0 , 0 ), $ result );
48
+
49
+ // Test mixed references
50
+ $ result = $ method ->invoke ($ this ->worksheet , 'A$1 ' );
51
+ $ this ->assertEquals (array (0 , 0 ), $ result );
52
+
53
+ $ result = $ method ->invoke ($ this ->worksheet , '$A1 ' );
54
+ $ this ->assertEquals (array (0 , 0 ), $ result );
55
+
56
+ // Test cell range with dollar signs
57
+ $ result = $ method ->invoke ($ this ->worksheet , '$A$1:$B$2 ' );
58
+ $ this ->assertEquals (array (0 , 0 , 1 , 1 ), $ result );
59
+ }
60
+
61
+ /**
62
+ * Test that _cellToRowcol handles regex with dollar signs correctly
63
+ */
64
+ public function testCellToRowcolWithDollarSigns ()
65
+ {
66
+ $ method = new \ReflectionMethod ($ this ->worksheet , '_cellToRowcol ' );
67
+ $ method ->setAccessible (true );
68
+
69
+ // Test with absolute reference
70
+ $ result = $ method ->invoke ($ this ->worksheet , '$A$1 ' );
71
+ $ this ->assertEquals (array (0 , 0 ), $ result );
72
+
73
+ // Test with relative reference
74
+ $ result = $ method ->invoke ($ this ->worksheet , 'B2 ' );
75
+ $ this ->assertEquals (array (1 , 1 ), $ result );
76
+
77
+ // Test with mixed reference
78
+ $ result = $ method ->invoke ($ this ->worksheet , '$C3 ' );
79
+ $ this ->assertEquals (array (2 , 2 ), $ result );
80
+ }
81
+
82
+ /**
83
+ * Test that getData properly handles clearing _data property
84
+ */
85
+ public function testGetDataClearsDataProperty ()
86
+ {
87
+ // Access protected property
88
+ $ property = new \ReflectionProperty ($ this ->worksheet , '_data ' );
89
+ $ property ->setAccessible (true );
90
+
91
+ // Set some data
92
+ $ testData = 'test data ' ;
93
+ $ property ->setValue ($ this ->worksheet , $ testData );
94
+
95
+ // Call getData
96
+ $ result = $ this ->worksheet ->getData ();
97
+
98
+ // Check that data was returned
99
+ $ this ->assertEquals ($ testData , $ result );
40
100
}
41
101
}
0 commit comments