InputTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 1
c 0
b 0
f 0
lcom 1
cbo 5
dl 0
loc 24
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testValidatorReceivesFilteredValueInContext() 0 21 1
1
<?php
2
3
namespace JhFlexiTimeTest\InputFilter;
4
5
use JhFlexiTime\InputFilter\BaseInputFilter as InputFilter;
6
use PHPUnit_Framework_TestCase;
7
use Zend\Filter\StringTrim;
8
use JhFlexiTime\InputFilter\Input;
9
use Zend\Validator;
10
11
/**
12
 * Class BaseInputFilterTest
13
 * @package JhFlexiTimeTest\InputFilter
14
 * @author  Aydin Hassan <[email protected]>
15
 */
16
class InputTest extends PHPUnit_Framework_TestCase
17
{
18
    public function testValidatorReceivesFilteredValueInContext()
19
    {
20
        $input1 = new Input('input1');
21
        $input1->getFilterChain()->attach(new StringTrim());
22
23
        $validator = $this->getMock('Zend\Validator\ValidatorInterface');
24
        $validator
25
            ->expects($this->once())
26
            ->method('isValid')
27
            ->with('value1', ['input1' => 'value1']);
28
29
        $validator
30
            ->expects($this->once())
31
            ->method('getMessages')
32
            ->will($this->returnValue([]));
33
34
        $input1->getValidatorChain()->attach($validator);
35
36
        $input1->setValue('   value1    ');
37
        $input1->isValid(['input1' => '   value1    ']);
38
    }
39
}
40