Passed
Pull Request — master (#4184)
by Owen
21:44 queued 11:10
created

Issue1107Test   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 21
c 1
b 0
f 0
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 5 2
A testIssue1107() 0 20 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpOffice\PhpSpreadsheetTests\Reader\Html;
6
7
use PhpOffice\PhpSpreadsheet\Reader\Html as HtmlReader;
8
use PhpOffice\PhpSpreadsheet\Shared\File;
9
use PhpOffice\PhpSpreadsheet\Spreadsheet;
10
use PhpOffice\PhpSpreadsheet\Writer\Html as HtmlWriter;
11
use PHPUnit\Framework\TestCase;
12
13
class Issue1107Test extends TestCase
14
{
15
    private string $outfile = '';
16
17
    protected function tearDown(): void
18
    {
19
        if ($this->outfile !== '') {
20
            unlink($this->outfile);
21
            $this->outfile = '';
22
        }
23
    }
24
25
    public function testIssue1107(): void
26
    {
27
        // failure due to cached file size
28
        $outstr = str_repeat('a', 1023) . "\n";
29
        $allout = str_repeat($outstr, 10);
30
        $this->outfile = $outfile = File::temporaryFilename();
31
        file_put_contents($outfile, $allout);
32
        self::assertSame(10240, filesize($outfile));
33
        $spreadsheet = new Spreadsheet();
34
        $sheet = $spreadsheet->getActiveSheet();
35
        $sheet->getCell('A1')->setValue(1);
36
        $writer = new HtmlWriter($spreadsheet);
37
        $writer->save($outfile);
38
        $spreadsheet->disconnectWorksheets();
39
        $reader = new HtmlReader();
40
        $spreadsheet2 = $reader->load($outfile);
41
        $sheet2 = $spreadsheet2->getActiveSheet();
42
        self::assertSame(1, $sheet2->getCell('A1')->getValue());
43
44
        $spreadsheet2->disconnectWorksheets();
45
    }
46
}
47