Exemplo n.º 1
0
 /**
  * @test
  */
 function kanaType_katakana_fails_for_text_with_non_katakana()
 {
     // with hiragana
     $text = 'アイウエオ' . 'あ';
     $value = $this->validate->apply($text, array('kanaType' => Rules::ONLY_KATAKANA));
     $this->assertEquals(true, $value->fails());
     //        $this->assertEquals( null, $this->validate->result()->message() );
     // with ascii
     $text = 'アイウエオ' . 'a';
     $value = $this->validate->apply($text, array('kanaType' => Rules::ONLY_KATAKANA));
     $this->assertEquals(true, $value->fails());
     //        $this->assertEquals( null, $this->validate->result()->message() );
     // with space... not sure if this should fail
     $text = 'アイウエオ' . ' ';
     $value = $this->validate->apply($text, array('kanaType' => Rules::ONLY_KATAKANA));
     $this->assertEquals(true, $value->fails());
     //        $this->assertEquals( null, $this->validate->result()->message() );
 }
Exemplo n.º 2
0
 /**
  * @test
  */
 function closure_with_error()
 {
     /**
      * @param ValueTO $v
      */
     $filter = function ($v) {
         $val = $v->getValue();
         $val .= ':bad';
         $v->setValue($val);
         $v->setError(__METHOD__);
         $v->setMessage('Closure with Error');
     };
     $found = $this->verify->is('test', $this->factory->rules()->withType('text')->custom($filter));
     $this->assertEquals(false, $found);
     /** @var ValueTO $valTo */
     $valTo = $this->verify->apply('test', $this->factory->rules()->withType('text')->custom($filter));
     $this->assertTrue($valTo->fails());
     $this->assertTrue($valTo->getBreak());
     $this->assertEquals('test:bad', $valTo->getValue());
     $this->assertEquals('Closure with Error', $valTo->message());
 }