@@ -61,6 +61,7 @@ public function tearDown() {
61
61
$ Folder = new Folder ($ this ->path );
62
62
$ Folder ->delete ();
63
63
App::build ();
64
+ CakePlugin::unload ();
64
65
}
65
66
66
67
/**
@@ -255,7 +256,6 @@ public function testExtractPlugin() {
255
256
$ this ->assertNoPattern ('#Pages# ' , $ result );
256
257
$ this ->assertContains ('translate.ctp:1 ' , $ result );
257
258
$ this ->assertContains ('This is a translatable string ' , $ result );
258
- CakePlugin::unload ();
259
259
}
260
260
261
261
/**
@@ -342,4 +342,46 @@ public function testExtractModelValidationWithDomainInModel() {
342
342
$ this ->assertPattern ($ pattern , $ result );
343
343
}
344
344
345
+
346
+ /**
347
+ * Test that the extract shell can obtain validation messages from models inside a specific plugin
348
+ *
349
+ * @return void
350
+ */
351
+ public function testExtractModelValidationInPlugin () {
352
+ App::build (array (
353
+ 'plugins ' => array (CAKE . 'Test ' . DS . 'test_app ' . DS . 'Plugin ' . DS )
354
+ ));
355
+ $ this ->out = $ this ->getMock ('ConsoleOutput ' , array (), array (), '' , false );
356
+ $ this ->in = $ this ->getMock ('ConsoleInput ' , array (), array (), '' , false );
357
+ $ this ->Task = $ this ->getMock ('ExtractTask ' ,
358
+ array ('_isExtractingApp ' , 'in ' , 'out ' , 'err ' , 'clear ' , '_stop ' ),
359
+ array ($ this ->out , $ this ->out , $ this ->in )
360
+ );
361
+
362
+ $ this ->Task ->params ['output ' ] = $ this ->path . DS ;
363
+ $ this ->Task ->params ['ignore-model-validation ' ] = false ;
364
+ $ this ->Task ->params ['plugin ' ] = 'TestPlugin ' ;
365
+
366
+ $ this ->Task ->execute ();
367
+ $ result = file_get_contents ($ this ->path . DS . 'test_plugin.pot ' );
368
+
369
+ $ pattern = '#Model/TestPluginPost.php:validation for field title# ' ;
370
+ $ this ->assertPattern ($ pattern , $ result );
371
+
372
+ $ pattern = '#Model/TestPluginPost.php:validation for field body# ' ;
373
+ $ this ->assertPattern ($ pattern , $ result );
374
+
375
+ $ pattern = '#msgid "Post title is required"# ' ;
376
+ $ this ->assertPattern ($ pattern , $ result );
377
+
378
+ $ pattern = '#msgid "Post body is required"# ' ;
379
+ $ this ->assertPattern ($ pattern , $ result );
380
+
381
+ $ pattern = '#msgid "Post body is super required"# ' ;
382
+ $ this ->assertPattern ($ pattern , $ result );
383
+
384
+ $ pattern = '#Plugin/TestPlugin/Model/TestPluginPost.php:validation for field title# ' ;
385
+ $ this ->assertNoPattern ($ pattern , $ result );
386
+ }
345
387
}
0 commit comments