generated from krissss/package-skeleton-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWriterTest.php
95 lines (73 loc) · 3.55 KB
/
WriterTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
use Kriss\DataExporter\DataExporter;
use PhpOffice\PhpSpreadsheet\IOFactory;
use Symfony\Component\Filesystem\Path;
beforeEach(function () {
$this->source = [
['aa', 'bb', 'cc'],
['aa', 'bb', 'cc'],
['aa', 'bb', 'cc'],
['aa', 'bb', 'cc'],
];
$this->filename = __DIR__ . '/../tmp/test';
});
it('Writer csv', function () {
$filename = DataExporter::csv($this->source)->saveAs($this->filename);
expect(Path::canonicalize($this->filename . '.csv'))->toBe($filename);
$factory = IOFactory::load($filename);
expect((string)$factory->getActiveSheet()->getCell('C4')->getValue())->toBe('cc');
});
it('Writer xlsx', function () {
$filename = DataExporter::xlsx($this->source)->saveAs($this->filename);
expect(Path::canonicalize($this->filename . '.xlsx'))->toBe($filename);
$factory = IOFactory::load($filename);
expect((string)$factory->getActiveSheet()->getCell('C4')->getValue())->toBe('cc');
});
it('Writer xls', function () {
$filename = DataExporter::xls($this->source)->saveAs($this->filename);
expect(Path::canonicalize($this->filename . '.xls'))->toBe($filename);
$factory = IOFactory::load($filename);
expect((string)$factory->getActiveSheet()->getCell('C4')->getValue())->toBe('cc');
});
it('Writer csvSpout', function () {
$filename = DataExporter::csvSpout($this->source)->saveAs($this->filename);
expect(Path::canonicalize($this->filename . '.csv'))->toBe($filename);
$factory = IOFactory::load($filename);
expect((string)$factory->getActiveSheet()->getCell('C4')->getValue())->toBe('cc');
});
it('Writer xlsxSpout', function () {
$filename = DataExporter::xlsxSpout($this->source)->saveAs($this->filename);
expect(Path::canonicalize($this->filename . '.xlsx'))->toBe($filename);
$factory = IOFactory::load($filename);
expect((string)$factory->getActiveSheet()->getCell('C4')->getValue())->toBe('cc');
});
it('Writer odsSpout', function () {
$filename = DataExporter::odsSpout($this->source)->saveAs($this->filename);
expect(Path::canonicalize($this->filename . '.ods'))->toBe($filename);
$factory = IOFactory::load($filename);
expect((string)$factory->getActiveSheet()->getCell('C4')->getValue())->toBe('cc');
});
it('Writer csvSpreadsheet', function () {
$filename = DataExporter::csvSpreadsheet($this->source)->saveAs($this->filename);
expect(Path::canonicalize($this->filename . '.csv'))->toBe($filename);
$factory = IOFactory::load($filename);
expect((string)$factory->getActiveSheet()->getCell('C4')->getValue())->toBe('cc');
});
it('Writer xlsSpreadsheet', function () {
$filename = DataExporter::xlsSpreadsheet($this->source)->saveAs($this->filename);
expect(Path::canonicalize($this->filename . '.xls'))->toBe($filename);
$factory = IOFactory::load($filename);
expect((string)$factory->getActiveSheet()->getCell('C4')->getValue())->toBe('cc');
});
it('Writer xlsxSpreadsheet', function () {
$filename = DataExporter::xlsxSpreadsheet($this->source)->saveAs($this->filename);
expect(Path::canonicalize($this->filename . '.xlsx'))->toBe($filename);
$factory = IOFactory::load($filename);
expect((string)$factory->getActiveSheet()->getCell('C4')->getValue())->toBe('cc');
});
it('Writer odsSpreadsheet', function () {
$filename = DataExporter::odsSpreadsheet($this->source)->saveAs($this->filename);
expect(Path::canonicalize($this->filename . '.ods'))->toBe($filename);
$factory = IOFactory::load($filename);
expect((string)$factory->getActiveSheet()->getCell('C4')->getValue())->toBe('cc');
});