@@ -126,12 +126,49 @@ function testView() {
126
126
}
127
127
128
128
/**
129
- * undocumented function
129
+ * test dumping a schema file.
130
130
*
131
131
* @return void
132
132
**/
133
- function () {
134
-
133
+ function testDump () {
134
+ $ this ->Task ->params = array ('name ' => 'i18n ' );
135
+ $ this ->Task ->startup ();
136
+ $ this ->Task ->Schema ->path = APP . 'config ' . DS . 'schema ' ;
137
+ $ this ->Task ->expectAt (0 , 'out ' , array (new PatternExpectation ('/create table `i18n`/i ' )));
138
+ $ this ->Task ->dump ();
139
+ }
140
+
141
+ /**
142
+ * test dump() with sql file generation
143
+ *
144
+ * @return void
145
+ **/
146
+ function testDumpWithFileWriting () {
147
+ //copy file.
148
+ $ file =& new File (APP . 'config ' . DS . 'schema ' . DS . 'i18n.php ' );
149
+ $ contents = $ file ->read ();
150
+ $ file =& new File (TMP . 'tests ' . DS . 'i18n.php ' );
151
+ $ file ->write ($ contents );
152
+
153
+ $ this ->Task ->params = array ('name ' => 'i18n ' );
154
+ $ this ->Task ->args = array ('write ' );
155
+ $ this ->Task ->startup ();
156
+ $ this ->Task ->Schema ->path = TMP . 'tests ' ;
157
+ $ this ->Task ->dump ();
158
+
159
+ $ sql =& new File (TMP . 'tests ' . DS . 'i18n.sql ' );
160
+ $ contents = $ sql ->read ();
161
+ $ this ->assertPattern ('/DROP TABLE/ ' , $ contents );
162
+ $ this ->assertPattern ('/CREATE TABLE `i18n`/ ' , $ contents );
163
+ $ this ->assertPattern ('/id/ ' , $ contents );
164
+ $ this ->assertPattern ('/model/ ' , $ contents );
165
+ $ this ->assertPattern ('/field/ ' , $ contents );
166
+ $ this ->assertPattern ('/locale/ ' , $ contents );
167
+ $ this ->assertPattern ('/foreign_key/ ' , $ contents );
168
+ $ this ->assertPattern ('/content/ ' , $ contents );
169
+
170
+ $ sql ->delete ();
171
+ $ file ->delete ();
135
172
}
136
173
}
137
174
?>
0 commit comments