Skip to content

Commit 2462b45

Browse files
committed
Test: insert date default format and read row with data type
1 parent 191f247 commit 2462b45

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

kernel/excel.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ PHP_METHOD(vtiful_xls, insertDate)
480480
type_writer(&_zv_double_time, row, column, &obj->write_ptr, format, NULL);
481481
}
482482

483+
zend_string_release(format);
483484
zval_ptr_dtor(&_zv_double_time);
484485
}
485486
/* }}} */
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Check for vtiful presence
3+
--SKIPIF--
4+
<?php if (!extension_loaded("xlswriter")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
$config = [
8+
'path' => './tests'
9+
];
10+
11+
$fileObject = new \Vtiful\Kernel\Excel($config);
12+
$fileObject = $fileObject->fileName('tutorial.xlsx');
13+
14+
$filePath = $fileObject->header(['date'])
15+
->insertDate(1, 0, time())
16+
->output();
17+
18+
var_dump($filePath);
19+
?>
20+
--CLEAN--
21+
<?php
22+
@unlink(__DIR__ . '/tutorial.xlsx');
23+
?>
24+
--EXPECT--
25+
string(21) "./tests/tutorial.xlsx"
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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')
13+
->header(['Item', 'Cost'])
14+
->data([
15+
['Item_1', 'Cost_1'],
16+
])
17+
->output();
18+
19+
$excel->openFile('tutorial.xlsx')
20+
->openSheet();
21+
22+
var_dump($excel->nextRow([\Vtiful\Kernel\Excel::TYPE_STRING, \Vtiful\Kernel\Excel::TYPE_STRING]));
23+
var_dump($excel->nextRow([\Vtiful\Kernel\Excel::TYPE_STRING, \Vtiful\Kernel\Excel::TYPE_STRING]));
24+
var_dump($excel->nextRow([\Vtiful\Kernel\Excel::TYPE_STRING, \Vtiful\Kernel\Excel::TYPE_STRING]));
25+
var_dump($excel->nextRow([\Vtiful\Kernel\Excel::TYPE_STRING, \Vtiful\Kernel\Excel::TYPE_STRING]));
26+
var_dump($excel->nextRow([\Vtiful\Kernel\Excel::TYPE_STRING, \Vtiful\Kernel\Excel::TYPE_STRING]));
27+
var_dump($excel->nextRow([\Vtiful\Kernel\Excel::TYPE_STRING, \Vtiful\Kernel\Excel::TYPE_STRING]));
28+
var_dump($excel->nextRow([\Vtiful\Kernel\Excel::TYPE_STRING, \Vtiful\Kernel\Excel::TYPE_STRING]));
29+
?>
30+
--CLEAN--
31+
<?php
32+
@unlink(__DIR__ . '/tutorial.xlsx');
33+
?>
34+
--EXPECT--
35+
array(2) {
36+
[0]=>
37+
string(4) "Item"
38+
[1]=>
39+
string(4) "Cost"
40+
}
41+
array(2) {
42+
[0]=>
43+
string(6) "Item_1"
44+
[1]=>
45+
string(6) "Cost_1"
46+
}
47+
NULL
48+
NULL
49+
NULL
50+
NULL
51+
NULL

0 commit comments

Comments
 (0)