Skip to content

Commit

Permalink
Fixing problems when running the AllTests testsuite
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jun 20, 2011
1 parent 33c74b6 commit e758b27
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 27 deletions.
8 changes: 6 additions & 2 deletions lib/Cake/Model/Model.php
Expand Up @@ -2584,6 +2584,10 @@ function invalidFields($options = array()) {
}
$validator = array_merge($default, $validator);

$validationDomain = $this->validationDomain;
if (empty($validationDomain)) {
$validationDomain = 'default';
}
if (isset($validator['message'])) {
$message = $validator['message'];
} else {
Expand All @@ -2603,7 +2607,7 @@ function invalidFields($options = array()) {
);

if ($required) {
$this->invalidate($fieldName, $message);
$this->invalidate($fieldName, __d($validationDomain, $message));
if ($validator['last']) {
break;
}
Expand Down Expand Up @@ -2647,7 +2651,7 @@ function invalidFields($options = array()) {
} elseif (is_numeric($index) && count($ruleSet) > 1) {
$validator['message'] = $index + 1;
} else {
$validator['message'] = $message;
$validator['message'] = __d($validationDomain, $message);
}
}
$this->invalidate($fieldName, $validator['message']);
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php
Expand Up @@ -239,7 +239,7 @@ public function testExtractModelValidation() {
App::build(array(
'Model' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS),
'plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
));
), App::RESET);
$this->out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$this->in = $this->getMock('ConsoleInput', array(), array(), '', false);
$this->Task = $this->getMock('ExtractTask',
Expand All @@ -256,10 +256,10 @@ public function testExtractModelValidation() {
$this->Task->execute();
$result = file_get_contents($this->path . DS . 'default.pot');

$pattern = '#Model/Post.php:validation for field title#';
$pattern = '#Model/PersisterOne.php:validation for field title#';
$this->assertPattern($pattern, $result);

$pattern = '#Model/Post.php:validation for field body#';
$pattern = '#Model/PersisterOne.php:validation for field body#';
$this->assertPattern($pattern, $result);

$pattern = '#msgid "Post title is required"#';
Expand Down
22 changes: 22 additions & 0 deletions lib/Cake/Test/test_app/Model/PersisterOne.php
Expand Up @@ -25,4 +25,26 @@ class PersisterOne extends AppModel {
public $actsAs = array('PersisterOneBehavior', 'TestPlugin.TestPluginPersisterOne');

public $hasMany = array('Comment', 'TestPlugin.TestPluginComment');
public $validate = array(
'title' => array(
'rule' => array('custom', '.*'),
'allowEmpty' => true,
'required' => false,
'message' => 'Post title is required'
),
'body' => array(
'first_rule' => array(
'rule' => array('custom', '.*'),
'allowEmpty' => true,
'required' => false,
'message' => 'Post body is required'
),
'second_rule' => array(
'rule' => array('custom', '.*'),
'allowEmpty' => true,
'required' => false,
'message' => 'Post body is super required'
)
),
);
}
22 changes: 0 additions & 22 deletions lib/Cake/Test/test_app/Model/Post.php
Expand Up @@ -21,26 +21,4 @@
class Post extends AppModel {
public $useTable = 'posts';
public $name = 'Post';
public $validate = array(
'title' => array(
'rule' => array('custom', '.*'),
'allowEmpty' => true,
'required' => false,
'message' => 'Post title is required'
),
'body' => array(
'first_rule' => array(
'rule' => array('custom', '.*'),
'allowEmpty' => true,
'required' => false,
'message' => 'Post body is required'
),
'second_rule' => array(
'rule' => array('custom', '.*'),
'allowEmpty' => true,
'required' => false,
'message' => 'Post body is super required'
)
),
);
}

0 comments on commit e758b27

Please sign in to comment.