-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathinstall.php
executable file
·99 lines (86 loc) · 2.48 KB
/
install.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env php
<?php
/**
* Part of CI PHPUnit Test
*
* @author Kenji Suzuki <https://github.com/kenjis>
* @license MIT License
* @copyright 2015 Kenji Suzuki
* @link https://github.com/kenjis/ci-phpunit-test
*/
$installer = new Installer();
$installer->prepareForWindows();
system('php vendor/kenjis/ci-phpunit-test/install.php');
$installer->install();
class Installer
{
public static function prepareForWindows()
{
if (! self::isWindows()) {
return;
}
// Remove symlink
unlink('application/tests/_ci_phpunit_test');
}
private static function isWindows(){
return defined('PHP_WINDOWS_VERSION_MAJOR');
}
public static function install()
{
self::recursiveCopy(
'vendor/kenjis/ci-phpunit-test/application/database',
'application/database'
);
self::recursiveCopy(
'vendor/kenjis/ci-phpunit-test/application/libraries',
'application/libraries'
);
self::copy(
'application/tests/phpunit.xml.dist',
'application/tests/phpunit.xml'
);
self::copy(
'application/tests/TestCase.php.dist',
'application/tests/TestCase.php'
);
self::copy(
'application/tests/Bootstrap.php.dist',
'application/tests/Bootstrap.php'
);
}
private static function copy($src, $dst)
{
$success = copy($src, $dst);
if ($success) {
echo 'copied: ' . $dst . PHP_EOL;
}
}
/**
* Recursive Copy
*
* @param string $src
* @param string $dst
*/
private static function recursiveCopy($src, $dst)
{
if (! is_dir($src)) {
echo 'No such directory: ' . $src . PHP_EOL;
return;
}
@mkdir($dst, 0755);
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($src, \RecursiveDirectoryIterator::SKIP_DOTS),
\RecursiveIteratorIterator::SELF_FIRST
);
foreach ($iterator as $file) {
if ($file->isDir()) {
@mkdir($dst . '/' . $iterator->getSubPathName());
} else {
$success = copy($file, $dst . '/' . $iterator->getSubPathName());
if ($success) {
echo 'copied: ' . $dst . '/' . $iterator->getSubPathName() . PHP_EOL;
}
}
}
}
}