File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
tests/PhpSpreadsheetTests/Collection Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace PhpOffice \PhpSpreadsheetTests \Collection ;
6+
7+ use PhpOffice \PhpSpreadsheet \Collection \Cells ;
8+ use PhpOffice \PhpSpreadsheet \Worksheet \Worksheet ;
9+ use PHPUnit \Framework \TestCase ;
10+
11+ class Cells2Test extends TestCase
12+ {
13+ public function testThrowsWhenCellCannotBeStoredInClonedCache (): void
14+ {
15+ $ this ->expectException (\PhpOffice \PhpSpreadsheet \Exception::class);
16+ $ this ->expectExceptionMessage ('Failed to copy cells in cache ' );
17+
18+ $ cache = new SimpleCache3xxx ();
19+
20+ $ worksheet = new Worksheet ();
21+ $ collection = new Cells ($ worksheet , $ cache );
22+
23+ $ collection ->add ('A1 ' , $ worksheet ->getCell ('A1 ' ));
24+ $ collection ->add ('A2 ' , $ worksheet ->getCell ('A2 ' ));
25+ $ collection ->cloneCellCollection ($ worksheet );
26+ }
27+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace PhpOffice \PhpSpreadsheetTests \Collection ;
6+
7+ use DateInterval ;
8+ use PhpOffice \PhpSpreadsheet \Collection \Memory \SimpleCache3 ;
9+
10+ class SimpleCache3xxx extends SimpleCache3
11+ {
12+ public static int $ useCount = 0 ;
13+
14+ public function set (string $ key , mixed $ value , null |int |DateInterval $ ttl = null ): bool
15+ {
16+ ++self ::$ useCount ;
17+ if (self ::$ useCount >= 4 ) {
18+ return false ;
19+ }
20+
21+ return parent ::set ($ key , $ value , $ ttl );
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments