ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilUnitUtil.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
9 class ilUnitUtil
10 {
14  public static function performInitialisation()
15  {
19  global $ilErr;
20 
21  if (!defined('IL_PHPUNIT_TEST')) {
22  define('IL_PHPUNIT_TEST', true);
23  }
24 
25  session_id('phpunittest');
26  $_SESSION = array();
27 
28  include 'Services/PHPUnit/config/cfg.phpunit.php';
29 
30  include_once 'Services/Context/classes/class.ilContext.php';
32 
33  include_once('Services/Init/classes/class.ilInitialisation.php');
35  ilInitialisation::initUserAccount();
36 
37  $ilUnitUtil = new self();
38  $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK, array($ilUnitUtil, 'errorHandler'));
39  PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ilUnitUtil, 'errorHandler'));
40  }
41 
46  public function errorHandler($a_error_obj)
47  {
48  echo "Error occured: ".get_class($a_error_obj)."\n";
49  try
50  {
51  throw new Exception("dummy");
52  }
53  catch(Exception $e)
54  {
55  echo($e->getTraceAsString()."\n\n");
56  }
57  exit();
58  }
59 }
exit
Definition: login.php:54
setErrorHandling($mode=null, $options=null)
Sets how errors generated by this object should be handled.
Definition: PEAR.php:335
const PEAR_ERROR_CALLBACK
Definition: PEAR.php:35
$_SESSION["AccountId"]
const CONTEXT_UNITTEST
Utilities for Unit Testing.
static initILIAS()
ilias initialisation
errorHandler($a_error_obj)
static init($a_type)
Init context by type.