TestUtil.php 621 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * Utilites for test functions
  4. */
  5. function Tests_Auth_Yadis_datafile($name, $reader)
  6. {
  7. $path = dirname(realpath(__FILE__));
  8. $sep = DIRECTORY_SEPARATOR;
  9. $filename = $path . $sep . 'data' . $sep . $name;
  10. $data = $reader($filename);
  11. if ($data === false) {
  12. $msg = "Failed to open data file: $name";
  13. trigger_error($msg, E_USER_ERROR);
  14. }
  15. return $data;
  16. }
  17. function Tests_Auth_Yadis_readdata($name)
  18. {
  19. return Tests_Auth_Yadis_datafile($name, 'file_get_contents');
  20. }
  21. function Tests_Auth_Yadis_readlines($name)
  22. {
  23. return Tests_Auth_Yadis_datafile($name, 'file');
  24. }