Skip to content

Commit 2059d3b

Browse files
committed
A Tiny Amount of Coverage
1 parent a88993d commit 2059d3b

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
}

0 commit comments

Comments
 (0)