|
|
@@ -209,19 +209,16 @@ class ExtractTaskTest extends CakeTestCase {
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testExtractExcludePlugins() {
|
|
|
- $this->Task->params['paths'] = array(
|
|
|
- CAKE . 'Test' . DS . 'test_app'
|
|
|
- );
|
|
|
App::build(array(
|
|
|
'plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
|
|
|
));
|
|
|
$this->out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
|
|
$this->in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
|
|
$this->Task = $this->getMock('ExtractTask',
|
|
|
- array('_isExtractingApp', 'in', 'out', 'err', 'clear', '_stop'),
|
|
|
+ array('_isExtractingApp', '_extractValidationMessages', 'in', 'out', 'err', 'clear', '_stop'),
|
|
|
array($this->out, $this->out, $this->in)
|
|
|
);
|
|
|
- $this->Task->expects($this->once())->method('_isExtractingApp')->will($this->returnValue(true));
|
|
|
+ $this->Task->expects($this->exactly(2))->method('_isExtractingApp')->will($this->returnValue(true));
|
|
|
|
|
|
$this->Task->params['paths'] = CAKE . 'Test' . DS . 'test_app' . DS;
|
|
|
$this->Task->params['output'] = $this->path . DS;
|
|
|
@@ -231,4 +228,45 @@ class ExtractTaskTest extends CakeTestCase {
|
|
|
$result = file_get_contents($this->path . DS . 'default.pot');
|
|
|
$this->assertNoPattern('#TesPlugin#', $result);
|
|
|
}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Tests that the task will inspect application models and extract the validation messages from them
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testExtractModelValidation() {
|
|
|
+ App::build(array(
|
|
|
+ 'Model' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS)
|
|
|
+ ));
|
|
|
+ $this->out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
|
|
+ $this->in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
|
|
+ $this->Task = $this->getMock('ExtractTask',
|
|
|
+ array('_isExtractingApp', 'in', 'out', 'err', 'clear', '_stop'),
|
|
|
+ array($this->out, $this->out, $this->in)
|
|
|
+ );
|
|
|
+ $this->Task->expects($this->exactly(2))->method('_isExtractingApp')->will($this->returnValue(true));
|
|
|
+
|
|
|
+ $this->Task->params['paths'] = CAKE . 'Test' . DS . 'test_app' . DS;
|
|
|
+ $this->Task->params['output'] = $this->path . DS;
|
|
|
+ $this->Task->params['exclude-plugins'] = true;
|
|
|
+ $this->Task->params['ignore-model-validation'] = false;
|
|
|
+
|
|
|
+ $this->Task->execute();
|
|
|
+ $result = file_get_contents($this->path . DS . 'default.pot');
|
|
|
+
|
|
|
+ $pattern = '#Model/Post.php:validation for field title#';
|
|
|
+ $this->assertPattern($pattern, $result);
|
|
|
+
|
|
|
+ $pattern = '#Model/Post.php:validation for field body#';
|
|
|
+ $this->assertPattern($pattern, $result);
|
|
|
+
|
|
|
+ $pattern = '#msgid "Post title is required"#';
|
|
|
+ $this->assertPattern($pattern, $result);
|
|
|
+
|
|
|
+ $pattern = '#msgid "Post body is required"#';
|
|
|
+ $this->assertPattern($pattern, $result);
|
|
|
+
|
|
|
+ $pattern = '#msgid "Post body is super required"#';
|
|
|
+ $this->assertPattern($pattern, $result);
|
|
|
+ }
|
|
|
}
|