Completed
Push — master ( bd2863...897b5a )
by Shcherbak
45:04 queued 30:10
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 Method

Rating   Name   Duplication   Size   Complexity  
A testRegexp() 0 22 1
1
<?php
2
3
  namespace Tests\Fiv\Form\Validator;
4
5
  use Fiv\Form\Form;
6
7
  /**
8
   *
9
   */
10
  class RegexpTest extends \PHPUnit_Framework_TestCase {
11
12
    public function testRegexp() {
13
      $regexpValidator = new \Fiv\Form\Validator\Regexp();
14
      $regexpValidator->setRegexp('![^\@]+\@[^\@]+!');
15
16
      $form = new Form();
17
      $form->input('email')
18
        ->addValidator($regexpValidator);
19
20
      $form->setData([
21
        $form->getUid() => 1,
22
        'email' => 'test@test',
23
      ]);
24
25
      $this->assertTrue($form->isValid());
26
27
      $form->setData([
28
        $form->getUid() => 1,
29
        'email' => 'test',
30
      ]);
31
32
      $this->assertFalse($form->isValid());
33
    }
34
  }
35