コード例 #1
0
 public function testSubmitCheck()
 {
     $response = "HTTP/1.0 200 OK\r\n" . "Connection: close\r\n" . "\r\n" . '{"rsp":{"@attributes":{"stat":"ok"},"method":"webpurify.live.check","format":"rest","found":"0","api_key":"xxxxx"}}';
     $this->adapter->setResponse($response);
     try {
         $response = $this->_webpurify->check('ham');
     } catch (Exception $e) {
         $this->fail('Valid key should not throw exceptions');
     }
     // ham shouldn't be marked as profanity
     $this->assertFalse($response);
 }
コード例 #2
0
ファイル: Validate.php プロジェクト: aporat/service_webpurify
 /**
  * checks if a text has profanity or not
  * @param string $value
  */
 public function isValid($value, $context = null)
 {
     if ($context != null) {
         foreach ($this->_listOfFields as $field) {
             if (isset($context[$field])) {
                 $value .= ' ' . $context[$field];
             }
         }
     }
     $profanityFound = $this->_validatorService->check($value);
     if ($profanityFound === true) {
         $this->_error('profanity');
         return false;
     }
     return true;
 }