3 * Tine 2.0 - http://www.tine20.org
6 * @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
7 * @copyright Copyright (c) 2013-2014 Metaways Infosystems GmbH (http://www.metaways.de)
8 * @author Philipp Schüle <p.schuele@metaways.de>
12 * Test class for Calendar_Backend_Sql
16 abstract class ServerTestCase extends PHPUnit_Framework_TestCase
18 protected $preserveGlobalState = false;
19 protected $runTestInSeparateProcess = true;
22 * transaction id if test is wrapped in an transaction
26 protected $_transactionId = null;
36 protected function setUp()
38 Zend_Session::$_unitTestEnabled = true;
41 $configData = @include('phpunitconfig.inc.php');
42 if ($configData === false) {
43 $configData = include('config.inc.php');
45 if ($configData === false) {
46 die ('central configuration file config.inc.php not found in includepath: ' . get_include_path());
48 $this->_config = new Zend_Config($configData);
50 $this->_transactionId = Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
56 protected function tearDown()
58 Zend_Session::$_unitTestEnabled = false;
60 if ($this->_transactionId) {
61 Tinebase_TransactionManager::getInstance()->rollBack();
66 * Performs custom preparations on the process isolation template.
68 * @param Text_Template $template
69 * @since Method available since Release 3.4.0
71 protected function prepareTemplate(Text_Template $template)
73 // needed to get bootstrap file included in separate process again
74 $template->setVar(array(
75 'globals' => sprintf("\$GLOBALS['__PHPUNIT_BOOTSTRAP'] = '%s/bootstrap.php';", __DIR__)
80 * fetch test user credentials
84 public function getTestCredentials()
86 $config = $this->_config;
87 $username = isset($config->login->username) ? $config->login->username : $config->username;
88 $password = isset($config->login->password) ? $config->login->password : $config->password;
91 'username' => $username,
92 'password' => $password
100 * @return Tinebase_Model_FullUser
102 public function getAccountByName($name)
104 return Tinebase_User::getInstance()->getFullUserByLoginName($name);
109 * @param Tinebase_Model_User $account
110 * @param string $recordClass
111 * @return Tinebase_Record_RecordSet
113 public function getPersonalContainer(Tinebase_Model_User $account, $recordClass)
115 return Tinebase_Container::getInstance()
116 ->getPersonalContainer($account, $recordClass, $account, Tinebase_Model_Grants::GRANT_ADMIN);