1
+ <?php
2
+ /* SVN FILE: $Id$ */
3
+ /**
4
+ * Test Case for test generation shell task
5
+ *
6
+ *
7
+ *
8
+ * PHP versions 4 and 5
9
+ *
10
+ * CakePHP : Rapid Development Framework (http://www.cakephp.org)
11
+ * Copyright 2006-2008, Cake Software Foundation, Inc.
12
+ *
13
+ * Licensed under The MIT License
14
+ * Redistributions of files must retain the above copyright notice.
15
+ *
16
+ * @filesource
17
+ * @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
18
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
19
+ * @package cake
20
+ * @subpackage cake.cake.libs.
21
+ * @since CakePHP v 1.2.0.7726
22
+ * @version $Revision$
23
+ * @modifiedby $LastChangedBy$
24
+ * @lastmodified $Date$
25
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
26
+ */
27
+ App::import ('Core ' , 'Shell ' );
28
+
29
+ if (!defined ('DISABLE_AUTO_DISPATCH ' )) {
30
+ define ('DISABLE_AUTO_DISPATCH ' , true );
31
+ }
32
+
33
+ if (!class_exists ('ShellDispatcher ' )) {
34
+ ob_start ();
35
+ $ argv = false ;
36
+ require CAKE . 'console ' . DS . 'cake.php ' ;
37
+ ob_end_clean ();
38
+ }
39
+
40
+ if (!class_exists ('TestTask ' )) {
41
+ require CAKE . 'console ' . DS . 'libs ' . DS . 'tasks ' . DS . 'test.php ' ;
42
+ }
43
+
44
+ class TestTestShellDispatcher extends ShellDispatcher {
45
+
46
+ function _initEnvironment () {
47
+ }
48
+
49
+ function stdout ($ string , $ newline = true ) {
50
+ }
51
+
52
+ function stderr ($ string ) {
53
+ }
54
+
55
+ function getInput ($ prompt , $ options , $ default ) {
56
+ }
57
+
58
+ function _stop ($ status = 0 ) {
59
+ $ this ->stopped = 'Stopped with status: ' . $ status ;
60
+ }
61
+ }
62
+
63
+ Mock::generatePartial ('TestTask ' , 'MockTestTask ' , array ('createFile ' , 'out ' , 'in ' ));
64
+
65
+ class TestTaskTest extends CakeTestCase {
66
+
67
+ function setUp () {
68
+ $ this ->dispatcher = new TestTestShellDispatcher ();
69
+ $ this ->task = new MockTestTask ($ this ->dispatcher );
70
+ }
71
+ /**
72
+ * Test that file path generation doesn't continuously append paths.
73
+ *
74
+ * @access public
75
+ * @return void
76
+ */
77
+ function testFilePathGeneration () {
78
+ $ this ->task ->setReturnValue ('in ' , 'y ' );
79
+ $ this ->task ->expectAt (0 , 'createFile ' , array (TESTS . 'cases ' . DS . 'models ' . DS . 'my_class.test.php ' , '* ' ));
80
+ $ this ->task ->bake ('Model ' , 'MyClass ' );
81
+
82
+ $ this ->task ->expectAt (1 , 'createFile ' , array (TESTS . 'cases ' . DS . 'models ' . DS . 'my_class.test.php ' , '* ' ));
83
+ $ this ->task ->bake ('Model ' , 'MyClass ' );
84
+ }
85
+
86
+ function tearDown () {
87
+ unset($ this ->task , $ this ->dispatcher );
88
+ }
89
+ }
90
+
91
+ ?>
0 commit comments