Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
--TEST--
2
File_CSV Test Case bug14030: File_CSV::write() does not correctly quote field values
3
--FILE--
4
<?php
5
// $Id: bug14030.phpt,v 1.1 2008/09/21 21:17:49 dufuz Exp $
6
require 'File/CSV.php';
7
 
8
$rows = array(
9
    array(1, "I may be quoted", 1),
10
    array(2, "I \"must\" \"be\" quoted", 2),
11
    array(3, "   I must be quoted", 3),
12
    array(4, "I must be quoted   ", 4),
13
    array(5, "I must; \"be\"; quoted", 5),
14
    array(6, "I must\nbe\nquoted", 6),
15
);
16
 
17
$csv_conf = array(
18
    'fields' => 3,
19
    'crlf'   => "\r\n",
20
    'quote'  => '"',
21
    'sep'    => ';'
22
);
23
 
24
$csv_temp_filename = 'bug14030-to-delete.csv';
25
foreach ($rows as $csv_row) {
26
    $res = File_CSV::write($csv_temp_filename, $csv_row, $csv_conf);
27
}
28
 
29
echo file_get_contents($csv_temp_filename);
30
@unlink(dirname(__FILE__) . $csv_temp_filename);
31
?>
32
--EXPECT--
33
1;I may be quoted;1
34
2;"I ""must"" ""be"" quoted";2
35
3;"   I must be quoted";3
36
4;"I must be quoted   ";4
37
5;"I must; ""be""; quoted";5
38
6;"I must
39
be
40
quoted";6