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

Public Member Functions

 setup ()
 
 testSimple ()
 
 testPrincipalProperties ()
 
 testNotificationProperties ()
 
 testNotificationGet ()
 
 testGETPassthrough ()
 

Protected Attributes

 $server
 
 $plugin
 
 $response
 
 $caldavBackend
 

Detailed Description

Definition at line 12 of file PluginTest.php.

Member Function Documentation

◆ setup()

Sabre\CalDAV\Notifications\PluginTest::setup ( )

Definition at line 28 of file PluginTest.php.

References $aclPlugin, $authBackend, $authPlugin, $principalBackend, Sabre\CalDAV\Notifications\PluginTest\$response, and $root.

28  {
29 
30  $this->caldavBackend = new CalDAV\Backend\MockSharing();
31  $principalBackend = new DAVACL\PrincipalBackend\Mock();
32  $calendars = new CalDAV\CalendarRoot($principalBackend, $this->caldavBackend);
33  $principals = new CalDAV\Principal\Collection($principalBackend);
34 
35  $root = new DAV\SimpleCollection('root');
36  $root->addChild($calendars);
37  $root->addChild($principals);
38 
39  $this->server = new DAV\Server($root);
40  $this->server->sapi = new HTTP\SapiMock();
41  $this->server->debugExceptions = true;
42  $this->server->setBaseUri('/');
43  $this->plugin = new Plugin();
44  $this->server->addPlugin($this->plugin);
45 
46 
47  // Adding ACL plugin
48  $aclPlugin = new DAVACL\Plugin();
49  $aclPlugin->allowUnauthenticatedAccess = false;
50  $this->server->addPlugin($aclPlugin);
51 
52  // CalDAV is also required.
53  $this->server->addPlugin(new CalDAV\Plugin());
54  // Adding Auth plugin, and ensuring that we are logged in.
55  $authBackend = new DAV\Auth\Backend\Mock();
56  $authPlugin = new DAV\Auth\Plugin($authBackend);
57  $this->server->addPlugin($authPlugin);
58 
59  // This forces a login
60  $authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response());
61 
62  $this->response = new HTTP\ResponseMock();
63  $this->server->httpResponse = $this->response;
64 
65  }
$root
Definition: sabredav.php:45
$authPlugin
$authBackend
$principalBackend
$aclPlugin

◆ testGETPassthrough()

Sabre\CalDAV\Notifications\PluginTest::testGETPassthrough ( )

Definition at line 153 of file PluginTest.php.

References Sabre\CalDAV\Notifications\PluginTest\$server.

153  {
154 
155  $server = new DAV\Server();
156  $caldav = new Plugin();
157 
158  $httpResponse = new HTTP\ResponseMock();
159  $server->httpResponse = $httpResponse;
160 
161  $server->addPlugin($caldav);
162 
163  $this->assertNull($caldav->httpGet(new HTTP\Request('GET', '/foozz'), $server->httpResponse));
164 
165  }

◆ testNotificationGet()

Sabre\CalDAV\Notifications\PluginTest::testNotificationGet ( )

Definition at line 117 of file PluginTest.php.

References Sabre\CalDAV\Notifications\PluginTest\$server.

117  {
118 
119  $notification = new Node(
120  $this->caldavBackend,
121  'principals/user1',
122  new SystemStatus('foo', '"1"')
123  );
124 
125  $server = new DAV\Server([$notification]);
126  $caldav = new Plugin();
127 
128  $server->httpRequest = new Request('GET', '/foo.xml');
129  $httpResponse = new HTTP\ResponseMock();
130  $server->httpResponse = $httpResponse;
131 
132  $server->addPlugin($caldav);
133 
134  $caldav->httpGet($server->httpRequest, $server->httpResponse);
135 
136  $this->assertEquals(200, $httpResponse->status);
137  $this->assertEquals([
138  'Content-Type' => ['application/xml'],
139  'ETag' => ['"1"'],
140  ], $httpResponse->getHeaders());
141 
142  $expected =
143 '<?xml version="1.0" encoding="UTF-8"?>
144 <cs:notification xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:cs="http://calendarserver.org/ns/">
145  <cs:systemstatus type="high"/>
146 </cs:notification>
147 ';
148 
149  $this->assertXmlStringEqualsXmlString($expected, $httpResponse->getBodyAsString());
150 
151  }

◆ testNotificationProperties()

Sabre\CalDAV\Notifications\PluginTest::testNotificationProperties ( )

Definition at line 97 of file PluginTest.php.

References Sabre\CalDAV\Notifications\Plugin\NS_CALENDARSERVER.

97  {
98 
99  $notification = new Node(
100  $this->caldavBackend,
101  'principals/user1',
102  new SystemStatus('foo', '"1"')
103  );
104  $propFind = new DAV\PropFind('calendars/user1/notifications', [
105  '{' . Plugin::NS_CALENDARSERVER . '}notificationtype',
106  ]);
107 
108  $this->plugin->propFind($propFind, $notification);
109 
110  $this->assertEquals(
111  $notification->getNotificationType(),
112  $propFind->get('{' . Plugin::NS_CALENDARSERVER . '}notificationtype')
113  );
114 
115  }
const NS_CALENDARSERVER
This is the namespace for the proprietary calendarserver extensions.
Definition: Plugin.php:32

◆ testPrincipalProperties()

Sabre\CalDAV\Notifications\PluginTest::testPrincipalProperties ( )

Definition at line 78 of file PluginTest.php.

References Sabre\CalDAV\Notifications\Plugin\NS_CALENDARSERVER.

78  {
79 
80  $httpRequest = new Request('GET', '/', ['Host' => 'sabredav.org']);
81  $this->server->httpRequest = $httpRequest;
82 
83  $props = $this->server->getPropertiesForPath('principals/admin', [
84  '{' . Plugin::NS_CALENDARSERVER . '}notification-URL',
85  ]);
86 
87  $this->assertArrayHasKey(0, $props);
88  $this->assertArrayHasKey(200, $props[0]);
89 
90  $this->assertArrayHasKey('{' . Plugin::NS_CALENDARSERVER . '}notification-URL', $props[0][200]);
91  $prop = $props[0][200]['{' . Plugin::NS_CALENDARSERVER . '}notification-URL'];
92  $this->assertTrue($prop instanceof DAV\Xml\Property\Href);
93  $this->assertEquals('calendars/admin/notifications/', $prop->getHref());
94 
95  }
const NS_CALENDARSERVER
This is the namespace for the proprietary calendarserver extensions.
Definition: Plugin.php:32

◆ testSimple()

Sabre\CalDAV\Notifications\PluginTest::testSimple ( )

Definition at line 67 of file PluginTest.php.

67  {
68 
69  $this->assertEquals([], $this->plugin->getFeatures());
70  $this->assertEquals('notifications', $this->plugin->getPluginName());
71  $this->assertEquals(
72  'notifications',
73  $this->plugin->getPluginInfo()['name']
74  );
75 
76  }

Field Documentation

◆ $caldavBackend

Sabre\CalDAV\Notifications\PluginTest::$caldavBackend
protected

Definition at line 26 of file PluginTest.php.

◆ $plugin

Sabre\CalDAV\Notifications\PluginTest::$plugin
protected

Definition at line 21 of file PluginTest.php.

◆ $response

Sabre\CalDAV\Notifications\PluginTest::$response
protected

Definition at line 22 of file PluginTest.php.

Referenced by Sabre\CalDAV\Notifications\PluginTest\setup().

◆ $server

Sabre\CalDAV\Notifications\PluginTest::$server
protected

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