Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F1820951
TestUtil.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Size
1 KB
Subscribers
None
TestUtil.php
View Options
<?php
namespace
Sabre
;
class
TestUtil
{
/**
* This function deletes all the contents of the temporary directory.
*
* @return void
*/
static
function
clearTempDir
()
{
self
::
deleteTree
(
SABRE_TEMPDIR
,
false
);
}
static
private
function
deleteTree
(
$path
,
$deleteRoot
=
true
)
{
foreach
(
scandir
(
$path
)
as
$node
)
{
if
(
$node
==
'.'
||
$node
==
'..'
)
continue
;
$myPath
=
$path
.
'/'
.
$node
;
if
(
is_file
(
$myPath
))
{
unlink
(
$myPath
);
}
else
{
self
::
deleteTree
(
$myPath
);
}
}
if
(
$deleteRoot
)
{
rmdir
(
$path
);
}
}
static
function
getMySQLDB
()
{
try
{
$pdo
=
new
\PDO
(
SABRE_MYSQLDSN
,
SABRE_MYSQLUSER
,
SABRE_MYSQLPASS
);
$pdo
->
setAttribute
(
\PDO
::
ATTR_ERRMODE
,
\PDO
::
ERRMODE_EXCEPTION
);
return
$pdo
;
}
catch
(
\PDOException
$e
)
{
return
null
;
}
}
static
function
getSQLiteDB
()
{
$pdo
=
new
\PDO
(
'sqlite:'
.
SABRE_TEMPDIR
.
'/pdobackend'
);
$pdo
->
setAttribute
(
\PDO
::
ATTR_ERRMODE
,
\PDO
::
ERRMODE_EXCEPTION
);
return
$pdo
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Dec 22, 11:14 PM (2 d, 20 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
914397
Default Alt Text
TestUtil.php (1 KB)
Attached To
rDAVCAL DokuWiki DAVCal PlugIn
Event Timeline
Log In to Comment