summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schneider2018-06-28 12:12:33 +0200
committerChristian Schneider2018-06-28 12:12:33 +0200
commit0551cf39c668f3276e40b50664909cba1850dbcc (patch)
tree4f5322bb4ad77a33f27ea678cd85b5f05c0cc24a
parentc652e5a2ebbe5ed589d637301f3f26383e485bc4 (diff)
downloaditools-0551cf39c668f3276e40b50664909cba1850dbcc.tar.gz
itools-0551cf39c668f3276e40b50664909cba1850dbcc.tar.bz2
itools-0551cf39c668f3276e40b50664909cba1850dbcc.zip
Use tempnam() to create tmp file and unlink() for removing, no need to it::system() to delete a file
-rwxr-xr-xtest/it.t17
1 files changed, 9 insertions, 8 deletions
diff --git a/test/it.t b/test/it.t
index fe0b45d..fcc68e7 100755
--- a/test/it.t
+++ b/test/it.t
@@ -462,14 +462,15 @@ is(it::split("b", "abbba", ['no_empty' => true]), ["a", "a"]);
is(it::split("(b)", "aba", ['delim_capture' => true]), ["a", "b", "a"]);
is(it::split("b", "aabaa", ['offset_capture' => true]), [["aa", 0], ["aa", 3]]);
-it::file_put_contents("/tmp/it_test", "aa");
-is(($fh = it::fopen("/tmp/it_test", "r")) ? fgets($fh) : null, "aa");
-is(it::file_get_contents("/tmp/it_test"), "aa");
-is(it::file("/tmp/it_test"), ["aa"]);
+$tmpfile = tempnam("/tmp", "it_test");
+it::file_put_contents($tmpfile, "aa");
+is(($fh = it::fopen($tmpfile, "r")) ? fgets($fh) : null, "aa");
+is(it::file_get_contents($tmpfile), "aa");
+is(it::file($tmpfile), ["aa"]);
ob_start();
-it::readfile("/tmp/it_test");
+it::readfile($tmpfile);
is(ob_get_clean(), "aa");
-it::file_put("/tmp/it_test", "bb");
-is(it::file_get("/tmp/it_test"), "bb");
-it::system("rm -f /tmp/it_test");
+it::file_put($tmpfile, "bb");
+is(it::file_get($tmpfile), "bb");
+unlink($tmpfile);