SplFileObject_fputcsv_error.phpt 993 B

123456789101112131415161718192021222324252627282930313233343536
  1. --TEST--
  2. SplFileObject::fputcsv(): error conditions
  3. --FILE--
  4. <?php
  5. $fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv2.csv', 'w');
  6. echo "*** Testing error conditions ***\n";
  7. // zero argument
  8. echo "-- Testing fputcsv() with zero argument --\n";
  9. var_dump( $fo->fputcsv() );
  10. // more than expected no. of args
  11. echo "-- Testing fputcsv() with more than expected number of arguments --\n";
  12. $fields = array("fld1", "fld2");
  13. $delim = ";";
  14. $enclosure ="\"";
  15. $escape = "\\";
  16. var_dump( $fo->fputcsv($fields, $delim, $enclosure, $escape, $fo) );
  17. echo "Done\n";
  18. --CLEAN--
  19. <?php
  20. $file = __DIR__ . '/SplFileObject_fputcsv2.csv';
  21. unlink($file);
  22. ?>
  23. --EXPECTF--
  24. *** Testing error conditions ***
  25. -- Testing fputcsv() with zero argument --
  26. Warning: SplFileObject::fputcsv() expects at least 1 parameter, 0 given in %s on line %d
  27. NULL
  28. -- Testing fputcsv() with more than expected number of arguments --
  29. Warning: SplFileObject::fputcsv() expects at most 4 parameters, 5 given in %s on line %d
  30. NULL
  31. Done