From 214387f3927092c46264123ddcca38d0a71205ad Mon Sep 17 00:00:00 2001 From: chunice Date: Wed, 2 Mar 2016 17:45:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Build=E7=B1=BB=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/thinkphp/library/think/buildTest.php | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/thinkphp/library/think/buildTest.php diff --git a/tests/thinkphp/library/think/buildTest.php b/tests/thinkphp/library/think/buildTest.php new file mode 100644 index 00000000..e3dcf18b --- /dev/null +++ b/tests/thinkphp/library/think/buildTest.php @@ -0,0 +1,71 @@ + +// +---------------------------------------------------------------------- + +/** + * build测试 + * @author 刘志淳 + */ + +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); + } + } + } + } + } + } +}