ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\DAVACL\PrincipalSearchPropertySetTest Class Reference
+ Inheritance diagram for Sabre\DAVACL\PrincipalSearchPropertySetTest:
+ Collaboration diagram for Sabre\DAVACL\PrincipalSearchPropertySetTest:

Public Member Functions

 getServer ()
 
 testDepth1 ()
 
 testDepthIncorrectXML ()
 
 testCorrect ()
 

Detailed Description

Definition at line 10 of file PrincipalSearchPropertySetTest.php.

Member Function Documentation

◆ getServer()

Sabre\DAVACL\PrincipalSearchPropertySetTest::getServer ( )

Definition at line 12 of file PrincipalSearchPropertySetTest.php.

12 {
13
14 $backend = new PrincipalBackend\Mock();
15
16 $dir = new DAV\SimpleCollection('root');
17 $principals = new PrincipalCollection($backend);
18 $dir->addChild($principals);
19
20 $fakeServer = new DAV\Server($dir);
21 $fakeServer->sapi = new HTTP\SapiMock();
22 $fakeServer->httpResponse = new HTTP\ResponseMock();
23 $plugin = new Plugin();
24 $plugin->allowUnauthenticatedAccess = false;
25 $this->assertTrue($plugin instanceof Plugin);
26 $fakeServer->addPlugin($plugin);
27 $this->assertEquals($plugin, $fakeServer->getPlugin('acl'));
28
29 return $fakeServer;
30
31 }

Referenced by Sabre\DAVACL\PrincipalSearchPropertySetTest\testCorrect(), Sabre\DAVACL\PrincipalSearchPropertySetTest\testDepth1(), and Sabre\DAVACL\PrincipalSearchPropertySetTest\testDepthIncorrectXML().

+ Here is the caller graph for this function:

◆ testCorrect()

Sabre\DAVACL\PrincipalSearchPropertySetTest::testCorrect ( )

Definition at line 87 of file PrincipalSearchPropertySetTest.php.

87 {
88
89 $xml = '<?xml version="1.0"?>
90<d:principal-search-property-set xmlns:d="DAV:"/>';
91
92 $serverVars = [
93 'REQUEST_METHOD' => 'REPORT',
94 'HTTP_DEPTH' => '0',
95 'REQUEST_URI' => '/principals',
96 ];
97
99 $request->setBody($xml);
100
101 $server = $this->getServer();
102 $server->httpRequest = $request;
103
104 $server->exec();
105
106 $this->assertEquals(200, $server->httpResponse->status, $server->httpResponse->body);
107 $this->assertEquals([
108 'X-Sabre-Version' => [DAV\Version::VERSION],
109 'Content-Type' => ['application/xml; charset=utf-8'],
110 ], $server->httpResponse->getHeaders());
111
112
113 $check = [
114 '/d:principal-search-property-set',
115 '/d:principal-search-property-set/d:principal-search-property' => 2,
116 '/d:principal-search-property-set/d:principal-search-property/d:prop' => 2,
117 '/d:principal-search-property-set/d:principal-search-property/d:prop/d:displayname' => 1,
118 '/d:principal-search-property-set/d:principal-search-property/d:prop/s:email-address' => 1,
119 '/d:principal-search-property-set/d:principal-search-property/d:description' => 2,
120 ];
121
122 $xml = simplexml_load_string($server->httpResponse->body);
123 $xml->registerXPathNamespace('d', 'DAV:');
124 $xml->registerXPathNamespace('s', 'http://sabredav.org/ns');
125 foreach ($check as $v1 => $v2) {
126
127 $xpath = is_int($v1) ? $v2 : $v1;
128
129 $result = $xml->xpath($xpath);
130
131 $count = 1;
132 if (!is_int($v1)) $count = $v2;
133
134 $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body);
135
136 }
137
138 }
$result
foreach($paths as $path) $request
Definition: asyncclient.php:32
const VERSION
Full version number.
Definition: Version.php:17
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
$server
Definition: sabredav.php:48

References $request, $result, $server, $xml, Sabre\HTTP\Sapi\createFromServerArray(), Sabre\DAVACL\PrincipalSearchPropertySetTest\getServer(), and Sabre\DAV\Version\VERSION.

+ Here is the call graph for this function:

◆ testDepth1()

Sabre\DAVACL\PrincipalSearchPropertySetTest::testDepth1 ( )

Definition at line 33 of file PrincipalSearchPropertySetTest.php.

33 {
34
35 $xml = '<?xml version="1.0"?>
36<d:principal-search-property-set xmlns:d="DAV:" />';
37
38 $serverVars = [
39 'REQUEST_METHOD' => 'REPORT',
40 'HTTP_DEPTH' => '1',
41 'REQUEST_URI' => '/principals',
42 ];
43
45 $request->setBody($xml);
46
47 $server = $this->getServer();
48 $server->httpRequest = $request;
49
50 $server->exec();
51
52 $this->assertEquals(400, $server->httpResponse->status);
53 $this->assertEquals([
54 'X-Sabre-Version' => [DAV\Version::VERSION],
55 'Content-Type' => ['application/xml; charset=utf-8'],
56 ], $server->httpResponse->getHeaders());
57
58 }

References $request, $server, $xml, Sabre\HTTP\Sapi\createFromServerArray(), Sabre\DAVACL\PrincipalSearchPropertySetTest\getServer(), and Sabre\DAV\Version\VERSION.

+ Here is the call graph for this function:

◆ testDepthIncorrectXML()

Sabre\DAVACL\PrincipalSearchPropertySetTest::testDepthIncorrectXML ( )

Definition at line 60 of file PrincipalSearchPropertySetTest.php.

60 {
61
62 $xml = '<?xml version="1.0"?>
63<d:principal-search-property-set xmlns:d="DAV:"><d:ohell /></d:principal-search-property-set>';
64
65 $serverVars = [
66 'REQUEST_METHOD' => 'REPORT',
67 'HTTP_DEPTH' => '0',
68 'REQUEST_URI' => '/principals',
69 ];
70
72 $request->setBody($xml);
73
74 $server = $this->getServer();
75 $server->httpRequest = $request;
76
77 $server->exec();
78
79 $this->assertEquals(400, $server->httpResponse->status, $server->httpResponse->body);
80 $this->assertEquals([
81 'X-Sabre-Version' => [DAV\Version::VERSION],
82 'Content-Type' => ['application/xml; charset=utf-8'],
83 ], $server->httpResponse->getHeaders());
84
85 }

References $request, $server, $xml, Sabre\HTTP\Sapi\createFromServerArray(), Sabre\DAVACL\PrincipalSearchPropertySetTest\getServer(), and Sabre\DAV\Version\VERSION.

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: