Przeglądaj źródła

Fix: read: Turning data into custom types

viest 5 lat temu
rodzic
commit
7000ccf7c2
2 zmienionych plików z 76 dodań i 1 usunięć
  1. 75 0
      tests/fix-207.phpt
  2. 1 1
      tests/open_xlsx_get_data_with_set_type.phpt

+ 75 - 0
tests/fix-207.phpt

@@ -0,0 +1,75 @@
+--TEST--
+Check for vtiful presence
+--SKIPIF--
+<?php
+require __DIR__ . '/include/skipif.inc';
+skip_disable_reader();
+?>
+--FILE--
+<?php
+$config = ['path' => './tests'];
+$excel  = new \Vtiful\Kernel\Excel($config);
+
+$filePath = $excel->fileName('tutorial.xlsx')
+    ->header(['Name', 'Code'])
+    ->data([
+        ['Viest', '00024']
+    ])
+    ->output();
+
+$dataOne = $excel->openFile('tutorial.xlsx')
+    ->openSheet()
+    ->setType([
+        \Vtiful\Kernel\Excel::TYPE_STRING,
+        \Vtiful\Kernel\Excel::TYPE_STRING,
+    ])
+    ->getSheetData();
+
+$dataTwo = $excel->openFile('tutorial.xlsx')
+    ->openSheet()
+    ->setType([
+        \Vtiful\Kernel\Excel::TYPE_STRING,
+        \Vtiful\Kernel\Excel::TYPE_INT,
+    ])
+    ->getSheetData();
+
+var_dump($dataOne);
+var_dump($dataTwo);
+?>
+--CLEAN--
+<?php
+@unlink(__DIR__ . '/tutorial.xlsx');
+?>
+--EXPECT--
+array(2) {
+  [0]=>
+  array(2) {
+    [0]=>
+    string(4) "Name"
+    [1]=>
+    string(4) "Code"
+  }
+  [1]=>
+  array(2) {
+    [0]=>
+    string(5) "Viest"
+    [1]=>
+    string(5) "00024"
+  }
+}
+array(2) {
+  [0]=>
+  array(2) {
+    [0]=>
+    string(4) "Name"
+    [1]=>
+    string(4) "Code"
+  }
+  [1]=>
+  array(2) {
+    [0]=>
+    string(5) "Viest"
+    [1]=>
+    int(24)
+  }
+}

+ 1 - 1
tests/open_xlsx_get_data_with_set_type.phpt

@@ -48,7 +48,7 @@ array(2) {
     [0]=>
     string(5) "Viest"
     [1]=>
-    int(24)
+    string(2) "24"
     [2]=>
     int(1568877706)
   }