| @@ 34-42 (lines=9) @@ | ||
| 31 | /** |
|
| 32 | * Tests Validator::setRules |
|
| 33 | */ |
|
| 34 | public function testSetRulesValid() |
|
| 35 | { |
|
| 36 | $msg = new CommitMessage('Foo'); |
|
| 37 | $v = new Validator(); |
|
| 38 | $v->setRules([new MsgNotEmpty()]); |
|
| 39 | ||
| 40 | $v->validate($msg); |
|
| 41 | $this->assertTrue(true); |
|
| 42 | } |
|
| 43 | ||
| 44 | /** |
|
| 45 | * Tests Validator::setRules |
|
| @@ 49-55 (lines=7) @@ | ||
| 46 | * |
|
| 47 | * @expectedException \Exception |
|
| 48 | */ |
|
| 49 | public function testSetRulesInvalid() |
|
| 50 | { |
|
| 51 | $msg = new CommitMessage(''); |
|
| 52 | $v = new Validator(); |
|
| 53 | $v->setRules([new MsgNotEmpty()]); |
|
| 54 | $v->validate($msg); |
|
| 55 | } |
|
| 56 | ||
| 57 | /** |
|
| 58 | * Tests Validator::setRules |
|
| @@ 62-70 (lines=9) @@ | ||
| 59 | * |
|
| 60 | * @expectedException \Exception |
|
| 61 | */ |
|
| 62 | public function testAddRuleInvalid() |
|
| 63 | { |
|
| 64 | $msg = new CommitMessage('foo bar baz'); |
|
| 65 | $v = new Validator(); |
|
| 66 | $v->setRules([new MsgNotEmpty()]); |
|
| 67 | $v->addRule(new CapitalizeSubject()); |
|
| 68 | ||
| 69 | $v->validate($msg); |
|
| 70 | } |
|
| 71 | } |
|
| 72 | ||