You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FileTest.php 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. require_once 'FSTools/FileSystemHarness.php';
  3. /**
  4. * These are not really unit tests, just sanity checks of basic functionality.
  5. */
  6. class FSTools_FileTest extends FSTools_FileSystemHarness
  7. {
  8. public function test()
  9. {
  10. $name = 'test.txt';
  11. $file = new FSTools_File($name);
  12. $this->assertFalse($file->exists());
  13. $file->write('foobar');
  14. $this->assertTrue($file->exists());
  15. $this->assertEqual($file->get(), 'foobar');
  16. $file->delete();
  17. $this->assertFalse($file->exists());
  18. }
  19. public function testGetNonExistent()
  20. {
  21. $name = 'notfound.txt';
  22. $file = new FSTools_File($name);
  23. $this->expectError();
  24. $this->assertFalse($file->get());
  25. }
  26. public function testHandle()
  27. {
  28. $file = new FSTools_File('foo.txt');
  29. $this->assertFalse($file->exists());
  30. $file->open('w');
  31. $this->assertTrue($file->exists());
  32. $file->put('Foobar');
  33. $file->close();
  34. $file->open('r');
  35. $this->assertIdentical('F', $file->getChar());
  36. $this->assertFalse($file->eof());
  37. $this->assertIdentical('oo', $file->read(2));
  38. $this->assertIdentical('bar', $file->getLine());
  39. $this->assertTrue($file->eof());
  40. }
  41. }
  42. // vim: et sw=4 sts=4