buildTest.php
2.8 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
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
/**
* build测试
* @author 刘志淳 <chun@engineer.com>
*/
namespace tests\thinkphp\library\think;
use think\Build;
class buildTest extends \PHPUnit_Framework_TestCase
{
public function testRun()
{
$build = [
// Test run directory
'__dir__' => ['runtime/cache', 'runtime/log', 'runtime/temp', 'runtime/template'],
'__file__' => ['common.php'],
// Test generation module
'demo' => [
'__file__' => ['common.php'],
'__dir__' => ['behavior', 'controller', 'model', 'view', 'service'],
'controller' => ['Index', 'Test', 'UserType'],
'model' => ['User', 'UserType'],
'service' => ['User', 'UserType'],
'view' => ['index/index'],
],
];
Build::run($build);
$this->buildFileExists($build);
}
protected function buildFileExists($build)
{
foreach ($build as $module => $list) {
if ('__dir__' == $module || '__file__' == $module) {
foreach ($list as $file) {
$this->assertFileExists(APP_PATH . $file);
}
} else {
foreach ($list as $path => $moduleList) {
if ('__file__' == $path || '__dir__' == $path) {
foreach ($moduleList as $file) {
$this->assertFileExists(APP_PATH . $module . '/' . $file);
}
} else {
foreach ($moduleList as $file) {
if ('view' == $path) {
$file_name = APP_PATH . $module . '/' . $path . '/' . $file . '.html';
} else {
$file_name = APP_PATH . $module . '/' . $path . '/' . $file . EXT;
}
$this->assertFileExists($file_name);
}
}
}
$this->assertFileExists(APP_PATH . ($module ? $module . DS : '') . 'config.php');
}
}
}
}