]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/tests/Sabre/DAV/Browser/GuessContentTypeTest.php
Merge branch 'master' of git://github.com/friendica/friendica-addons
[friendica-addons.git] / dav / SabreDAV / tests / Sabre / DAV / Browser / GuessContentTypeTest.php
1 <?php
2
3 require_once 'Sabre/DAV/AbstractServer.php';
4 class Sabre_DAV_Browser_GuessContentTypeTest extends Sabre_DAV_AbstractServer {
5
6     function setUp() {
7
8         parent::setUp();
9         file_put_contents(SABRE_TEMPDIR . '/somefile.jpg','blabla');
10         file_put_contents(SABRE_TEMPDIR . '/somefile.hoi','blabla');
11
12     }
13
14     function tearDown() {
15
16         unlink(SABRE_TEMPDIR . '/somefile.jpg');
17         parent::tearDown();
18     }
19
20     function testGetProperties() {
21
22         $properties = array(
23             '{DAV:}getcontenttype',
24         );
25         $result = $this->server->getPropertiesForPath('/somefile.jpg',$properties);
26         $this->assertArrayHasKey(0,$result);
27         $this->assertArrayHasKey(404,$result[0]);
28         $this->assertArrayHasKey('{DAV:}getcontenttype',$result[0][404]);
29
30     }
31
32     /**
33      * @depends testGetProperties
34      */
35     function testGetPropertiesPluginEnabled() {
36
37         $this->server->addPlugin(new Sabre_DAV_Browser_GuessContentType());
38         $properties = array(
39             '{DAV:}getcontenttype',
40         );
41         $result = $this->server->getPropertiesForPath('/somefile.jpg',$properties);
42         $this->assertArrayHasKey(0,$result);
43         $this->assertArrayHasKey(200,$result[0]);
44         $this->assertArrayHasKey('{DAV:}getcontenttype',$result[0][200]);
45         $this->assertEquals('image/jpeg',$result[0][200]['{DAV:}getcontenttype']);
46
47     }
48
49     /**
50      * @depends testGetPropertiesPluginEnabled
51      */
52     function testGetPropertiesUnknown() {
53
54         $this->server->addPlugin(new Sabre_DAV_Browser_GuessContentType());
55         $properties = array(
56             '{DAV:}getcontenttype',
57         );
58         $result = $this->server->getPropertiesForPath('/somefile.hoi',$properties);
59         $this->assertArrayHasKey(0,$result);
60         $this->assertArrayHasKey(404,$result[0]);
61         $this->assertArrayHasKey('{DAV:}getcontenttype',$result[0][404]);
62
63     }
64 }