-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
tests.php
47 lines (40 loc) · 1.45 KB
/
tests.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* Tests loader.
*
* This file is a part of the "common classes package", utilised by a number of
* packages and projects, including CIDRAM and phpMussel.
* @link https://github.com/Maikuolan/Common
*/
/**
* If this file remains intact after deploying the package to production,
* preventing it from running outside of Composer may be useful as a means of
* prevent potential attackers from hammering the file and needlessly wasting
* cycles at the server.
*/
if (!isset($_SERVER['COMPOSER_BINARY'])) {
die;
}
// Tests directory.
$TestsDir = __DIR__ . DIRECTORY_SEPARATOR . '.tests' . DIRECTORY_SEPARATOR;
// Classes directory.
$ClassesDir = __DIR__ . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR;
// Base directory.
$BaseDir = __DIR__ . DIRECTORY_SEPARATOR;
// Needed in order for tests to work properly.
if (!is_readable($ClassesDir . 'CommonAbstract.php')) {
echo 'CommonAbstract.php is not readable.' . PHP_EOL;
exit(1);
}
require $ClassesDir . 'CommonAbstract.php';
// Run tests.
foreach (['ComplexStringHandler', 'DelayedIO', 'Demojibakefier', 'Events', 'IPHeader', 'L10N', 'Matrix', 'NumberFormatter', 'Operation', 'Request', 'YAML'] as $Case) {
if (!is_readable($ClassesDir . $Case . '.php') || !is_readable($TestsDir . $Case . 'Test.php')) {
echo $Case . '.php is not readable.' . PHP_EOL;
exit(2);
}
$ExitCode = 3;
require $TestsDir . $Case . 'Test.php';
}
echo 'All tests passed.' . PHP_EOL;
exit(0);