forked from php-imagine/Imagine
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
70 lines (57 loc) · 2.59 KB
/
bootstrap.php
File metadata and controls
70 lines (57 loc) · 2.59 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/*
* This file is part of the Imagine package.
*
* (c) Bulat Shakirzyanov <mallluhuct@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
// This should be already included by Composer, but it's here just in case someone calls phpunit in other ways
require_once dirname(__DIR__) . '/vendor/autoload.php';
if ((int) (ini_get('memory_limit')) < 64) {
ini_set('memory_limit', '64M');
}
if (!class_exists('PHPUnit\Framework\Constraint\Constraint')) {
class_alias('PHPUnit_Framework_Constraint', 'PHPUnit\Framework\Constraint\Constraint');
}
if (!class_exists('PHPUnit\Framework\Exception')) {
class_alias('PHPUnit_Framework_Exception', 'PHPUnit\Framework\Exception');
}
if (!class_exists('PHPUnit\Framework\ExpectationFailedException')) {
class_alias('PHPUnit_Framework_ExpectationFailedException', 'PHPUnit\Framework\ExpectationFailedException');
}
if (!class_exists('PHPUnit\Runner\Version')) {
class_alias('PHPUnit_Runner_Version', 'PHPUnit\Runner\Version');
}
if (version_compare(PHPUnit\Runner\Version::id(), '7') >= 0) {
class_alias('Imagine\Test\Constraint\Constraint_v2', 'Imagine\Test\Constraint\Constraint');
} else {
class_alias('Imagine\Test\Constraint\Constraint_v1', 'Imagine\Test\Constraint\Constraint');
}
if (version_compare(PHPUnit\Runner\Version::id(), '8') >= 0) {
class_alias('Imagine\Test\ImagineTestCase_v2', 'Imagine\Test\ImagineTestCase');
} else {
class_alias('Imagine\Test\ImagineTestCase_v1', 'Imagine\Test\ImagineTestCase');
}
define('IMAGINE_TEST_SRCFOLDER', dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src');
define('IMAGINE_TEST_FIXTURESFOLDER', __DIR__ . DIRECTORY_SEPARATOR . 'fixtures');
define('IMAGINE_TEST_TEMPFOLDER', __DIR__ . DIRECTORY_SEPARATOR . 'tmp');
if (is_dir(IMAGINE_TEST_TEMPFOLDER)) {
$rc = -1;
$output = array();
if (DIRECTORY_SEPARATOR === '\\') {
exec('RMDIR /S /Q ' . escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, IMAGINE_TEST_TEMPFOLDER)) . ' 2>&1', $output, $rc);
} else {
exec('rm -rf ' . escapeshellarg(IMAGINE_TEST_TEMPFOLDER) . ' 2>&1', $output, $rc);
}
if ($rc !== 0) {
throw new Exception('Failed to delete directory ' . IMAGINE_TEST_TEMPFOLDER . ":\n" . implode("\n", $output));
}
unset($rc);
unset($output);
}
mkdir(IMAGINE_TEST_TEMPFOLDER);
$keepTestFiles = getenv('IMAGINE_TEST_KEEP_TEMPFILES');
define('IMAGINE_TEST_KEEP_TEMPFILES', !empty($keepTestFiles) && strcasecmp($keepTestFiles, 'no') !== 0 && strcasecmp($keepTestFiles, 'false') !== 0);
unset($keepTestFiles);