Esempio n. 1
0
 function testRuleAndMessageGettersSetters()
 {
     $post = new TestPost();
     $this->assertEquals(4, count($post->getRules()));
     $this->assertEquals('required', $post->getRule('title'));
     $this->assertEquals(2, count($post->setRules(array('title' => 'required', 'date' => 'required'))->getRules()));
     $this->assertEquals(3, count($post->setRule('slug', 'required')->getRules()));
     $post->mergeRules(array('content' => 'required'));
     $this->assertEquals(4, count($post->getRules()));
     $post->setCustomMessage('title', 'hello');
     $this->assertEquals(1, count($post->getCustomMessages()));
     $post->setCustomMessages(array('title.required' => 'Bad title', 'date.required' => 'Bad date'));
     $this->assertEquals(2, count($post->getCustomMessages()));
     $post->mergeCustomMessages(array('content.required' => 'Bad content'));
     $this->assertEquals(3, count($post->getCustomMessages()));
     $this->assertEquals(12, count($post->getObservableEvents()));
 }