fileobject_005.phpt 910 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --TEST--
  2. SPL: SplFileObject truncate tests
  3. --CREDITS--
  4. Mark Ammann
  5. #Hackday Webtuesday 2008-05-24
  6. --FILE--
  7. <?php
  8. set_include_path(dirname(dirname(__FILE__)));
  9. $path = dirname(__FILE__).DIRECTORY_SEPARATOR.'fileobject_005.txt';
  10. touch($path);
  11. $fo = new SplFileObject('tests'.DIRECTORY_SEPARATOR.'fileobject_005.txt', 'w+', true);
  12. $fo->fwrite("blahlubba");
  13. var_dump($fo->ftruncate(4));
  14. $fo->rewind();
  15. var_dump($fo->fgets(8));
  16. $fo->rewind();
  17. $fo->fwrite("blahlubba");
  18. // This should throw a warning and return NULL since an argument is missing
  19. var_dump($fo->ftruncate());
  20. ?>
  21. ==DONE==
  22. --CLEAN--
  23. <?php
  24. $path = dirname(__FILE__).DIRECTORY_SEPARATOR.'fileobject_005.txt';
  25. unlink($path);
  26. ?>
  27. --EXPECTF--
  28. bool(true)
  29. Warning: SplFileObject::fgets() expects exactly 0 parameters, 1 given in %s on line %d
  30. NULL
  31. Warning: SplFileObject::ftruncate() expects exactly 1 parameter, 0 given in %s on line %d
  32. NULL
  33. ==DONE==