Kaynağa Gözat

Merge pull request #14 from motecshine/tests

Add test files
王杰新 7 yıl önce
ebeveyn
işleme
f5ad2b5526
9 değiştirilmiş dosya ile 126 ekleme ve 4 silme
  1. 2 1
      .gitignore
  2. 1 2
      .travis.yml
  3. 19 0
      excel.php
  4. 1 1
      tests/001.phpt
  5. 22 0
      tests/002.phpt
  6. 23 0
      tests/003.phpt
  7. 24 0
      tests/004.phpt
  8. 10 0
      tests/005.phpt
  9. 24 0
      travis/run-test.sh

+ 2 - 1
.gitignore

@@ -14,6 +14,7 @@ config.nice
 config.status
 config.sub
 configure
+configure.ac
 configure.in
 include
 install-sh
@@ -36,4 +37,4 @@ tests/*/*.sh
 .idea
 cmake-build-debug
 CMakeLists.txt
-local_test.php
+local_test.php

+ 1 - 2
.travis.yml

@@ -24,6 +24,5 @@ branches:
   only:
     - master
     - dev
-
 script:
-  - exit 0
+    - ./travis/run-test.sh

+ 19 - 0
excel.php

@@ -0,0 +1,19 @@
+<?php
+$config = ['path' => './tests/'];
+$excel = new \Vtiful\Kernel\Excel($config);
+$fileFd = $excel->fileName('tutorial01.xlsx');
+var_dump($fileFd);
+$setHeader = $fileFd->header(['Item', 'Cost']);
+var_dump($setHeader);
+$setData = $setHeader->data([
+        ['Rent', 1000],
+        ['Gas',  100],
+        ['Food', 300],
+        ['Gym',  50],
+
+    ]);
+var_dump($setData);
+$output = $setData->output();
+var_dump($output);
+?>
+

+ 1 - 1
tests/001.phpt

@@ -1,7 +1,7 @@
 --TEST--
 Check for vtiful presence
 --SKIPIF--
-<?php if (!extension_loaded("vtiful")) print "skip"; ?>
+<?php if (!extension_loaded("excel_writer")) print "skip"; ?>
 --FILE--
 <?php 
 echo "vtiful extension is available";

+ 22 - 0
tests/002.phpt

@@ -0,0 +1,22 @@
+--TEST--
+Check for vtiful presence
+--SKIPIF--
+<?php if (!extension_loaded("excel_writer")) print "skip"; ?>
+--FILE--
+<?php 
+$config = ['path' => './tests/'];
+$excel = new \Vtiful\Kernel\Excel($config);
+var_dump($excel);
+?>
+--EXPECT--
+object(Vtiful\Kernel\Excel)#1 (3) {
+  ["config":"Vtiful\Kernel\Excel":private]=>
+  array(1) {
+    ["path"]=>
+    string(8) "./tests/"
+  }
+  ["fileName":"Vtiful\Kernel\Excel":private]=>
+  NULL
+  ["handle":"Vtiful\Kernel\Excel":private]=>
+  NULL
+}

+ 23 - 0
tests/003.phpt

@@ -0,0 +1,23 @@
+--TEST--
+Check for vtiful presence
+--SKIPIF--
+<?php if (!extension_loaded("excel_writer")) print "skip"; ?>
+--FILE--
+<?php 
+$config = ['path' => './tests/'];
+$excel = new \Vtiful\Kernel\Excel($config);
+$fileFd = $excel->fileName('tutorial01.xlsx');
+var_dump($fileFd);
+?>
+--EXPECT--
+object(Vtiful\Kernel\Excel)#1 (3) {
+  ["config":"Vtiful\Kernel\Excel":private]=>
+  array(1) {
+    ["path"]=>
+    string(8) "./tests/"
+  }
+  ["fileName":"Vtiful\Kernel\Excel":private]=>
+  string(23) "./tests/tutorial01.xlsx"
+  ["handle":"Vtiful\Kernel\Excel":private]=>
+  resource(4) of type (vtiful)
+}

+ 24 - 0
tests/004.phpt

@@ -0,0 +1,24 @@
+--TEST--
+Check for vtiful presence
+--SKIPIF--
+<?php if (!extension_loaded("excel_writer")) print "skip"; ?>
+--FILE--
+<?php 
+$config = ['path' => './tests/'];
+$excel = new \Vtiful\Kernel\Excel($config);
+$fileFd = $excel->fileName('tutorial01.xlsx');
+$setHeader = $fileFd->header(['Item', 'Cost']);
+var_dump($setHeader);
+?>
+--EXPECT--
+object(Vtiful\Kernel\Excel)#1 (3) {
+  ["config":"Vtiful\Kernel\Excel":private]=>
+  array(1) {
+    ["path"]=>
+    string(8) "./tests/"
+  }
+  ["fileName":"Vtiful\Kernel\Excel":private]=>
+  string(23) "./tests/tutorial01.xlsx"
+  ["handle":"Vtiful\Kernel\Excel":private]=>
+  resource(5) of type (vtiful)
+}

+ 10 - 0
tests/005.phpt

@@ -0,0 +1,10 @@
+--TEST--
+Check for vtiful presence
+--SKIPIF--
+<?php if (!extension_loaded("excel_writer")) print "skip"; ?>
+--FILE--
+<?php 
+echo "output path";
+?>
+--EXPECT--
+output path

+ 24 - 0
travis/run-test.sh

@@ -0,0 +1,24 @@
+#!/bin/bash
+TEST_DIR="`pwd`/tests/"
+
+make test 
+
+for file in `find $TEST_DIR -name "*.diff" 2>/dev/null`
+do
+	grep "\-\-XFAIL--" ${file/%diff/phpt} >/dev/null 2>&1
+	if [ $? -gt 0 ]
+	then
+		FAILS[${#FAILS[@]}]="$file"
+	fi
+done
+
+if [ ${#FAILS[@]} -gt 0 ]
+then
+	for fail in "${FAILS[@]}"
+	do
+		sh -xc "cat $fail"
+	done
+	exit 1
+else
+	exit 0
+fi