Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validator::errors() is deprecated. Use Validator::validate() instead. #18

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// Validate the Configure Data
$validator = new ConfigValidator();

$errors = $validator->errors(Configure::read('Recaptcha'));
$errors = $validator->validate(Configure::read('Recaptcha'));

if (!empty($errors)) {
$errMsg = '';
Expand Down
6 changes: 3 additions & 3 deletions src/View/Helper/RecaptchaHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function __construct(View $view, $config = [])
}
// Validate the Configure Data
$validator = new RecaptchaValidator();
$errors = $validator->errors($this->getConfig());
$errors = $validator->validate($this->getConfig());
if (!empty($errors)) {
throw new \Exception(__d('recaptcha', 'One of your recaptcha config value is incorrect'));
// throw an exception with config error that is raised
Expand Down Expand Up @@ -95,7 +95,7 @@ public function display(array $options = [])

// Validate the Configure Data
$validator = new RecaptchaValidator();
$errors = $validator->errors($options);
$errors = $validator->validate($options);
if (!empty($errors)) {
throw new \Exception(__d('recaptcha', 'One of your recaptcha config value is incorrect'));
// throw an exception with config error that is raised
Expand Down Expand Up @@ -137,7 +137,7 @@ public function widget(array $options = [])

// Validate the Configure Data
$validator = new RecaptchaValidator();
$errors = $validator->errors($options);
$errors = $validator->validate($options);
if (!empty($errors)) {
throw new \Exception(__d('recaptcha', 'One of your recaptcha config value is incorrect in a widget'));
// throw an exception with config error that is raised
Expand Down
24 changes: 12 additions & 12 deletions tests/TestCase/Validation/ConfigValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ public function testConfigValidationWithMissingSecretParam()
{
$validator = new ConfigValidator();
$data = ['lang' => 'fr'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertArrayHasKey('secret', $errors);

$validator = new ConfigValidator();
$data = ['theme' => 'light'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertArrayHasKey('secret', $errors);

$validator = new ConfigValidator();
$data = ['type' => 'image'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertArrayHasKey('secret', $errors);

$validator = new ConfigValidator();
$data = ['size' => 'normal'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertArrayHasKey('secret', $errors);
}

Expand All @@ -54,22 +54,22 @@ public function testConfigValidationWithExistingParams()
{
$validator = new ConfigValidator();
$data = ['secret' => 'fff', 'lang' => 'fr'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertEmpty($errors);

$validator = new ConfigValidator();
$data = ['secret' => 'fff', 'theme' => 'light'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertEmpty($errors);

$validator = new ConfigValidator();
$data = ['secret' => 'fff', 'type' => 'image'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertEmpty($errors);

$validator = new ConfigValidator();
$data = ['secret' => 'fff', 'size' => 'normal'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertEmpty($errors);
}

Expand All @@ -82,22 +82,22 @@ public function testConfigValidationWithNonExistingParams()
{
$validator = new ConfigValidator();
$data = ['secret' => 'fff', 'lang' => 'non-existing-lang'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertArrayHasKey('lang', $errors);

$validator = new ConfigValidator();
$data = ['secret' => 'fff', 'theme' => 'non-existing-theme'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertArrayHasKey('theme', $errors);

$validator = new ConfigValidator();
$data = ['secret' => 'fff', 'type' => 'non-existing-type'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertArrayHasKey('type', $errors);

$validator = new ConfigValidator();
$data = ['secret' => 'fff', 'size' => 'non-existing-size'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertArrayHasKey('size', $errors);
}

Expand Down
20 changes: 10 additions & 10 deletions tests/TestCase/Validation/GlobalValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ public function testGlobalValidationWithExistingParams()
{
$validator = new GlobalValidator();
$data = ['lang' => 'fr'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertEmpty($errors);

$validator = new GlobalValidator();
$data = ['theme' => 'light'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertEmpty($errors);

$validator = new GlobalValidator();
$data = ['type' => 'image'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertEmpty($errors);

$validator = new GlobalValidator();
$data = ['size' => 'normal'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertEmpty($errors);
}

Expand All @@ -54,22 +54,22 @@ public function testGlobalValidationWithNonExistingParams()
{
$validator = new GlobalValidator();
$data = ['lang' => 'non-existing-lang'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertArrayHasKey('lang', $errors);

$validator = new GlobalValidator();
$data = ['theme' => 'non-existing-theme'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertArrayHasKey('theme', $errors);

$validator = new GlobalValidator();
$data = ['type' => 'non-existing-type'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertArrayHasKey('type', $errors);

$validator = new GlobalValidator();
$data = ['size' => 'non-existing-size'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertArrayHasKey('size', $errors);
}

Expand All @@ -87,7 +87,7 @@ public function testGlobalValidationWithBlockOfExistingParams()
'type' => 'audio',
'size' => 'compact'
];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertEmpty($errors);
}

Expand All @@ -105,7 +105,7 @@ public function testGlobalValidationWithBlockOfNonExistingParams()
'type' => 'non-existing-type',
'size' => 'non-existing-size'
];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertArrayHasKey('lang', $errors);
$this->assertArrayHasKey('theme', $errors);
$this->assertArrayHasKey('type', $errors);
Expand Down
20 changes: 10 additions & 10 deletions tests/TestCase/Validation/RecaptchaValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ public function testRecaptchaValidationWithExistingParams()
{
$validator = new RecaptchaValidator();
$data = ['lang' => 'fr'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertEmpty($errors);

$validator = new RecaptchaValidator();
$data = ['theme' => 'light'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertEmpty($errors);

$validator = new RecaptchaValidator();
$data = ['type' => 'image'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertEmpty($errors);

$validator = new RecaptchaValidator();
$data = ['size' => 'normal'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertEmpty($errors);
}

Expand All @@ -54,22 +54,22 @@ public function testRecaptchaValidationWithNonExistingParams()
{
$validator = new RecaptchaValidator();
$data = ['lang' => 'non-existing-lang'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertArrayHasKey('lang', $errors);

$validator = new RecaptchaValidator();
$data = ['theme' => 'non-existing-theme'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertArrayHasKey('theme', $errors);

$validator = new RecaptchaValidator();
$data = ['type' => 'non-existing-type'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertArrayHasKey('type', $errors);

$validator = new RecaptchaValidator();
$data = ['size' => 'non-existing-size'];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertArrayHasKey('size', $errors);
}

Expand All @@ -87,7 +87,7 @@ public function testRecaptchaValidationWithBlockOfExistingParams()
'type' => 'audio',
'size' => 'compact'
];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertEmpty($errors);
}

Expand All @@ -105,7 +105,7 @@ public function testRecaptchaValidationWithBlockOfNonExistingParams()
'type' => 'non-existing-type',
'size' => 'non-existing-size'
];
$errors = $validator->errors($data);
$errors = $validator->validate($data);
$this->assertArrayHasKey('lang', $errors);
$this->assertArrayHasKey('theme', $errors);
$this->assertArrayHasKey('type', $errors);
Expand Down