ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 119 of file ilGlobalSuite.php.

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

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

References $_GET.

◆ suite()

static ilGlobalSuite::suite ( )
static

Definition at line 64 of file ilGlobalSuite.php.

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

References $name, $s, $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: