1<?php
2
3namespace Sabre\DAV\Auth\Backend;
4
5class FileTest extends \PHPUnit_Framework_TestCase {
6
7    function tearDown() {
8
9        if (file_exists(SABRE_TEMPDIR . '/filebackend')) unlink(SABRE_TEMPDIR .'/filebackend');
10
11    }
12
13    function testConstruct() {
14
15        $file = new File();
16        $this->assertTrue($file instanceof File);
17
18    }
19
20    /**
21     * @expectedException Sabre\DAV\Exception
22     */
23    function testLoadFileBroken() {
24
25        file_put_contents(SABRE_TEMPDIR . '/backend','user:realm:hash');
26        $file = new File();
27        $file->loadFile(SABRE_TEMPDIR .'/backend');
28
29    }
30
31    function testLoadFile() {
32
33        file_put_contents(SABRE_TEMPDIR . '/backend','user:realm:' . md5('user:realm:password'));
34        $file = new File();
35        $file->loadFile(SABRE_TEMPDIR . '/backend');
36
37        $this->assertFalse($file->getDigestHash('realm','blabla'));
38        $this->assertEquals(md5('user:realm:password'), $file->getDigesthash('realm','user'));
39
40    }
41
42}
43