Repository navigation
Expand file tree
/
Copy pathRoboFile.php
More file actions
105 lines (87 loc) · 3.45 KB
/
Copy pathRoboFile.php
File metadata and controls
105 lines (87 loc) · 3.45 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
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
100
101
102
103
104
105
<?php
use Robo\Symfony\ConsoleIO;
use Symfony\Component\Finder\Finder;
/**
* This is project's console commands configuration for Robo task runner.
*
* @see https://robo.li/
*/
class RoboFile extends \Robo\Tasks {
protected $workspace_dir = 'tests/integration/workspace';
public function clean() {
$collection = $this->collectionBuilder();
$collection->taskFilesystemStack()
->remove($this->workspace_dir . '/.gitignore')
->run();
$collection->taskCleanDir([$this->workspace_dir])->run();
return $collection->run();
}
public function test(ConsoleIO $io, $version = 'dev-master') {
$composer_json = 'tests/integration/composer.site.json';
$collection = $this->collectionBuilder();
// 1. Clean workspace directory
$this->clean();
// 2. Install base SimpleID
$collection->taskComposerCreateProject()
->source('simpleid/simpleid:' . $version)
->target($this->workspace_dir)
->noInstall(true)
->noDev()
->run();
// 3. Update composer.json to add local repository
$collection->taskFilesystemStack()
->copy($composer_json, $this->workspace_dir . '/composer.site.json')
->run();
// 4. Update minimum-stability in root composer.json
$collection->taskComposerConfig()
->workingDir($this->workspace_dir)
->set('minimum-stability', 'dev')
->run();
$collection->taskComposerConfig()
->workingDir($this->workspace_dir)
->set('prefer-stable', 'true')
->run();
// 5. Try installing the test module
$collection->taskComposerUpdate()
->workingDir($this->workspace_dir)
->noDev()
->run();
// 6. See if module exists in the right location and is part of
// autoload
$collection->addCode(function() use ($io) {
$expected_file = $this->workspace_dir . '/www/site/test/src/TestModule/TestModule.php';
if (!file_exists($expected_file)) {
$io->error('Test module not installed');
return 1;
} else {
$io->success('Test module installed in expected location');
}
});
$collection->addCode(function() use ($io) {
$autoload_file = $this->workspace_dir . '/www/vendor/composer/autoload_psr4.php';
$autoloads = include($autoload_file);
if (!array_key_exists('SimpleID\\Modules\\TestModule\\', $autoloads)) {
$io->error('Test module not included in autoload');
return 1;
} else {
$io->success('Test module included in autoload');
}
});
return $collection->run();
}
public function update_copyright() {
$current_year = strftime("%Y");
$finder = new Finder();
$finder->in(['src'])->name('*.php');
foreach($finder as $file) {
$this->taskReplaceInFile($file)
->regex('/Copyright \(C\) Kelvin Mo (\d{4})-(\d{4})(\R)/m')
->to('Copyright (C) Kelvin Mo $1-'. $current_year . '$3')
->run();
$this->taskReplaceInFile($file)
->regex('/Copyright \(C\) Kelvin Mo (\d{4})(\R)/m')
->to('Copyright (C) Kelvin Mo $1-'. $current_year . '$2')
->run();
}
}
}