File: FileTest.php

package info (click to toggle)
php-sabredav 1.8.12-7
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,848 kB
  • sloc: php: 28,471; sql: 271; python: 221; makefile: 35; xml: 25; sh: 6
file content (42 lines) | stat: -rw-r--r-- 989 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php

namespace Sabre\DAV\Auth\Backend;

class FileTest extends \PHPUnit\Framework\TestCase {

    function tearDown() {

        if (file_exists(SABRE_TEMPDIR . '/filebackend')) unlink(SABRE_TEMPDIR .'/filebackend');

    }

    function testConstruct() {

        $file = new File();
        $this->assertTrue($file instanceof File);

    }

    /**
     * @expectedException Sabre\DAV\Exception
     */
    function testLoadFileBroken() {

        file_put_contents(SABRE_TEMPDIR . '/backend','user:realm:hash');
        $file = new File();
        $file->loadFile(SABRE_TEMPDIR .'/backend');

    }

    function testLoadFile() {

        file_put_contents(SABRE_TEMPDIR . '/backend','user:realm:' . md5('user:realm:password'));
        $file = new File();
        $file->loadFile(SABRE_TEMPDIR . '/backend');

        $this->assertFalse($file->getDigestHash('realm','blabla'));
        $this->assertEquals(md5('user:realm:password'), $file->getDigesthash('realm','user'));

    }

}