ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilGlobalSuite Class Reference

This is the global ILIAS test suite. More...

+ Inheritance diagram for ilGlobalSuite:
+ Collaboration diagram for ilGlobalSuite:

Public Member Functions

 hasInstalledILIAS ()
 Check if there is an installed ILIAS to run tests on. More...
 

Static Public Member Functions

static suite ()
 

Data Fields

const PHPUNIT_GROUP_FOR_TESTS_REQUIRING_INSTALLED_ILIAS = "needsInstalledILIAS"
 
const REGEX_TEST_FILENAME = "#[a-zA-Z]+Test\.php#"
 
const PHP_UNIT_PARENT_CLASS = "PHPUnit_Framework_TestCase"
 

Static Protected Member Functions

static addTestFolderToSuite (ilGlobalSuite $suite)
 Find and add all testSuits beneath ILIAS_ROOL/tests - folder. More...
 

Detailed Description

This is the global ILIAS test suite.

It searches automatically for components test suites by scanning all Modules/.../test and Services/.../test directories for test suite files.

Test suite files are identified automatically, if they are named "ilServices[ServiceName]Suite.php" or ilModules[ModuleName]Suite.php".

Author
alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e

Definition at line 14 of file ilGlobalSuite.php.

Member Function Documentation

◆ addTestFolderToSuite()

static ilGlobalSuite::addTestFolderToSuite ( ilGlobalSuite  $suite)
staticprotected

Find and add all testSuits beneath ILIAS_ROOL/tests - folder.

Parameters
ilGlobalSuite$suite
Returns
ilGloblaSuite $suite

Definition at line 123 of file ilGlobalSuite.php.

123 {
124 $test_directories = array("tests");
125 while($aux_dir = current($test_directories)) {
126 if($handle = opendir($aux_dir)) {
127 $aux_dir .= DIRECTORY_SEPARATOR;
128 while (false !== ($entry = readdir($handle))) {
129 if($entry === '.' || $entry === '..') {
130 continue;
131 }
132 if(is_dir($aux_dir.$entry)) {
133 $test_directories[] = $aux_dir.$entry;
134 } else {
135 if(1 === preg_match(self::REGEX_TEST_FILENAME, $entry)) {
136 $ref_declared_classes = get_declared_classes();
137 require_once $aux_dir."/".$entry;
138 $new_declared_classes = array_diff(get_declared_classes(),$ref_declared_classes );
139 foreach ($new_declared_classes as $entry_class) {
140 $reflection = new ReflectionClass($entry_class);
141 if(!$reflection->isAbstract() && $reflection->isSubclassOf(self::PHP_UNIT_PARENT_CLASS)) {
142 echo "Adding Test-Suite: ".$entry_class."\n";
143 $suite->addTestSuite($entry_class);
144 }
145 }
146 }
147 }
148 }
149 }
150 next($test_directories);
151 }
152 return $suite;
153 }
$suite

References $suite.

Referenced by suite().

+ Here is the caller graph for this function:

◆ hasInstalledILIAS()

ilGlobalSuite::hasInstalledILIAS ( )

Check if there is an installed ILIAS to run tests on.

TODO: implement me correctly!

Returns
bool

Definition at line 29 of file ilGlobalSuite.php.

29 {
30 $ilias_ini_path = __DIR__."/../../../ilias.ini.php";
31
32 if(!is_file($ilias_ini_path)) {
33 return false;
34 }
35 require_once './Services/Init/classes/class.ilIniFile.php';
36 $ilias_ini = new ilIniFile($ilias_ini_path);
37 $ilias_ini->read();
38 $client_data_path = $ilias_ini->readVariable("server", "absolute_path")."/".$ilias_ini->readVariable("clients", "path");
39
40 if(!is_dir($client_data_path)) {
41 return false;
42 }
43
44 include_once($ilias_ini->readVariable("server", "absolute_path")."/Services/PHPUnit/config/cfg.phpunit.php");
45
46 if(!isset($_GET["client_id"])) {
47 return false;
48 }
49
50 $phpunit_client = $_GET["client_id"];
51
52 if(!$phpunit_client) {
53 return false;
54 }
55
56 if(!is_file($client_data_path."/".$phpunit_client."/client.ini.php")) {
57 return false;
58 }
59
60 return true;
61 }
$_GET["client_id"]
INIFile Parser.

References $_GET.

◆ suite()

static ilGlobalSuite::suite ( )
static

Definition at line 63 of file ilGlobalSuite.php.

64 {
65 $suite = new ilGlobalSuite();
66 echo "ILIAS PHPUnit-Tests need installed dev-requirements, please install using 'composer install' in ./libs/composer \n";
67 echo "\n";
68
69 // scan Modules and Services directories
70 $basedirs = array("Services", "Modules");
71
72 foreach ($basedirs as $basedir)
73 {
74 // read current directory
75 $dir = opendir($basedir);
76
77 while($file = readdir($dir))
78 {
79 if ($file != "." && $file != ".." && is_dir($basedir."/".$file))
80 {
81 $suite_path =
82 $basedir."/".$file."/test/il".$basedir.$file."Suite.php";
83 if (is_file($suite_path))
84 {
85 include_once($suite_path);
86
87 $name = "il".$basedir.$file."Suite";
88 $s = $name::suite();
89 echo "Adding Suite: ".$name."\n";
90 $suite->addTest($s);
91 //$suite->addTestSuite("ilSettingTest");
92 }
93 }
94 }
95 }
96
98
99 echo "\n";
100
101 if (!$suite->hasInstalledILIAS()) {
102 echo "Removing tests requiring an installed ILIAS.\n";
103 $ff = new PHPUnit_Runner_Filter_Factory();
104 $ff->addFilter
105 ( new ReflectionClass("PHPUnit_Runner_Filter_Group_Exclude")
106 , array(self::PHPUNIT_GROUP_FOR_TESTS_REQUIRING_INSTALLED_ILIAS)
107 );
108 $suite->injectFilter($ff);
109 }
110 else {
111 echo "Found installed ILIAS, running all tests.\n";
112 }
113
114 return $suite;
115 }
This is the global ILIAS test suite.
static addTestFolderToSuite(ilGlobalSuite $suite)
Find and add all testSuits beneath ILIAS_ROOL/tests - folder.
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file

References $file, $suite, and addTestFolderToSuite().

+ Here is the call graph for this function:

Field Documentation

◆ PHP_UNIT_PARENT_CLASS

const ilGlobalSuite::PHP_UNIT_PARENT_CLASS = "PHPUnit_Framework_TestCase"

Definition at line 21 of file ilGlobalSuite.php.

◆ PHPUNIT_GROUP_FOR_TESTS_REQUIRING_INSTALLED_ILIAS

const ilGlobalSuite::PHPUNIT_GROUP_FOR_TESTS_REQUIRING_INSTALLED_ILIAS = "needsInstalledILIAS"

Definition at line 19 of file ilGlobalSuite.php.

◆ REGEX_TEST_FILENAME

const ilGlobalSuite::REGEX_TEST_FILENAME = "#[a-zA-Z]+Test\.php#"

Definition at line 20 of file ilGlobalSuite.php.


The documentation for this class was generated from the following file: