public function testIsAlphabetical()
 {
     $this->assertTrue(SpoonFilter::isAlphabetical('geen'));
     $this->assertTrue(SpoonFilter::isAlphabetical('GeeN'));
     $this->assertFalse(SpoonFilter::isAlphabetical('géén'));
     $this->assertFalse(SpoonFilter::isAlphabetical('gééN'));
     // Simulating PHP < 5.4 behaviour
     $this->assertTrue(SpoonFilter::isAlphabetical(array('a', 'b')));
 }
Example #2
0
 /**
  * Checks if this field contains only letters a-z and A-Z.
  *
  * @return	bool
  * @param	string[optional] $error		The error message to set.
  */
 public function isAlphabetical($error = null)
 {
     // filled
     if ($this->isFilled()) {
         // post/get data
         $data = $this->getMethod(true);
         // validate
         if (!isset($data[$this->attributes['name']]) || !SpoonFilter::isAlphabetical($data[$this->attributes['name']])) {
             if ($error !== null) {
                 $this->setError($error);
             }
             return false;
         }
         return true;
     }
     // not submitted
     if ($error !== null) {
         $this->setError($error);
     }
     return false;
 }
 public function testIsAlphabetical()
 {
     $this->assertTrue(SpoonFilter::isAlphabetical('geen'));
     $this->assertTrue(SpoonFilter::isAlphabetical('GeeN'));
     $this->assertFalse(SpoonFilter::isAlphabetical('géén'));
     $this->assertFalse(SpoonFilter::isAlphabetical('gééN'));
 }