ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PluginTest.php
Go to the documentation of this file.
1 <?php
2 
4 
6 
7  protected $backend;
8  protected $plugin;
9 
10  protected $setupFiles = true;
11 
12  function setUp() {
13 
14  parent::setUp();
15  $this->backend = new Backend\Mock();
16  $this->plugin = new Plugin(
17  $this->backend
18  );
19 
20  $this->server->addPlugin($this->plugin);
21 
22  }
23 
24  function testGetInfo() {
25 
26  $this->assertArrayHasKey(
27  'name',
28  $this->plugin->getPluginInfo()
29  );
30 
31  }
32 
33  function testSetProperty() {
34 
35  $this->server->updateProperties('', ['{DAV:}displayname' => 'hi']);
36  $this->assertEquals([
37  '' => [
38  '{DAV:}displayname' => 'hi',
39  ]
40  ], $this->backend->data);
41 
42  }
43 
47  function testGetProperty() {
48 
49  $this->testSetProperty();
50  $result = $this->server->getProperties('', ['{DAV:}displayname']);
51 
52  $this->assertEquals([
53  '{DAV:}displayname' => 'hi',
54  ], $result);
55 
56  }
57 
61  function testDeleteProperty() {
62 
63  $this->testSetProperty();
64  $this->server->emit('afterUnbind', ['']);
65  $this->assertEquals([], $this->backend->data);
66 
67  }
68 
69  function testMove() {
70 
71  $this->server->tree->getNodeForPath('files')->createFile('source');
72  $this->server->updateProperties('files/source', ['{DAV:}displayname' => 'hi']);
73 
74  $request = new \Sabre\HTTP\Request('MOVE', '/files/source', ['Destination' => '/files/dest']);
75  $this->assertHTTPStatus(201, $request);
76 
77  $result = $this->server->getProperties('/files/dest', ['{DAV:}displayname']);
78 
79  $this->assertEquals([
80  '{DAV:}displayname' => 'hi',
81  ], $result);
82 
83  $this->server->tree->getNodeForPath('files')->createFile('source');
84  $result = $this->server->getProperties('/files/source', ['{DAV:}displayname']);
85 
86  $this->assertEquals([], $result);
87 
88  }
89 
94 
95  $this->plugin->pathFilter = function($path) {
96 
97  return false;
98 
99  };
100 
101  $this->server->updateProperties('', ['{DAV:}displayname' => 'hi']);
102  $this->assertEquals([], $this->backend->data);
103 
104  }
105 
110 
112  $result = $this->server->getProperties('', ['{DAV:}displayname']);
113 
114  $this->assertEquals([], $result);
115  }
116 
117 }
$path
Definition: aliased.php:25
$result
testGetPropertyInFilteredPath()
testSetPropertyInFilteredPath
Definition: PluginTest.php:109
foreach($paths as $path) $request
Definition: asyncclient.php:32
testSetPropertyInFilteredPath()
testDeleteProperty
Definition: PluginTest.php:93
testDeleteProperty()
testSetProperty
Definition: PluginTest.php:61
PropertyStorage Plugin.
Definition: Plugin.php:26
This class may be used as a basis for other webdav-related unittests.