Skip to content

Commit b1f3804

Browse files
committed
Test: put csv callback
1 parent 7f5521a commit b1f3804

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@
225225
<file md5sum="98f47ea5e8aab04af809a1707a1f1476" name="tests/sheet_checkout.phpt" role="test" />
226226
<file md5sum="5811dd930d7b0f916c662139ff1053d4" name="tests/string_from_column_index.phpt" role="test" />
227227
<file md5sum="42b26f050d9291509d6f583ef43ebde9" name="tests/xlsx_to_csv.phpt" role="test" />
228+
<file name="tests/xlsx_to_csv_callback.phpt" role="test" />
228229
<file md5sum="a9af7f4ca385ba41b008b50ac67f8e96" name="tests/zoom.phpt" role="test" />
229230
<file md5sum="f4a2d1a28ad1bf782502d698de0b1907" name="tests/include/skipif.inc" role="test" />
230231
<file md5sum="bb4256831dfd81f951bd6f4afbe1719f" name="CREDITS" role="doc" />

tests/xlsx_to_csv_callback.phpt

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
--TEST--
2+
Check for vtiful presence
3+
--SKIPIF--
4+
<?php
5+
require __DIR__ . '/include/skipif.inc';
6+
skip_disable_reader();
7+
?>
8+
--FILE--
9+
<?php
10+
$config = ['path' => './tests'];
11+
$excel = new \Vtiful\Kernel\Excel($config);
12+
$filePath = $excel->fileName('tutorial.xlsx', 'TestSheet1')
13+
->header(['Item', 'Cost'])
14+
->data([
15+
['Item_1', 'Cost_1', 10, 10.9999995],
16+
])
17+
->output();
18+
19+
$fp = fopen('./tests/file.csv', 'w');
20+
21+
$csvResult = $excel->openFile('tutorial.xlsx')
22+
->openSheet()
23+
->putCSVCallback(function($row){
24+
return $row;
25+
}, $fp);
26+
27+
fclose($fp);
28+
29+
var_dump($csvResult);
30+
31+
$fp = fopen('./tests/file.csv', 'r');
32+
33+
var_dump(fgetcsv($fp));
34+
var_dump(fgetcsv($fp));
35+
?>
36+
--CLEAN--
37+
<?php
38+
@unlink(__DIR__ . '/tutorial.xlsx');
39+
@unlink(__DIR__ . '/file.csv');
40+
?>
41+
--EXPECT--
42+
bool(true)
43+
array(2) {
44+
[0]=>
45+
string(4) "Item"
46+
[1]=>
47+
string(4) "Cost"
48+
}
49+
array(4) {
50+
[0]=>
51+
string(6) "Item_1"
52+
[1]=>
53+
string(6) "Cost_1"
54+
[2]=>
55+
string(2) "10"
56+
[3]=>
57+
string(10) "10.9999995"
58+
}

0 commit comments

Comments
 (0)