mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Fixing problems when running the AllTests testsuite
This commit is contained in:
parent
33c74b6062
commit
e758b272bd
4 changed files with 31 additions and 27 deletions
|
@ -2584,6 +2584,10 @@ class Model extends Object {
|
||||||
}
|
}
|
||||||
$validator = array_merge($default, $validator);
|
$validator = array_merge($default, $validator);
|
||||||
|
|
||||||
|
$validationDomain = $this->validationDomain;
|
||||||
|
if (empty($validationDomain)) {
|
||||||
|
$validationDomain = 'default';
|
||||||
|
}
|
||||||
if (isset($validator['message'])) {
|
if (isset($validator['message'])) {
|
||||||
$message = $validator['message'];
|
$message = $validator['message'];
|
||||||
} else {
|
} else {
|
||||||
|
@ -2603,7 +2607,7 @@ class Model extends Object {
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($required) {
|
if ($required) {
|
||||||
$this->invalidate($fieldName, $message);
|
$this->invalidate($fieldName, __d($validationDomain, $message));
|
||||||
if ($validator['last']) {
|
if ($validator['last']) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2647,7 +2651,7 @@ class Model extends Object {
|
||||||
} elseif (is_numeric($index) && count($ruleSet) > 1) {
|
} elseif (is_numeric($index) && count($ruleSet) > 1) {
|
||||||
$validator['message'] = $index + 1;
|
$validator['message'] = $index + 1;
|
||||||
} else {
|
} else {
|
||||||
$validator['message'] = $message;
|
$validator['message'] = __d($validationDomain, $message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->invalidate($fieldName, $validator['message']);
|
$this->invalidate($fieldName, $validator['message']);
|
||||||
|
|
|
@ -239,7 +239,7 @@ class ExtractTaskTest extends CakeTestCase {
|
||||||
App::build(array(
|
App::build(array(
|
||||||
'Model' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS),
|
'Model' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS),
|
||||||
'plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
|
'plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
|
||||||
));
|
), App::RESET);
|
||||||
$this->out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
$this->out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||||
$this->in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
$this->in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||||
$this->Task = $this->getMock('ExtractTask',
|
$this->Task = $this->getMock('ExtractTask',
|
||||||
|
@ -256,10 +256,10 @@ class ExtractTaskTest extends CakeTestCase {
|
||||||
$this->Task->execute();
|
$this->Task->execute();
|
||||||
$result = file_get_contents($this->path . DS . 'default.pot');
|
$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);
|
$this->assertPattern($pattern, $result);
|
||||||
|
|
||||||
$pattern = '#Model/Post.php:validation for field body#';
|
$pattern = '#Model/PersisterOne.php:validation for field body#';
|
||||||
$this->assertPattern($pattern, $result);
|
$this->assertPattern($pattern, $result);
|
||||||
|
|
||||||
$pattern = '#msgid "Post title is required"#';
|
$pattern = '#msgid "Post title is required"#';
|
||||||
|
|
|
@ -25,4 +25,26 @@ class PersisterOne extends AppModel {
|
||||||
public $actsAs = array('PersisterOneBehavior', 'TestPlugin.TestPluginPersisterOne');
|
public $actsAs = array('PersisterOneBehavior', 'TestPlugin.TestPluginPersisterOne');
|
||||||
|
|
||||||
public $hasMany = array('Comment', 'TestPlugin.TestPluginComment');
|
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'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,26 +21,4 @@
|
||||||
class Post extends AppModel {
|
class Post extends AppModel {
|
||||||
public $useTable = 'posts';
|
public $useTable = 'posts';
|
||||||
public $name = 'Post';
|
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'
|
|
||||||
)
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue