@@ -29,16 +29,28 @@ public function testCollectionCell(): void
29
29
self ::assertSame ($ cell1 , $ collection ->add ('B2 ' , $ cell1 ), 'adding a cell should return the cell ' );
30
30
31
31
// Assert cell presence
32
- self ::assertEquals (['B2 ' ], $ collection ->getCoordinates (), 'cell list should contains the cell ' );
33
- self ::assertEquals (['B2 ' ], $ collection ->getSortedCoordinates (), 'sorted cell list contains the cell ' );
32
+ self ::assertEquals (['B2 ' ], $ collection ->getCoordinates (), 'cell list should contains the B2 cell ' );
33
+ self ::assertEquals (['B2 ' ], $ collection ->getSortedCoordinates (), 'sorted cell list contains the B2 cell ' );
34
34
self ::assertSame ($ cell1 , $ collection ->get ('B2 ' ), 'should get exact same object ' );
35
- self ::assertTrue ($ collection ->has ('B2 ' ), 'cell should exists ' );
35
+ self ::assertTrue ($ collection ->has ('B2 ' ), 'B2 cell should exists ' );
36
36
37
37
// Add a second cell
38
38
$ cell2 = $ sheet ->getCell ('A1 ' );
39
39
self ::assertSame ($ cell2 , $ collection ->add ('A1 ' , $ cell2 ), 'adding a second cell should return the cell ' );
40
- self ::assertEquals (['B2 ' , 'A1 ' ], $ collection ->getCoordinates (), 'cell list should contains the cell ' );
41
- self ::assertEquals (['A1 ' , 'B2 ' ], $ collection ->getSortedCoordinates (), 'sorted cell list contains the cell ' );
40
+ self ::assertEquals (['B2 ' , 'A1 ' ], $ collection ->getCoordinates (), 'cell list should contains the second cell ' );
41
+ self ::assertEquals (['A1 ' , 'B2 ' ], $ collection ->getSortedCoordinates (), 'sorted cell list contains the second cell ' );
42
+
43
+ // Add a third cell
44
+ $ cell3 = $ sheet ->getCell ('AA1 ' );
45
+ self ::assertSame ($ cell3 , $ collection ->add ('AA1 ' , $ cell3 ), 'adding a third cell should return the cell ' );
46
+ self ::assertEquals (['B2 ' , 'A1 ' , 'AA1 ' ], $ collection ->getCoordinates (), 'cell list should contains the third cell ' );
47
+ self ::assertEquals (['A1 ' , 'AA1 ' , 'B2 ' ], $ collection ->getSortedCoordinates (), 'sorted cell list contains the third cell ' );
48
+
49
+ // Add a fourth cell
50
+ $ cell4 = $ sheet ->getCell ('Z1 ' );
51
+ self ::assertSame ($ cell4 , $ collection ->add ('Z1 ' , $ cell4 ), 'adding a fourth cell should return the cell ' );
52
+ self ::assertEquals (['B2 ' , 'A1 ' , 'AA1 ' , 'Z1 ' ], $ collection ->getCoordinates (), 'cell list should contains the fourth cell ' );
53
+ self ::assertEquals (['A1 ' , 'Z1 ' , 'AA1 ' , 'B2 ' ], $ collection ->getSortedCoordinates (), 'sorted cell list contains the fourth cell ' );
42
54
43
55
// Assert collection copy
44
56
$ sheet2 = $ spreadsheet ->createSheet ();
@@ -53,16 +65,16 @@ public function testCollectionCell(): void
53
65
// Assert deletion
54
66
$ collection ->delete ('B2 ' );
55
67
self ::assertFalse ($ collection ->has ('B2 ' ), 'cell should have been deleted ' );
56
- self ::assertEquals (['A1 ' ], $ collection ->getCoordinates (), 'cell list should contains the cell ' );
68
+ self ::assertEquals (['A1 ' , ' AA1 ' , ' Z1 ' ], $ collection ->getCoordinates (), 'cell list should still contains the A1,Z1 and A11 cells ' );
57
69
58
70
// Assert update
59
71
$ cell2 = $ sheet ->getCell ('A1 ' );
60
72
self ::assertSame ($ sheet ->getCellCollection (), $ collection );
61
73
self ::assertSame ($ cell2 , $ collection ->update ($ cell2 ), 'should update existing cell ' );
62
74
63
75
$ cell3 = $ sheet ->getCell ('C3 ' );
64
- self ::assertSame ($ cell3 , $ collection ->update ($ cell3 ), 'should silently add non-existing cell ' );
65
- self ::assertEquals (['A1 ' , 'C3 ' ], $ collection ->getCoordinates (), 'cell list should contains the cell ' );
76
+ self ::assertSame ($ cell3 , $ collection ->update ($ cell3 ), 'should silently add non-existing C3 cell ' );
77
+ self ::assertEquals (['A1 ' , 'AA1 ' , ' Z1 ' , ' C3 ' ], $ collection ->getCoordinates (), 'cell list should contains the C3 cell ' );
66
78
}
67
79
68
80
public function testCacheLastCell (): void
0 commit comments