Skip to content

Commit 54f0d50

Browse files
committed
Made some SplFileObject::fputcsv not pollute the working dir.
1 parent 09e367d commit 54f0d50

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

ext/spl/tests/SplFileObject_fputcsv_002.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
SplFileObject::fputcsv(): Checking data after calling the function
33
--FILE--
44
<?php
5-
$fo = new SplFileObject('SplFileObject_fputcsv.csv', 'w');
5+
$fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv.csv', 'w');
66

77
$data = array(1, 2, 'foo', 'haha', array(4, 5, 6), 1.3, null);
88

@@ -12,7 +12,8 @@ var_dump($data);
1212
?>
1313
--CLEAN--
1414
<?php
15-
unlink('SplFileObject::fputcsv.csv');
15+
$file = __DIR__ . '/SplFileObject_fputcsv.csv';
16+
unlink($file);
1617
?>
1718
--EXPECTF--
1819
Notice: Array to string conversion in %s on line %d

ext/spl/tests/SplFileObject_fputcsv_error.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
SplFileObject::fputcsv(): error conditions
33
--FILE--
44
<?php
5-
$fo = new SplFileObject('SplFileObject_fputcsv.csv', 'w');
5+
$fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv.csv', 'w');
66

77
echo "*** Testing error conditions ***\n";
88
// zero argument
@@ -17,6 +17,11 @@ $enclosure ="\"";
1717
var_dump( $fo->fputcsv($fields, $delim, $enclosure, $fo) );
1818

1919
echo "Done\n";
20+
--CLEAN--
21+
<?php
22+
$file = __DIR__ . '/SplFileObject_fputcsv.csv';
23+
unlink($file);
24+
?>
2025
--EXPECTF--
2126
*** Testing error conditions ***
2227
-- Testing fputcsv() with zero argument --

ext/spl/tests/SplFileObject_fputcsv_variation13.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Test fputcsv() : usage variations - with default enclosure & delimiter of two ch
88

99
echo "*** Testing fputcsv() : with default enclosure & delimiter of two chars ***\n";
1010

11-
$fo = new SplFileObject('SplFileObject_fputcsv.csv', 'w');
11+
$fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv.csv', 'w');
1212

1313
var_dump($fo->fputcsv(array('water', 'fruit'), ',,', '"'));
1414

@@ -18,7 +18,8 @@ echo "Done\n";
1818
?>
1919
--CLEAN--
2020
<?php
21-
unlink('SplFileObject::fputcsv.csv');
21+
$file = __DIR__ . '/SplFileObject_fputcsv.csv';
22+
unlink($file);
2223
?>
2324
--EXPECTF--
2425
*** Testing fputcsv() : with default enclosure & delimiter of two chars ***

ext/spl/tests/SplFileObject_fputcsv_variation14.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Test fputcsv() : usage variations - with enclosure & delimiter of two chars
88

99
echo "*** Testing fputcsv() : with enclosure & delimiter of two chars and file opened in read mode ***\n";
1010

11-
$fo = new SplFileObject('SplFileObject_fputcsv.csv', 'w');
11+
$fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv.csv', 'w');
1212

1313
var_dump($fo->fputcsv(array('water', 'fruit'), ',,', '""'));
1414

@@ -18,7 +18,8 @@ echo "Done\n";
1818
?>
1919
--CLEAN--
2020
<?php
21-
unlink('SplFileObject::fputcsv.csv');
21+
$file = __DIR__ . '/SplFileObject_fputcsv.csv';
22+
unlink($file);
2223
?>
2324
--EXPECTF--
2425
*** Testing fputcsv() : with enclosure & delimiter of two chars and file opened in read mode ***

0 commit comments

Comments
 (0)