浏览代码

Test: default format

viest 5 年之前
父节点
当前提交
685e9cc210
共有 2 个文件被更改,包括 42 次插入0 次删除
  1. 1 0
      package.xml
  2. 41 0
      tests/default_format.phpt

+ 1 - 0
package.xml

@@ -186,6 +186,7 @@
    <file md5sum="39f7c511d9019c6815bcf7fd0f7e8224" name="tests/chart_style.phpt" role="test" />
    <file md5sum="bfdf9e054f8efd971a65d00eca465f2f" name="tests/chart_title.phpt" role="test" />
    <file md5sum="9badb50b14bd81536bafcfefcb5677d6" name="tests/column_index_from_string.phpt" role="test" />
+   <file name="tests/default_format.phpt" role="test" />
    <file md5sum="df2a6af4ced4ea7660a1691d18e75e8c" name="tests/format_align.phpt" role="test" />
    <file md5sum="6f9186fb9d8eb2ad4d96d149c97ef5f8" name="tests/format_background.phpt" role="test" />
    <file md5sum="c67d20fdc2f1d4b4b429ac905cb4cbf9" name="tests/format_border.phpt" role="test" />

+ 41 - 0
tests/default_format.phpt

@@ -0,0 +1,41 @@
+--TEST--
+Check for vtiful presence
+--SKIPIF--
+<?php if (!extension_loaded("xlswriter")) print "skip"; ?>
+--FILE--
+<?php
+$config = ['path' => './tests'];
+$excel  = new \Vtiful\Kernel\Excel($config);
+
+$excel->fileName('tutorial.xlsx');
+
+$format        = new \Vtiful\Kernel\Format($excel->getHandle());
+$colorOneStyle = $format
+    ->fontColor(\Vtiful\Kernel\Format::COLOR_ORANGE)
+    ->border(\Vtiful\Kernel\Format::BORDER_DASH_DOT)
+    ->toResource();
+
+$format        = new \Vtiful\Kernel\Format($excel->getHandle());
+$colorTwoStyle = $format
+    ->fontColor(\Vtiful\Kernel\Format::COLOR_GREEN)
+    ->toResource();
+
+$filePath = $excel
+    // Apply the first style as the default
+    ->defaultFormat($colorOneStyle)
+    ->header(['hello', 'xlswriter'])
+    // Apply the second style as the default style
+    ->defaultFormat($colorTwoStyle)
+    ->data([
+        ['hello', 'xlswriter'],
+    ])
+    ->output();
+
+var_dump($filePath);
+?>
+--CLEAN--
+<?php
+@unlink(__DIR__ . '/tutorial.xlsx');
+?>
+--EXPECT--
+string(21) "./tests/tutorial.xlsx"