2 // vim: foldmethod=marker
4 * Ethna_Plugin_Generator_ViewTest.php
6 * @author Masaki Fujimoto <fujimoto@php.net>
7 * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
12 // {{{ Ethna_Plugin_Generator_ViewTest
14 * ¥¹¥±¥ë¥È¥óÀ¸À®¥¯¥é¥¹
16 * @author Masaki Fujimoto <fujimoto@php.net>
20 class Ethna_Plugin_Generator_ViewTest extends Ethna_Plugin_Generator
23 * ¥Ó¥å¡¼Íѥƥ¹¥È¤Î¥¹¥±¥ë¥È¥ó¤òÀ¸À®¤¹¤ë
26 * @param string $forward_name ¥Ó¥å¡¼Ì¾
27 * @param string $skelton ¥¹¥±¥ë¥È¥ó¥Õ¥¡¥¤¥ë̾
28 * @return true|Ethna_Error true:À®¸ù Ethna_Error:¼ºÇÔ
30 function &generate($forward_name, $skelton = null, $gateway = GATEWAY_WWW)
32 $view_dir = $this->ctl->getViewdir();
33 $view_class = $this->ctl->getDefaultViewClass($forward_name, $gateway);
34 $view_path = $this->ctl->getDefaultViewPath($forward_name . 'Test');
37 $entity = $view_dir . $view_path;
38 Ethna_Util::mkdir(dirname($entity), 0755);
41 if ($skelton === null) {
42 $skelton = 'skel.view_test.php';
47 $macro['project_id'] = $this->ctl->getAppId();
48 $macro['forward_name'] = $forward_name;
49 $macro['view_class'] = $view_class;
50 $macro['view_path'] = $view_path;
53 $user_macro = $this->_getUserMacro();
54 $macro = array_merge($macro, $user_macro);
58 if (file_exists($entity)) {
59 printf("file [%s] already exists -> skip\n", $entity);
60 } else if ($this->_generateFile($skelton, $entity, $macro) == false) {
61 printf("[warning] file creation failed [%s]\n", $entity);
63 printf("view test(s) successfully created [%s]\n", $entity);