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

Public Member Functions

 setUp ()
 
 testConstruct ()
 
 testGetPrincipalsByPrefix ()
 testConstruct More...
 
 testGetPrincipalByPath ()
 testConstruct More...
 
 testGetGroupMemberSet ()
 
 testGetGroupMembership ()
 
 testSetGroupMemberSet ()
 
 testSearchPrincipals ()
 
 testUpdatePrincipal ()
 
 testUpdatePrincipalUnknownField ()
 
 testFindByUriUnknownScheme ()
 
 testFindByUri ()
 

Detailed Description

Definition at line 8 of file AbstractPDOTest.php.

Member Function Documentation

◆ setUp()

Sabre\DAVACL\PrincipalBackend\AbstractPDOTest::setUp ( )

Definition at line 12 of file AbstractPDOTest.php.

References $pdo, Sabre\DAV\createSchema(), Sabre\DAV\dropTables(), and Sabre\DAV\getPDO().

12  {
13 
14  $this->dropTables(['principals', 'groupmembers']);
15  $this->createSchema('principals');
16 
17  $pdo = $this->getPDO();
18 
19  $pdo->query("INSERT INTO principals (uri,email,displayname) VALUES ('principals/user','user@example.org','User')");
20  $pdo->query("INSERT INTO principals (uri,email,displayname) VALUES ('principals/group','group@example.org','Group')");
21 
22  $pdo->query("INSERT INTO groupmembers (principal_id,member_id) VALUES (5,4)");
23 
24  }
getPDO()
Alias for getDb.
dropTables($tableNames)
Drops tables, if they exist.
createSchema($schemaName)
Uses .sql files from the examples directory to initialize the database.
$pdo
Definition: migrateto20.php:62
+ Here is the call graph for this function:

◆ testConstruct()

Sabre\DAVACL\PrincipalBackend\AbstractPDOTest::testConstruct ( )

Definition at line 27 of file AbstractPDOTest.php.

References $pdo, and Sabre\DAV\getPDO().

27  {
28 
29  $pdo = $this->getPDO();
30  $backend = new PDO($pdo);
31  $this->assertTrue($backend instanceof PDO);
32 
33  }
getPDO()
Alias for getDb.
$pdo
Definition: migrateto20.php:62
+ Here is the call graph for this function:

◆ testFindByUri()

Sabre\DAVACL\PrincipalBackend\AbstractPDOTest::testFindByUri ( )

Definition at line 206 of file AbstractPDOTest.php.

References $pdo, and Sabre\DAV\getPDO().

206  {
207 
208  $pdo = $this->getPDO();
209  $backend = new PDO($pdo);
210  $this->assertEquals(
211  'principals/user',
212  $backend->findByUri('mailto:user@example.org', 'principals')
213  );
214 
215  }
getPDO()
Alias for getDb.
$pdo
Definition: migrateto20.php:62
+ Here is the call graph for this function:

◆ testFindByUriUnknownScheme()

Sabre\DAVACL\PrincipalBackend\AbstractPDOTest::testFindByUriUnknownScheme ( )

Definition at line 197 of file AbstractPDOTest.php.

References $pdo, and Sabre\DAV\getPDO().

197  {
198 
199  $pdo = $this->getPDO();
200  $backend = new PDO($pdo);
201  $this->assertNull($backend->findByUri('http://foo', 'principals'));
202 
203  }
getPDO()
Alias for getDb.
$pdo
Definition: migrateto20.php:62
+ Here is the call graph for this function:

◆ testGetGroupMemberSet()

Sabre\DAVACL\PrincipalBackend\AbstractPDOTest::testGetGroupMemberSet ( )

Definition at line 86 of file AbstractPDOTest.php.

References $pdo, and Sabre\DAV\getPDO().

86  {
87 
88  $pdo = $this->getPDO();
89  $backend = new PDO($pdo);
90  $expected = ['principals/user'];
91 
92  $this->assertEquals($expected, $backend->getGroupMemberSet('principals/group'));
93 
94  }
getPDO()
Alias for getDb.
$pdo
Definition: migrateto20.php:62
+ Here is the call graph for this function:

◆ testGetGroupMembership()

Sabre\DAVACL\PrincipalBackend\AbstractPDOTest::testGetGroupMembership ( )

Definition at line 96 of file AbstractPDOTest.php.

References $pdo, and Sabre\DAV\getPDO().

96  {
97 
98  $pdo = $this->getPDO();
99  $backend = new PDO($pdo);
100  $expected = ['principals/group'];
101 
102  $this->assertEquals($expected, $backend->getGroupMembership('principals/user'));
103 
104  }
getPDO()
Alias for getDb.
$pdo
Definition: migrateto20.php:62
+ Here is the call graph for this function:

◆ testGetPrincipalByPath()

Sabre\DAVACL\PrincipalBackend\AbstractPDOTest::testGetPrincipalByPath ( )

testConstruct

Definition at line 69 of file AbstractPDOTest.php.

References $pdo, and Sabre\DAV\getPDO().

69  {
70 
71  $pdo = $this->getPDO();
72  $backend = new PDO($pdo);
73 
74  $expected = [
75  'id' => 4,
76  'uri' => 'principals/user',
77  '{http://sabredav.org/ns}email-address' => 'user@example.org',
78  '{DAV:}displayname' => 'User',
79  ];
80 
81  $this->assertEquals($expected, $backend->getPrincipalByPath('principals/user'));
82  $this->assertEquals(null, $backend->getPrincipalByPath('foo'));
83 
84  }
getPDO()
Alias for getDb.
$pdo
Definition: migrateto20.php:62
+ Here is the call graph for this function:

◆ testGetPrincipalsByPrefix()

Sabre\DAVACL\PrincipalBackend\AbstractPDOTest::testGetPrincipalsByPrefix ( )

testConstruct

Definition at line 38 of file AbstractPDOTest.php.

References $pdo, and Sabre\DAV\getPDO().

38  {
39 
40  $pdo = $this->getPDO();
41  $backend = new PDO($pdo);
42 
43  $expected = [
44  [
45  'uri' => 'principals/admin',
46  '{http://sabredav.org/ns}email-address' => 'admin@example.org',
47  '{DAV:}displayname' => 'Administrator',
48  ],
49  [
50  'uri' => 'principals/user',
51  '{http://sabredav.org/ns}email-address' => 'user@example.org',
52  '{DAV:}displayname' => 'User',
53  ],
54  [
55  'uri' => 'principals/group',
56  '{http://sabredav.org/ns}email-address' => 'group@example.org',
57  '{DAV:}displayname' => 'Group',
58  ],
59  ];
60 
61  $this->assertEquals($expected, $backend->getPrincipalsByPrefix('principals'));
62  $this->assertEquals([], $backend->getPrincipalsByPrefix('foo'));
63 
64  }
getPDO()
Alias for getDb.
$pdo
Definition: migrateto20.php:62
+ Here is the call graph for this function:

◆ testSearchPrincipals()

Sabre\DAVACL\PrincipalBackend\AbstractPDOTest::testSearchPrincipals ( )

Definition at line 125 of file AbstractPDOTest.php.

References $pdo, $result, and Sabre\DAV\getPDO().

125  {
126 
127  $pdo = $this->getPDO();
128 
129  $backend = new PDO($pdo);
130 
131  $result = $backend->searchPrincipals('principals', ['{DAV:}blabla' => 'foo']);
132  $this->assertEquals([], $result);
133 
134  $result = $backend->searchPrincipals('principals', ['{DAV:}displayname' => 'ou']);
135  $this->assertEquals(['principals/group'], $result);
136 
137  $result = $backend->searchPrincipals('principals', ['{DAV:}displayname' => 'UsEr', '{http://sabredav.org/ns}email-address' => 'USER@EXAMPLE']);
138  $this->assertEquals(['principals/user'], $result);
139 
140  $result = $backend->searchPrincipals('mom', ['{DAV:}displayname' => 'UsEr', '{http://sabredav.org/ns}email-address' => 'USER@EXAMPLE']);
141  $this->assertEquals([], $result);
142 
143  }
$result
getPDO()
Alias for getDb.
$pdo
Definition: migrateto20.php:62
+ Here is the call graph for this function:

◆ testSetGroupMemberSet()

Sabre\DAVACL\PrincipalBackend\AbstractPDOTest::testSetGroupMemberSet ( )

Definition at line 106 of file AbstractPDOTest.php.

References $pdo, and Sabre\DAV\getPDO().

106  {
107 
108  $pdo = $this->getPDO();
109 
110  // Start situation
111  $backend = new PDO($pdo);
112  $this->assertEquals(['principals/user'], $backend->getGroupMemberSet('principals/group'));
113 
114  // Removing all principals
115  $backend->setGroupMemberSet('principals/group', []);
116  $this->assertEquals([], $backend->getGroupMemberSet('principals/group'));
117 
118  // Adding principals again
119  $backend->setGroupMemberSet('principals/group', ['principals/user']);
120  $this->assertEquals(['principals/user'], $backend->getGroupMemberSet('principals/group'));
121 
122 
123  }
getPDO()
Alias for getDb.
$pdo
Definition: migrateto20.php:62
+ Here is the call graph for this function:

◆ testUpdatePrincipal()

Sabre\DAVACL\PrincipalBackend\AbstractPDOTest::testUpdatePrincipal ( )

Definition at line 145 of file AbstractPDOTest.php.

References $pdo, $result, and Sabre\DAV\getPDO().

145  {
146 
147  $pdo = $this->getPDO();
148  $backend = new PDO($pdo);
149 
150  $propPatch = new DAV\PropPatch([
151  '{DAV:}displayname' => 'pietje',
152  ]);
153 
154  $backend->updatePrincipal('principals/user', $propPatch);
155  $result = $propPatch->commit();
156 
157  $this->assertTrue($result);
158 
159  $this->assertEquals([
160  'id' => 4,
161  'uri' => 'principals/user',
162  '{DAV:}displayname' => 'pietje',
163  '{http://sabredav.org/ns}email-address' => 'user@example.org',
164  ], $backend->getPrincipalByPath('principals/user'));
165 
166  }
$result
getPDO()
Alias for getDb.
$pdo
Definition: migrateto20.php:62
+ Here is the call graph for this function:

◆ testUpdatePrincipalUnknownField()

Sabre\DAVACL\PrincipalBackend\AbstractPDOTest::testUpdatePrincipalUnknownField ( )

Definition at line 168 of file AbstractPDOTest.php.

References $pdo, $result, and Sabre\DAV\getPDO().

168  {
169 
170  $pdo = $this->getPDO();
171  $backend = new PDO($pdo);
172 
173  $propPatch = new DAV\PropPatch([
174  '{DAV:}displayname' => 'pietje',
175  '{DAV:}unknown' => 'foo',
176  ]);
177 
178  $backend->updatePrincipal('principals/user', $propPatch);
179  $result = $propPatch->commit();
180 
181  $this->assertFalse($result);
182 
183  $this->assertEquals([
184  '{DAV:}displayname' => 424,
185  '{DAV:}unknown' => 403
186  ], $propPatch->getResult());
187 
188  $this->assertEquals([
189  'id' => '4',
190  'uri' => 'principals/user',
191  '{DAV:}displayname' => 'User',
192  '{http://sabredav.org/ns}email-address' => 'user@example.org',
193  ], $backend->getPrincipalByPath('principals/user'));
194 
195  }
$result
getPDO()
Alias for getDb.
$pdo
Definition: migrateto20.php:62
+ Here is the call graph for this function:

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