ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  $GLOBALS['DIC']['ilAuthSession']->setUserId($_SESSION["AccountId"]);
36  ilInitialisation::initUserAccount();
37 
38  $ilUnitUtil = new self();
39  $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK, array($ilUnitUtil, 'errorHandler'));
40  PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ilUnitUtil, 'errorHandler'));
41  }
42 
47  public function errorHandler($a_error_obj)
48  {
49  echo "Error occured: " . get_class($a_error_obj) . "\n";
50  try {
51  throw new Exception("dummy");
52  } catch (Exception $e) {
53  echo($e->getTraceAsString() . "\n\n");
54  }
55  exit();
56  }
57 }
global $ilErr
Definition: raiseError.php:16
const PEAR_ERROR_CALLBACK
Definition: PEAR.php:35
$_SESSION["AccountId"]
const CONTEXT_UNITTEST
Utilities for Unit Testing.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static setErrorHandling($mode=null, $options=null)
Sets how errors generated by this object should be handled.
Definition: PEAR.php:337
errorHandler($a_error_obj)
Create styles array
The data for the language used.
static init($a_type)
Init context by type.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27