PageRenderTime 49ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/Sabre/DAV/Auth/Backend/FileTest.php

https://github.com/KOLANICH/SabreDAV
PHP | 42 lines | 23 code | 16 blank | 3 comment | 1 complexity | ca8a4b42a350bacd110f85a099430d57 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. namespace Sabre\DAV\Auth\Backend;
  3. class FileTest extends \PHPUnit_Framework_TestCase {
  4. function tearDown() {
  5. if (file_exists(SABRE_TEMPDIR . '/filebackend')) unlink(SABRE_TEMPDIR .'/filebackend');
  6. }
  7. function testConstruct() {
  8. $file = new File();
  9. $this->assertTrue($file instanceof File);
  10. }
  11. /**
  12. * @expectedException Sabre\DAV\Exception
  13. */
  14. function testLoadFileBroken() {
  15. file_put_contents(SABRE_TEMPDIR . '/backend','user:realm:hash');
  16. $file = new File();
  17. $file->loadFile(SABRE_TEMPDIR .'/backend');
  18. }
  19. function testLoadFile() {
  20. file_put_contents(SABRE_TEMPDIR . '/backend','user:realm:' . md5('user:realm:password'));
  21. $file = new File();
  22. $file->loadFile(SABRE_TEMPDIR . '/backend');
  23. $this->assertFalse($file->getDigestHash('realm','blabla'));
  24. $this->assertEquals(md5('user:realm:password'), $file->getDigesthash('realm','user'));
  25. }
  26. }