set_file_buffer.phpt 922 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --TEST--
  2. int set_file_buffer ( resource $stream , int $buffer );
  3. --CREDITS--
  4. marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br
  5. --FILE--
  6. <?php
  7. class test_wrapper {
  8. function stream_open($path, $mode, $openedpath) {
  9. return true;
  10. }
  11. function stream_eof() {
  12. return false;
  13. }
  14. function stream_write($data) {
  15. echo "size: ", strlen($data), "\n";
  16. return strlen($data);
  17. }
  18. function stream_set_option($option, $arg1, $arg2) {
  19. echo "option: ", $option, ", ", $arg1, ", ", $arg2, "\n";
  20. return false;
  21. }
  22. }
  23. var_dump(stream_wrapper_register('test', 'test_wrapper'));
  24. $fd = fopen("test://foo","r");
  25. var_dump(set_file_buffer($fd, 50));
  26. var_dump(stream_set_chunk_size($fd, 42));
  27. var_dump(fwrite($fd, str_repeat('0', 70)));
  28. ?>
  29. --CLEAN--
  30. <?php
  31. fclose($fd);
  32. unset($fd);
  33. ?>
  34. --EXPECTF--
  35. bool(true)
  36. option: %d, %d, %d
  37. int(%i)
  38. int(%d)
  39. size: %d
  40. size: %d
  41. int(%d)