/**
  * Test Recaptcha Validation with block of non existing params
  *
  * @return void
  */
 public function testRecaptchaValidationWithBlockOfNonExistingParams()
 {
     $validator = new RecaptchaValidator();
     $data = ['lang' => 'non-existing-lang', 'theme' => 'non-existing-theme', 'type' => 'non-existing-type', 'size' => 'non-existing-size'];
     $errors = $validator->errors($data);
     $this->assertArrayHasKey('lang', $errors);
     $this->assertArrayHasKey('theme', $errors);
     $this->assertArrayHasKey('type', $errors);
     $this->assertArrayHasKey('size', $errors);
 }
Esempio n. 2
0
 /**
  * Create a recaptcha widget (for multiple widgets)
  *
  * @param array $options Options
  * - id : Id
  * - sitekey : Site Key
  * - theme : Theme
  * - type : Type
  * - lang : Langue
  *
  * @return void
  */
 public function widget(array $options = [])
 {
     $options = array_merge($this->config(), $options);
     // Validate the Configure Data
     $validator = new RecaptchaValidator();
     $errors = $validator->errors($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
     }
     // add infos in widgets for script()
     $this->widgets[] = ['id' => $options['id'], 'sitekey' => $options['sitekey'], 'theme' => $options['theme'], 'type' => $options['type'], 'lang' => $options['lang'], 'size' => $options['size']];
 }