comparison cake/tests/cases/console/libs/tasks/controller.test.php @ 0:261e66bd5a0c

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