/usr/share/php/Horde/Test/Factory/Share.php is in php-horde-test 2.6.0+debian0-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | <?php
/**
* Generates test database connectors.
*
* PHP version 5
*
* @category Horde
* @package Test
* @author Gunnar Wrobel <wrobel@pardus.de>
* @license http://www.horde.org/licenses/lgpl21 LGPL
* @link http://www.horde.org/components/Horde_Test
*/
/**
* Generates test database connectors.
*
* Copyright 2011-2016 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @package Test
* @author Gunnar Wrobel <wrobel@pardus.de>
* @license http://www.horde.org/licenses/lgpl21 LGPL
* @link http://www.horde.org/components/Horde_Test
*/
class Horde_Test_Factory_Share
{
/**
* The injector.
*
* @var Horde_Injector
*/
private $_injector;
/**
* Constructor.
*
* @param Horde_Injector $injector The injector.
*/
public function __construct(Horde_Injector $injector)
{
$this->_injector = $injector;
}
/**
* Create a SQL next generate share setup.
*
* @param array $params Additional options.
* <pre>
* 'app' - (string) The application name.
* 'user' - (string) The current user.
* </pre>
*
* @return Horde_Share_Sqlng The share setup.
*/
public function create($params)
{
$shares = $this->_createShares('Horde_Share_Sqlng', $params);
try {
$db = $this->_injector->getInstance('Horde_Db_Adapter');
} catch (Exception $e) {
throw new Horde_Test_Exception(
sprintf(
'Failed creating the "Horde_Db_Adapter" service: %s',
$e->getMessage()
)
);
}
$shares->setStorage($db);
return $shares;
}
/**
* Create a Kolab share setup.
*
* @param array $params Additional options.
* <pre>
* 'app' - (string) The application name.
* 'user' - (string) The current user.
* </pre>
*
* @return Horde_Share_Sqlng The share setup.
*/
public function createKolab($params)
{
$shares = $this->_createShares('Horde_Share_Kolab', $params);
try {
$storage = $this->_injector->getInstance('Horde_Kolab_Storage');
} catch (Exception $e) {
throw new Horde_Test_Exception(
sprintf(
'Failed creating the "Horde_Kolab_Storage" service: %s',
$e->getMessage()
)
);
}
$shares->setStorage($storage);
return $shares;
}
/**
* Create the share handler.
*
* @param string $class Class name of the share handler.
* @param array $params Additional options.
*
* @return mixed The share handler.
*/
private function _createShares($class, $params)
{
if (!class_exists($class)) {
throw new Horde_Test_Exception("The \"$class\" class is unavailable!");
}
try {
$perms = $this->_injector->getInstance('Horde_Perms');
} catch (Exception $e) {
throw new Horde_Test_Exception(
sprintf(
'Failed creating the "Horde_Perms" service: %s',
$e->getMessage()
)
);
}
try {
$group = $this->_injector->getInstance('Horde_Group');
} catch (Exception $e) {
throw new Horde_Test_Exception(
sprintf(
'Failed creating the "Horde_Group" service: %s',
$e->getMessage()
)
);
}
return new $class($params['app'], $params['user'], $perms, $group);
}
}
|