diff --git a/config/bootstrap.php b/config/bootstrap.php index 42f59b9..8fdcc2b 100644 --- a/config/bootstrap.php +++ b/config/bootstrap.php @@ -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 = ''; diff --git a/src/View/Helper/RecaptchaHelper.php b/src/View/Helper/RecaptchaHelper.php index 7886f22..202c59d 100644 --- a/src/View/Helper/RecaptchaHelper.php +++ b/src/View/Helper/RecaptchaHelper.php @@ -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 @@ -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 @@ -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 diff --git a/tests/TestCase/Validation/ConfigValidatorTest.php b/tests/TestCase/Validation/ConfigValidatorTest.php index 31faea1..fa64eab 100644 --- a/tests/TestCase/Validation/ConfigValidatorTest.php +++ b/tests/TestCase/Validation/ConfigValidatorTest.php @@ -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); } @@ -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); } @@ -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); } diff --git a/tests/TestCase/Validation/GlobalValidatorTest.php b/tests/TestCase/Validation/GlobalValidatorTest.php index 031f100..f04c005 100644 --- a/tests/TestCase/Validation/GlobalValidatorTest.php +++ b/tests/TestCase/Validation/GlobalValidatorTest.php @@ -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); } @@ -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); } @@ -87,7 +87,7 @@ public function testGlobalValidationWithBlockOfExistingParams() 'type' => 'audio', 'size' => 'compact' ]; - $errors = $validator->errors($data); + $errors = $validator->validate($data); $this->assertEmpty($errors); } @@ -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); diff --git a/tests/TestCase/Validation/RecaptchaValidatorTest.php b/tests/TestCase/Validation/RecaptchaValidatorTest.php index 87b7b18..8eef070 100644 --- a/tests/TestCase/Validation/RecaptchaValidatorTest.php +++ b/tests/TestCase/Validation/RecaptchaValidatorTest.php @@ -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); } @@ -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); } @@ -87,7 +87,7 @@ public function testRecaptchaValidationWithBlockOfExistingParams() 'type' => 'audio', 'size' => 'compact' ]; - $errors = $validator->errors($data); + $errors = $validator->validate($data); $this->assertEmpty($errors); } @@ -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);