浏览代码

Test(file): multiple

viest 5 年之前
父节点
当前提交
95fc7423b8
共有 2 个文件被更改,包括 45 次插入4 次删除
  1. 1 4
      kernel/excel.c
  2. 44 0
      tests/multiple_file.phpt

+ 1 - 4
kernel/excel.c

@@ -170,7 +170,7 @@ PHP_METHOD(vtiful_xls, __construct)
         return;
     }
 
-    add_property_zval(getThis(), V_XLS_COF, config);
+    add_property_zval_ex(getThis(), ZEND_STRL(V_XLS_COF), config);
 }
 /* }}} */
 
@@ -377,9 +377,6 @@ PHP_METHOD(vtiful_xls, output)
 
     workbook_file(&obj->write_ptr);
 
-    add_property_null(getThis(), V_XLS_HANDLE);
-    add_property_null(getThis(), V_XLS_PAT);
-
     ZVAL_COPY(return_value, file_path);
 }
 /* }}} */

+ 44 - 0
tests/multiple_file.phpt

@@ -0,0 +1,44 @@
+--TEST--
+Check for vtiful presence
+--SKIPIF--
+<?php if (!extension_loaded("xlswriter")) print "skip"; ?>
+--FILE--
+<?php
+$config = [
+    'path' => './tests',
+];
+
+$lastFilePath = NULL;
+
+for ($index = 0; $index < 100; $index++) {
+    $fileObject = new \Vtiful\Kernel\Excel($config);
+
+    $fileObject = $fileObject->fileName('tutorial' . $index . '.xlsx');
+    $fileHandle = $fileObject->getHandle();
+
+    $format     = new \Vtiful\Kernel\Format($fileHandle);
+    $alignStyle = $format->align(
+        \Vtiful\Kernel\Format::FORMAT_ALIGN_CENTER,
+        \Vtiful\Kernel\Format::FORMAT_ALIGN_VERTICAL_CENTER
+    )->toResource();
+
+    $lastFilePath = $fileObject->header(['name', 'age'])
+        ->data([
+            ['viest', 21],
+            ['wjx', 21],
+        ])
+        ->setRow('A1', 50, $alignStyle)
+        ->setRow('A2:A3', 50, $alignStyle)
+        ->output();
+}
+
+var_dump($lastFilePath);
+?>
+--CLEAN--
+<?php
+for ($index = 0; $index < 100; $index++) {
+    @unlink(__DIR__ . '/tutorial' . $index . '.xlsx');
+}
+?>
+--EXPECT--
+string(23) "./tests/tutorial99.xlsx"