Browse Source

Test: insert date custom format and read data with type

viest 5 years ago
parent
commit
2e7031363d

+ 25 - 0
tests/insert_date_custom_format.phpt

@@ -0,0 +1,25 @@
+--TEST--
+Check for vtiful presence
+--SKIPIF--
+<?php if (!extension_loaded("xlswriter")) print "skip"; ?>
+--FILE--
+<?php
+$config = [
+    'path' => './tests'
+];
+
+$fileObject = new \Vtiful\Kernel\Excel($config);
+$fileObject = $fileObject->fileName('tutorial.xlsx');
+
+$filePath = $fileObject->header(['date'])
+    ->insertDate(1, 0, time(), 'mmm d yyyy hh:mm AM/PM')
+    ->output();
+
+var_dump($filePath);
+?>
+--CLEAN--
+<?php
+@unlink(__DIR__ . '/tutorial.xlsx');
+?>
+--EXPECT--
+string(21) "./tests/tutorial.xlsx"

+ 49 - 0
tests/open_xlsx_next_row_with_data_type_date.phpt

@@ -0,0 +1,49 @@
+--TEST--
+Check for vtiful presence
+--SKIPIF--
+<?php
+require __DIR__ . '/include/skipif.inc';
+skip_disable_reader();
+?>
+--FILE--
+<?php
+$config = [
+    'path' => './tests',
+];
+
+$fileObject = new \Vtiful\Kernel\Excel($config);
+$fileObject = $fileObject->fileName('tutorial.xlsx');
+
+$filePath = $fileObject->header(['date'])
+    ->insertDate(1, 0, 1568389354, 'mmm d yyyy hh:mm AM/PM')
+    ->output();
+
+$fileObject->openFile('tutorial.xlsx')
+    ->openSheet();
+
+var_dump($fileObject->nextRow([\Vtiful\Kernel\Excel::TYPE_STRING])); // Header
+var_dump($fileObject->nextRow([\Vtiful\Kernel\Excel::TYPE_TIMESTAMP]));
+var_dump($fileObject->nextRow([\Vtiful\Kernel\Excel::TYPE_TIMESTAMP]));
+var_dump($fileObject->nextRow([\Vtiful\Kernel\Excel::TYPE_TIMESTAMP]));
+var_dump($fileObject->nextRow([\Vtiful\Kernel\Excel::TYPE_TIMESTAMP]));
+var_dump($fileObject->nextRow([\Vtiful\Kernel\Excel::TYPE_TIMESTAMP]));
+var_dump($fileObject->nextRow([\Vtiful\Kernel\Excel::TYPE_TIMESTAMP]));
+?>
+--CLEAN--
+<?php
+@unlink(__DIR__ . '/tutorial.xlsx');
+?>
+--EXPECT--
+array(1) {
+  [0]=>
+  string(4) "date"
+}
+array(1) {
+  [0]=>
+  float(1568389354)
+}
+NULL
+NULL
+NULL
+NULL
+NULL

+ 0 - 0
tests/open_xlsx_next_row_with_data_type.phpt → tests/open_xlsx_next_row_with_data_type_string.phpt