mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
添加Build类单元测试
This commit is contained in:
71
tests/thinkphp/library/think/buildTest.php
Normal file
71
tests/thinkphp/library/think/buildTest.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?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'],
|
||||
'controller' => ['Index', 'Test', 'UserType'],
|
||||
'model' => ['User', 'UserType'],
|
||||
'view' => ['index/index'],
|
||||
],
|
||||
];
|
||||
Build::run($build);
|
||||
|
||||
$this->build_file_exists($build);
|
||||
}
|
||||
|
||||
protected function build_file_exists($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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user