PageRenderTime 37ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/libs/Chat/testcase/filemtime.php

https://code.google.com/
PHP | 16 lines | 14 code | 2 blank | 0 comment | 2 complexity | 376a44ded7611fb575645212a91c621b MD5 | raw file
Possible License(s): Apache-2.0, GPL-2.0
  1. <?php
  2. $filename = dirname(__FILE__).'/'.basename(__FILE__).'.data';
  3. $timetowait = 3;
  4. if (!is_writable(dirname($filename))) die($filename.' is not writable');
  5. file_put_contents($filename,'some-data1-'.time());
  6. clearstatcache();
  7. $time1 = filemtime($filename);
  8. sleep($timetowait);
  9. file_put_contents($filename,'some-data2-'.time());
  10. clearstatcache();
  11. $time2 = filemtime($filename);
  12. unlink($filename);
  13. echo ($time2-$time1 == $timetowait) ? "filemtime test passed successfully\n" : "filemtime test failed\n";
  14. ?>