PageRenderTime 46ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/code/ryzom/tools/server/www/webtt/cake/tests/cases/console/libs/tasks/controller.test.php

https://bitbucket.org/mattraykowski/ryzomcore_demoshard
PHP | 633 lines | 395 code | 88 blank | 150 comment | 13 complexity | c9fb19a45bb067857f433fbe1e4f489f MD5 | raw file
Possible License(s): AGPL-3.0, GPL-3.0, LGPL-2.1
  1. <?php
  2. /**
  3. * ControllerTask Test Case
  4. *
  5. * PHP versions 4 and 5
  6. *
  7. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  8. * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
  9. *
  10. * Licensed under The MIT License
  11. * Redistributions of files must retain the above copyright notice.
  12. *
  13. * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. * @link http://cakephp.org CakePHP(tm) Project
  15. * @package cake
  16. * @subpackage cake.tests.cases.console.libs.tasks
  17. * @since CakePHP(tm) v 1.3
  18. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  19. */
  20. App::import('Core', 'ClassRegistry');
  21. App::import('View', 'Helper', false);
  22. App::import('Shell', 'Shell', false);
  23. if (!defined('DISABLE_AUTO_DISPATCH')) {
  24. define('DISABLE_AUTO_DISPATCH', true);
  25. }
  26. if (!class_exists('ShellDispatcher')) {
  27. ob_start();
  28. $argv = false;
  29. require CAKE . 'console' . DS . 'cake.php';
  30. ob_end_clean();
  31. }
  32. require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'project.php';
  33. require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'controller.php';
  34. require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'model.php';
  35. require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'template.php';
  36. require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'test.php';
  37. Mock::generatePartial(
  38. 'ShellDispatcher', 'TestControllerTaskMockShellDispatcher',
  39. array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
  40. );
  41. Mock::generatePartial(
  42. 'ControllerTask', 'MockControllerTask',
  43. array('in', 'hr', 'out', 'err', 'createFile', '_stop', '_checkUnitTest')
  44. );
  45. Mock::generatePartial(
  46. 'ModelTask', 'ControllerMockModelTask',
  47. array('in', 'out', 'err', 'createFile', '_stop', '_checkUnitTest')
  48. );
  49. Mock::generatePartial(
  50. 'ProjectTask', 'ControllerMockProjectTask',
  51. array('in', 'out', 'err', 'createFile', '_stop', '_checkUnitTest', 'getPrefix')
  52. );
  53. Mock::generate('TestTask', 'ControllerMockTestTask');
  54. $imported = App::import('Model', 'Article');
  55. $imported = $imported || App::import('Model', 'Comment');
  56. $imported = $imported || App::import('Model', 'Tag');
  57. if (!$imported) {
  58. define('ARTICLE_MODEL_CREATED', true);
  59. App::import('Core', 'Model');
  60. class Article extends Model {
  61. var $name = 'Article';
  62. var $hasMany = array('Comment');
  63. var $hasAndBelongsToMany = array('Tag');
  64. }
  65. }
  66. /**
  67. * ControllerTaskTest class
  68. *
  69. * @package cake
  70. * @subpackage cake.tests.cases.console.libs.tasks
  71. */
  72. class ControllerTaskTest extends CakeTestCase {
  73. /**
  74. * fixtures
  75. *
  76. * @var array
  77. * @access public
  78. */
  79. var $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag');
  80. /**
  81. * startTest method
  82. *
  83. * @return void
  84. * @access public
  85. */
  86. function startTest() {
  87. $this->Dispatcher =& new TestControllerTaskMockShellDispatcher();
  88. $this->Task =& new MockControllerTask($this->Dispatcher);
  89. $this->Task->name = 'ControllerTask';
  90. $this->Task->Dispatch =& $this->Dispatcher;
  91. $this->Task->Dispatch->shellPaths = App::path('shells');
  92. $this->Task->Template =& new TemplateTask($this->Task->Dispatch);
  93. $this->Task->Template->params['theme'] = 'default';
  94. $this->Task->Model =& new ControllerMockModelTask($this->Task->Dispatch);
  95. $this->Task->Project =& new ControllerMockProjectTask($this->Task->Dispatch);
  96. $this->Task->Test =& new ControllerMockTestTask();
  97. }
  98. /**
  99. * endTest method
  100. *
  101. * @return void
  102. * @access public
  103. */
  104. function endTest() {
  105. unset($this->Task, $this->Dispatcher);
  106. ClassRegistry::flush();
  107. }
  108. /**
  109. * test ListAll
  110. *
  111. * @return void
  112. * @access public
  113. */
  114. function testListAll() {
  115. $this->Task->connection = 'test_suite';
  116. $this->Task->interactive = true;
  117. $this->Task->expectAt(1, 'out', array('1. Articles'));
  118. $this->Task->expectAt(2, 'out', array('2. ArticlesTags'));
  119. $this->Task->expectAt(3, 'out', array('3. Comments'));
  120. $this->Task->expectAt(4, 'out', array('4. Tags'));
  121. $expected = array('Articles', 'ArticlesTags', 'Comments', 'Tags');
  122. $result = $this->Task->listAll('test_suite');
  123. $this->assertEqual($result, $expected);
  124. $this->Task->expectAt(6, 'out', array('1. Articles'));
  125. $this->Task->expectAt(7, 'out', array('2. ArticlesTags'));
  126. $this->Task->expectAt(8, 'out', array('4. Comments'));
  127. $this->Task->expectAt(9, 'out', array('5. Tags'));
  128. $this->Task->interactive = false;
  129. $result = $this->Task->listAll();
  130. $expected = array('articles', 'articles_tags', 'comments', 'tags');
  131. $this->assertEqual($result, $expected);
  132. }
  133. /**
  134. * Test that getName interacts with the user and returns the controller name.
  135. *
  136. * @return void
  137. * @access public
  138. */
  139. function testGetName() {
  140. $this->Task->interactive = true;
  141. $this->Task->setReturnValue('in', 1);
  142. $this->Task->setReturnValueAt(0, 'in', 'q');
  143. $this->Task->expectOnce('_stop');
  144. $this->Task->getName('test_suite');
  145. $this->Task->setReturnValueAt(1, 'in', 1);
  146. $result = $this->Task->getName('test_suite');
  147. $expected = 'Articles';
  148. $this->assertEqual($result, $expected);
  149. $this->Task->setReturnValueAt(2, 'in', 3);
  150. $result = $this->Task->getName('test_suite');
  151. $expected = 'Comments';
  152. $this->assertEqual($result, $expected);
  153. $this->Task->setReturnValueAt(3, 'in', 10);
  154. $result = $this->Task->getName('test_suite');
  155. $this->Task->expectOnce('err');
  156. }
  157. /**
  158. * test helper interactions
  159. *
  160. * @return void
  161. * @access public
  162. */
  163. function testDoHelpers() {
  164. $this->Task->setReturnValue('in', 'n');
  165. $result = $this->Task->doHelpers();
  166. $this->assertEqual($result, array());
  167. $this->Task->setReturnValueAt(1, 'in', 'y');
  168. $this->Task->setReturnValueAt(2, 'in', ' Javascript, Ajax, CustomOne ');
  169. $result = $this->Task->doHelpers();
  170. $expected = array('Javascript', 'Ajax', 'CustomOne');
  171. $this->assertEqual($result, $expected);
  172. $this->Task->setReturnValueAt(3, 'in', 'y');
  173. $this->Task->setReturnValueAt(4, 'in', ' Javascript, Ajax, CustomOne, , ');
  174. $result = $this->Task->doHelpers();
  175. $expected = array('Javascript', 'Ajax', 'CustomOne');
  176. $this->assertEqual($result, $expected);
  177. }
  178. /**
  179. * test component interactions
  180. *
  181. * @return void
  182. * @access public
  183. */
  184. function testDoComponents() {
  185. $this->Task->setReturnValue('in', 'n');
  186. $result = $this->Task->doComponents();
  187. $this->assertEqual($result, array());
  188. $this->Task->setReturnValueAt(1, 'in', 'y');
  189. $this->Task->setReturnValueAt(2, 'in', ' RequestHandler, Security ');
  190. $result = $this->Task->doComponents();
  191. $expected = array('RequestHandler', 'Security');
  192. $this->assertEqual($result, $expected);
  193. $this->Task->setReturnValueAt(3, 'in', 'y');
  194. $this->Task->setReturnValueAt(4, 'in', ' RequestHandler, Security, , ');
  195. $result = $this->Task->doComponents();
  196. $expected = array('RequestHandler', 'Security');
  197. $this->assertEqual($result, $expected);
  198. }
  199. /**
  200. * test Confirming controller user interaction
  201. *
  202. * @return void
  203. * @access public
  204. */
  205. function testConfirmController() {
  206. $controller = 'Posts';
  207. $scaffold = false;
  208. $helpers = array('Ajax', 'Time');
  209. $components = array('Acl', 'Auth');
  210. $uses = array('Comment', 'User');
  211. $this->Task->expectAt(2, 'out', array("Controller Name:\n\t$controller"));
  212. $this->Task->expectAt(3, 'out', array("Helpers:\n\tAjax, Time"));
  213. $this->Task->expectAt(4, 'out', array("Components:\n\tAcl, Auth"));
  214. $this->Task->confirmController($controller, $scaffold, $helpers, $components);
  215. }
  216. /**
  217. * test the bake method
  218. *
  219. * @return void
  220. * @access public
  221. */
  222. function testBake() {
  223. $helpers = array('Ajax', 'Time');
  224. $components = array('Acl', 'Auth');
  225. $this->Task->setReturnValue('createFile', true);
  226. $result = $this->Task->bake('Articles', '--actions--', $helpers, $components);
  227. $this->assertPattern('/class ArticlesController extends AppController/', $result);
  228. $this->assertPattern('/\$components \= array\(\'Acl\', \'Auth\'\)/', $result);
  229. $this->assertPattern('/\$helpers \= array\(\'Ajax\', \'Time\'\)/', $result);
  230. $this->assertPattern('/\-\-actions\-\-/', $result);
  231. $result = $this->Task->bake('Articles', 'scaffold', $helpers, $components);
  232. $this->assertPattern('/class ArticlesController extends AppController/', $result);
  233. $this->assertPattern('/var \$scaffold/', $result);
  234. $this->assertNoPattern('/helpers/', $result);
  235. $this->assertNoPattern('/components/', $result);
  236. $result = $this->Task->bake('Articles', '--actions--', array(), array());
  237. $this->assertPattern('/class ArticlesController extends AppController/', $result);
  238. $this->assertNoPattern('/components/', $result);
  239. $this->assertNoPattern('/helpers/', $result);
  240. $this->assertPattern('/\-\-actions\-\-/', $result);
  241. }
  242. /**
  243. * test bake() with a -plugin param
  244. *
  245. * @return void
  246. * @access public
  247. */
  248. function testBakeWithPlugin() {
  249. $this->Task->plugin = 'ControllerTest';
  250. $helpers = array('Ajax', 'Time');
  251. $components = array('Acl', 'Auth');
  252. $uses = array('Comment', 'User');
  253. $path = APP . 'plugins' . DS . 'controller_test' . DS . 'controllers' . DS . 'articles_controller.php';
  254. $this->Task->expectAt(0, 'createFile', array($path, '*'));
  255. $this->Task->bake('Articles', '--actions--', array(), array(), array());
  256. $this->Task->plugin = 'controllerTest';
  257. $path = APP . 'plugins' . DS . 'controller_test' . DS . 'controllers' . DS . 'articles_controller.php';
  258. $this->Task->expectAt(1, 'createFile', array(
  259. $path, new PatternExpectation('/ArticlesController extends ControllerTestAppController/')));
  260. $this->Task->bake('Articles', '--actions--', array(), array(), array());
  261. $this->assertEqual($this->Task->Template->templateVars['plugin'], 'ControllerTest');
  262. }
  263. /**
  264. * test that bakeActions is creating the correct controller Code. (Using sessions)
  265. *
  266. * @return void
  267. * @access public
  268. */
  269. function testBakeActionsUsingSessions() {
  270. $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
  271. 'Testing bakeActions requires Article, Comment & Tag Model to be undefined. %s');
  272. if ($skip) {
  273. return;
  274. }
  275. $result = $this->Task->bakeActions('Articles', null, true);
  276. $this->assertTrue(strpos($result, 'function index() {') !== false);
  277. $this->assertTrue(strpos($result, '$this->Article->recursive = 0;') !== false);
  278. $this->assertTrue(strpos($result, "\$this->set('articles', \$this->paginate());") !== false);
  279. $this->assertTrue(strpos($result, 'function view($id = null)') !== false);
  280. $this->assertTrue(strpos($result, "\$this->Session->setFlash(__('Invalid article', true));") !== false);
  281. $this->assertTrue(strpos($result, "\$this->set('article', \$this->Article->read(null, \$id)") !== false);
  282. $this->assertTrue(strpos($result, 'function add()') !== false);
  283. $this->assertTrue(strpos($result, 'if (!empty($this->data))') !== false);
  284. $this->assertTrue(strpos($result, 'if ($this->Article->save($this->data))') !== false);
  285. $this->assertTrue(strpos($result, "\$this->Session->setFlash(__('The article has been saved', true));") !== false);
  286. $this->assertTrue(strpos($result, 'function edit($id = null)') !== false);
  287. $this->assertTrue(strpos($result, "\$this->Session->setFlash(__('The article could not be saved. Please, try again.', true));") !== false);
  288. $this->assertTrue(strpos($result, 'function delete($id = null)') !== false);
  289. $this->assertTrue(strpos($result, 'if ($this->Article->delete($id))') !== false);
  290. $this->assertTrue(strpos($result, "\$this->Session->setFlash(__('Article deleted', true));") !== false);
  291. $result = $this->Task->bakeActions('Articles', 'admin_', true);
  292. $this->assertTrue(strpos($result, 'function admin_index() {') !== false);
  293. $this->assertTrue(strpos($result, 'function admin_add()') !== false);
  294. $this->assertTrue(strpos($result, 'function admin_view($id = null)') !== false);
  295. $this->assertTrue(strpos($result, 'function admin_edit($id = null)') !== false);
  296. $this->assertTrue(strpos($result, 'function admin_delete($id = null)') !== false);
  297. }
  298. /**
  299. * Test baking with Controller::flash() or no sessions.
  300. *
  301. * @return void
  302. * @access public
  303. */
  304. function testBakeActionsWithNoSessions() {
  305. $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
  306. 'Testing bakeActions requires Article, Tag, Comment Models to be undefined. %s');
  307. if ($skip) {
  308. return;
  309. }
  310. $result = $this->Task->bakeActions('Articles', null, false);
  311. $this->assertTrue(strpos($result, 'function index() {') !== false);
  312. $this->assertTrue(strpos($result, '$this->Article->recursive = 0;') !== false);
  313. $this->assertTrue(strpos($result, "\$this->set('articles', \$this->paginate());") !== false);
  314. $this->assertTrue(strpos($result, 'function view($id = null)') !== false);
  315. $this->assertTrue(strpos($result, "\$this->flash(__('Invalid article', true), array('action' => 'index'))") !== false);
  316. $this->assertTrue(strpos($result, "\$this->set('article', \$this->Article->read(null, \$id)") !== false);
  317. $this->assertTrue(strpos($result, 'function add()') !== false);
  318. $this->assertTrue(strpos($result, 'if (!empty($this->data))') !== false);
  319. $this->assertTrue(strpos($result, 'if ($this->Article->save($this->data))') !== false);
  320. $this->assertTrue(strpos($result, "\$this->flash(__('The article has been saved.', true), array('action' => 'index'))") !== false);
  321. $this->assertTrue(strpos($result, 'function edit($id = null)') !== false);
  322. $this->assertTrue(strpos($result, "\$this->Article->Tag->find('list')") !== false);
  323. $this->assertTrue(strpos($result, "\$this->set(compact('tags'))") !== false);
  324. $this->assertTrue(strpos($result, 'function delete($id = null)') !== false);
  325. $this->assertTrue(strpos($result, 'if ($this->Article->delete($id))') !== false);
  326. $this->assertTrue(strpos($result, "\$this->flash(__('Article deleted', true), array('action' => 'index'))") !== false);
  327. }
  328. /**
  329. * test baking a test
  330. *
  331. * @return void
  332. * @access public
  333. */
  334. function testBakeTest() {
  335. $this->Task->plugin = 'ControllerTest';
  336. $this->Task->connection = 'test_suite';
  337. $this->Task->interactive = false;
  338. $this->Task->Test->expectOnce('bake', array('Controller', 'Articles'));
  339. $this->Task->bakeTest('Articles');
  340. $this->assertEqual($this->Task->plugin, $this->Task->Test->plugin);
  341. $this->assertEqual($this->Task->connection, $this->Task->Test->connection);
  342. $this->assertEqual($this->Task->interactive, $this->Task->Test->interactive);
  343. }
  344. /**
  345. * test Interactive mode.
  346. *
  347. * @return void
  348. * @access public
  349. */
  350. function testInteractive() {
  351. $this->Task->connection = 'test_suite';
  352. $this->Task->path = '/my/path';
  353. $this->Task->setReturnValue('in', '1');
  354. $this->Task->setReturnValueAt(1, 'in', 'y'); // build interactive
  355. $this->Task->setReturnValueAt(2, 'in', 'n'); // build no scaffolds
  356. $this->Task->setReturnValueAt(3, 'in', 'y'); // build normal methods
  357. $this->Task->setReturnValueAt(4, 'in', 'n'); // build admin methods
  358. $this->Task->setReturnValueAt(5, 'in', 'n'); // helpers?
  359. $this->Task->setReturnValueAt(6, 'in', 'n'); // components?
  360. $this->Task->setReturnValueAt(7, 'in', 'y'); // use sessions
  361. $this->Task->setReturnValueAt(8, 'in', 'y'); // looks good
  362. $this->Task->execute();
  363. $filename = '/my/path/articles_controller.php';
  364. $this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticlesController/')));
  365. }
  366. /**
  367. * test Interactive mode.
  368. *
  369. * @return void
  370. * @access public
  371. */
  372. function testInteractiveAdminMethodsNotInteractive() {
  373. $this->Task->connection = 'test_suite';
  374. $this->Task->interactive = true;
  375. $this->Task->path = '/my/path';
  376. $this->Task->setReturnValue('in', '1');
  377. $this->Task->setReturnValueAt(1, 'in', 'y'); // build interactive
  378. $this->Task->setReturnValueAt(2, 'in', 'n'); // build no scaffolds
  379. $this->Task->setReturnValueAt(3, 'in', 'y'); // build normal methods
  380. $this->Task->setReturnValueAt(4, 'in', 'y'); // build admin methods
  381. $this->Task->setReturnValueAt(5, 'in', 'n'); // helpers?
  382. $this->Task->setReturnValueAt(6, 'in', 'n'); // components?
  383. $this->Task->setReturnValueAt(7, 'in', 'y'); // use sessions
  384. $this->Task->setReturnValueAt(8, 'in', 'y'); // looks good
  385. $this->Task->setReturnValue('createFile', true);
  386. $this->Task->Project->setReturnValue('getPrefix', 'admin_');
  387. $result = $this->Task->execute();
  388. $this->assertPattern('/admin_index/', $result);
  389. $filename = '/my/path/articles_controller.php';
  390. $this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticlesController/')));
  391. }
  392. /**
  393. * test that execute runs all when the first arg == all
  394. *
  395. * @return void
  396. * @access public
  397. */
  398. function testExecuteIntoAll() {
  399. $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
  400. 'Execute into all could not be run as an Article, Tag or Comment model was already loaded. %s');
  401. if ($skip) {
  402. return;
  403. }
  404. $this->Task->connection = 'test_suite';
  405. $this->Task->path = '/my/path/';
  406. $this->Task->args = array('all');
  407. $this->Task->setReturnValue('createFile', true);
  408. $this->Task->setReturnValue('_checkUnitTest', true);
  409. $this->Task->Test->expectCallCount('bake', 1);
  410. $filename = '/my/path/articles_controller.php';
  411. $this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticlesController/')));
  412. $this->Task->execute();
  413. }
  414. /**
  415. * test that `cake bake controller foos` works.
  416. *
  417. * @return void
  418. * @access public
  419. */
  420. function testExecuteWithController() {
  421. $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
  422. 'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s');
  423. if ($skip) {
  424. return;
  425. }
  426. $this->Task->connection = 'test_suite';
  427. $this->Task->path = '/my/path/';
  428. $this->Task->args = array('Articles');
  429. $filename = '/my/path/articles_controller.php';
  430. $this->Task->expectAt(0, 'createFile', array(
  431. $filename, new PatternExpectation('/\$scaffold/')
  432. ));
  433. $this->Task->execute();
  434. }
  435. /**
  436. * test that both plural and singular forms work for controller baking.
  437. *
  438. * @return void
  439. * @access public
  440. */
  441. function testExecuteWithControllerNameVariations() {
  442. $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
  443. 'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s');
  444. if ($skip) {
  445. return;
  446. }
  447. $this->Task->connection = 'test_suite';
  448. $this->Task->path = '/my/path/';
  449. $this->Task->args = array('Articles');
  450. $filename = '/my/path/articles_controller.php';
  451. $this->Task->expectAt(0, 'createFile', array(
  452. $filename, new PatternExpectation('/\$scaffold/')
  453. ));
  454. $this->Task->execute();
  455. $this->Task->args = array('Article');
  456. $filename = '/my/path/articles_controller.php';
  457. $this->Task->expectAt(1, 'createFile', array(
  458. $filename, new PatternExpectation('/class ArticlesController/')
  459. ));
  460. $this->Task->execute();
  461. $this->Task->args = array('article');
  462. $filename = '/my/path/articles_controller.php';
  463. $this->Task->expectAt(2, 'createFile', array(
  464. $filename, new PatternExpectation('/class ArticlesController/')
  465. ));
  466. $this->Task->args = array('articles');
  467. $filename = '/my/path/articles_controller.php';
  468. $this->Task->expectAt(3, 'createFile', array(
  469. $filename, new PatternExpectation('/class ArticlesController/')
  470. ));
  471. $this->Task->execute();
  472. $this->Task->args = array('Articles');
  473. $filename = '/my/path/articles_controller.php';
  474. $this->Task->expectAt(4, 'createFile', array(
  475. $filename, new PatternExpectation('/class ArticlesController/')
  476. ));
  477. $this->Task->execute();
  478. $this->Task->execute();
  479. }
  480. /**
  481. * test that `cake bake controller foo scaffold` works.
  482. *
  483. * @return void
  484. * @access public
  485. */
  486. function testExecuteWithPublicParam() {
  487. $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
  488. 'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s');
  489. if ($skip) {
  490. return;
  491. }
  492. $this->Task->connection = 'test_suite';
  493. $this->Task->path = '/my/path/';
  494. $this->Task->args = array('Articles', 'public');
  495. $filename = '/my/path/articles_controller.php';
  496. $this->Task->expectAt(0, 'createFile', array(
  497. $filename, new NoPatternExpectation('/var \$scaffold/')
  498. ));
  499. $this->Task->execute();
  500. }
  501. /**
  502. * test that `cake bake controller foos both` works.
  503. *
  504. * @return void
  505. * @access public
  506. */
  507. function testExecuteWithControllerAndBoth() {
  508. $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
  509. 'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s');
  510. if ($skip) {
  511. return;
  512. }
  513. $this->Task->Project->setReturnValue('getPrefix', 'admin_');
  514. $this->Task->connection = 'test_suite';
  515. $this->Task->path = '/my/path/';
  516. $this->Task->args = array('Articles', 'public', 'admin');
  517. $filename = '/my/path/articles_controller.php';
  518. $this->Task->expectAt(0, 'createFile', array(
  519. $filename, new PatternExpectation('/admin_index/')
  520. ));
  521. $this->Task->execute();
  522. }
  523. /**
  524. * test that `cake bake controller foos admin` works.
  525. *
  526. * @return void
  527. * @access public
  528. */
  529. function testExecuteWithControllerAndAdmin() {
  530. $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
  531. 'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s');
  532. if ($skip) {
  533. return;
  534. }
  535. $this->Task->Project->setReturnValue('getPrefix', 'admin_');
  536. $this->Task->connection = 'test_suite';
  537. $this->Task->path = '/my/path/';
  538. $this->Task->args = array('Articles', 'admin');
  539. $filename = '/my/path/articles_controller.php';
  540. $this->Task->expectAt(0, 'createFile', array(
  541. $filename, new PatternExpectation('/admin_index/')
  542. ));
  543. $this->Task->execute();
  544. }
  545. }