testValidatorReceivesFilteredValueInContext()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 21
rs 9.3142
cc 1
eloc 15
nc 1
nop 0
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