Skip to content

Commit 95fc742

Browse files
committed
Test(file): multiple
1 parent 4aa86ed commit 95fc742

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

kernel/excel.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ PHP_METHOD(vtiful_xls, __construct)
170170
return;
171171
}
172172

173-
add_property_zval(getThis(), V_XLS_COF, config);
173+
add_property_zval_ex(getThis(), ZEND_STRL(V_XLS_COF), config);
174174
}
175175
/* }}} */
176176

@@ -377,9 +377,6 @@ PHP_METHOD(vtiful_xls, output)
377377

378378
workbook_file(&obj->write_ptr);
379379

380-
add_property_null(getThis(), V_XLS_HANDLE);
381-
add_property_null(getThis(), V_XLS_PAT);
382-
383380
ZVAL_COPY(return_value, file_path);
384381
}
385382
/* }}} */

tests/multiple_file.phpt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
$lastFilePath = NULL;
12+
13+
for ($index = 0; $index < 100; $index++) {
14+
$fileObject = new \Vtiful\Kernel\Excel($config);
15+
16+
$fileObject = $fileObject->fileName('tutorial' . $index . '.xlsx');
17+
$fileHandle = $fileObject->getHandle();
18+
19+
$format = new \Vtiful\Kernel\Format($fileHandle);
20+
$alignStyle = $format->align(
21+
\Vtiful\Kernel\Format::FORMAT_ALIGN_CENTER,
22+
\Vtiful\Kernel\Format::FORMAT_ALIGN_VERTICAL_CENTER
23+
)->toResource();
24+
25+
$lastFilePath = $fileObject->header(['name', 'age'])
26+
->data([
27+
['viest', 21],
28+
['wjx', 21],
29+
])
30+
->setRow('A1', 50, $alignStyle)
31+
->setRow('A2:A3', 50, $alignStyle)
32+
->output();
33+
}
34+
35+
var_dump($lastFilePath);
36+
?>
37+
--CLEAN--
38+
<?php
39+
for ($index = 0; $index < 100; $index++) {
40+
@unlink(__DIR__ . '/tutorial' . $index . '.xlsx');
41+
}
42+
?>
43+
--EXPECT--
44+
string(23) "./tests/tutorial99.xlsx"

0 commit comments

Comments
 (0)