Completed
Push — master ( bd2863...897b5a )
by Shcherbak
45:04 queued 30:10
created

RegexpTest::testRegexp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 22
rs 9.2
cc 1
eloc 14
nc 1
nop 0
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