Completed
Push — master ( 3cc3b2...768def )
by Vitaliy
01:53
created

RegexpTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 25
rs 10
1
<?php
2
3
  namespace Tests\Fiv\Form\Validator;
4
5
  use Fiv\Form\Form;
6
  use Fiv\Form\FormData;
7
8
  /**
9
   *
10
   */
11
  class RegexpTest extends \PHPUnit_Framework_TestCase {
12
13
    public function testRegexp() {
14
      $regexpValidator = new \Fiv\Form\Validator\Regexp();
15
      $regexpValidator->setRegexp('![^\@]+\@[^\@]+!');
16
17
      $form = new Form();
18
      $form->input('email')
19
        ->addValidator($regexpValidator);
20
21
      $form->handle(new FormData('post', [
22
        $form->getUid() => 1,
23
        'email' => 'test@test',
24
      ]));
25
26
      $this->assertTrue($form->isValid());
27
28
      $form->handle(new FormData('post', [
29
        $form->getUid() => 1,
30
        'email' => 'test',
31
      ]));
32
33
      $this->assertFalse($form->isValid());
34
    }
35
  }
36